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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Class representing a vector containing 2 coordinates
  1909. */
  1910. export class Vector2 {
  1911. /** defines the first coordinate */
  1912. x: number;
  1913. /** defines the second coordinate */
  1914. y: number;
  1915. /**
  1916. * Creates a new Vector2 from the given x and y coordinates
  1917. * @param x defines the first coordinate
  1918. * @param y defines the second coordinate
  1919. */
  1920. constructor(
  1921. /** defines the first coordinate */
  1922. x?: number,
  1923. /** defines the second coordinate */
  1924. y?: number);
  1925. /**
  1926. * Gets a string with the Vector2 coordinates
  1927. * @returns a string with the Vector2 coordinates
  1928. */
  1929. toString(): string;
  1930. /**
  1931. * Gets class name
  1932. * @returns the string "Vector2"
  1933. */
  1934. getClassName(): string;
  1935. /**
  1936. * Gets current vector hash code
  1937. * @returns the Vector2 hash code as a number
  1938. */
  1939. getHashCode(): number;
  1940. /**
  1941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1942. * @param array defines the source array
  1943. * @param index defines the offset in source array
  1944. * @returns the current Vector2
  1945. */
  1946. toArray(array: FloatArray, index?: number): Vector2;
  1947. /**
  1948. * Copy the current vector to an array
  1949. * @returns a new array with 2 elements: the Vector2 coordinates.
  1950. */
  1951. asArray(): number[];
  1952. /**
  1953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1954. * @param source defines the source Vector2
  1955. * @returns the current updated Vector2
  1956. */
  1957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the Vector2 coordinates with the given floats
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. * @returns the current updated Vector2
  1963. */
  1964. copyFromFloats(x: number, y: number): Vector2;
  1965. /**
  1966. * Sets the Vector2 coordinates with the given floats
  1967. * @param x defines the first coordinate
  1968. * @param y defines the second coordinate
  1969. * @returns the current updated Vector2
  1970. */
  1971. set(x: number, y: number): Vector2;
  1972. /**
  1973. * Add another vector with the current one
  1974. * @param otherVector defines the other vector
  1975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1976. */
  1977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1980. * @param otherVector defines the other vector
  1981. * @param result defines the target vector
  1982. * @returns the unmodified current Vector2
  1983. */
  1984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1985. /**
  1986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1987. * @param otherVector defines the other vector
  1988. * @returns the current updated Vector2
  1989. */
  1990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1993. * @param otherVector defines the other vector
  1994. * @returns a new Vector2
  1995. */
  1996. addVector3(otherVector: Vector3): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2
  2001. */
  2002. subtract(otherVector: Vector2): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Multiplies in place the current Vector2 coordinates by the given ones
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2028. /**
  2029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2037. * @param x defines the first coordinate
  2038. * @param y defines the second coordinate
  2039. * @returns a new Vector2
  2040. */
  2041. multiplyByFloats(x: number, y: number): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. divide(otherVector: Vector2): Vector2;
  2048. /**
  2049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Divides the current Vector2 coordinates by the given ones
  2057. * @param otherVector defines the other vector
  2058. * @returns the current updated Vector2
  2059. */
  2060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Gets a new Vector2 with current Vector2 negated coordinates
  2063. * @returns a new Vector2
  2064. */
  2065. negate(): Vector2;
  2066. /**
  2067. * Negate this vector in place
  2068. * @returns this
  2069. */
  2070. negateInPlace(): Vector2;
  2071. /**
  2072. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2073. * @param result defines the Vector3 object where to store the result
  2074. * @returns the current Vector2
  2075. */
  2076. negateToRef(result: Vector2): Vector2;
  2077. /**
  2078. * Multiply the Vector2 coordinates by scale
  2079. * @param scale defines the scaling factor
  2080. * @returns the current updated Vector2
  2081. */
  2082. scaleInPlace(scale: number): Vector2;
  2083. /**
  2084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2085. * @param scale defines the scaling factor
  2086. * @returns a new Vector2
  2087. */
  2088. scale(scale: number): Vector2;
  2089. /**
  2090. * Scale the current Vector2 values by a factor to a given Vector2
  2091. * @param scale defines the scale factor
  2092. * @param result defines the Vector2 object where to store the result
  2093. * @returns the unmodified current Vector2
  2094. */
  2095. scaleToRef(scale: number, result: Vector2): Vector2;
  2096. /**
  2097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2098. * @param scale defines the scale factor
  2099. * @param result defines the Vector2 object where to store the result
  2100. * @returns the unmodified current Vector2
  2101. */
  2102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2103. /**
  2104. * Gets a boolean if two vectors are equals
  2105. * @param otherVector defines the other vector
  2106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2107. */
  2108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2109. /**
  2110. * Gets a boolean if two vectors are equals (using an epsilon value)
  2111. * @param otherVector defines the other vector
  2112. * @param epsilon defines the minimal distance to consider equality
  2113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2114. */
  2115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. floor(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 from current Vector2 floored values
  2123. * @returns a new Vector2
  2124. */
  2125. fract(): Vector2;
  2126. /**
  2127. * Gets the length of the vector
  2128. * @returns the vector length (float)
  2129. */
  2130. length(): number;
  2131. /**
  2132. * Gets the vector squared length
  2133. * @returns the vector squared length (float)
  2134. */
  2135. lengthSquared(): number;
  2136. /**
  2137. * Normalize the vector
  2138. * @returns the current updated Vector2
  2139. */
  2140. normalize(): Vector2;
  2141. /**
  2142. * Gets a new Vector2 copied from the Vector2
  2143. * @returns a new Vector2
  2144. */
  2145. clone(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(0, 0)
  2148. * @returns a new Vector2
  2149. */
  2150. static Zero(): Vector2;
  2151. /**
  2152. * Gets a new Vector2(1, 1)
  2153. * @returns a new Vector2
  2154. */
  2155. static One(): Vector2;
  2156. /**
  2157. * Gets a new Vector2 set from the given index element of the given array
  2158. * @param array defines the data source
  2159. * @param offset defines the offset in the data source
  2160. * @returns a new Vector2
  2161. */
  2162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2163. /**
  2164. * Sets "result" from the given index element of the given array
  2165. * @param array defines the data source
  2166. * @param offset defines the offset in the data source
  2167. * @param result defines the target vector
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2170. /**
  2171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2172. * @param value1 defines 1st point of control
  2173. * @param value2 defines 2nd point of control
  2174. * @param value3 defines 3rd point of control
  2175. * @param value4 defines 4th point of control
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2184. * @param value defines the value to clamp
  2185. * @param min defines the lower limit
  2186. * @param max defines the upper limit
  2187. * @returns a new Vector2
  2188. */
  2189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2192. * @param value1 defines the 1st control point
  2193. * @param tangent1 defines the outgoing tangent
  2194. * @param value2 defines the 2nd control point
  2195. * @param tangent2 defines the incoming tangent
  2196. * @param amount defines the interpolation factor
  2197. * @returns a new Vector2
  2198. */
  2199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2202. * @param start defines the start vector
  2203. * @param end defines the end vector
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Gets the dot product of the vector "left" and the vector "right"
  2210. * @param left defines first vector
  2211. * @param right defines second vector
  2212. * @returns the dot product (float)
  2213. */
  2214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2215. /**
  2216. * Returns a new Vector2 equal to the normalized given vector
  2217. * @param vector defines the vector to normalize
  2218. * @returns a new Vector2
  2219. */
  2220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2223. * @param left defines 1st vector
  2224. * @param right defines 2nd vector
  2225. * @returns a new Vector2
  2226. */
  2227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2228. /**
  2229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2230. * @param left defines 1st vector
  2231. * @param right defines 2nd vector
  2232. * @returns a new Vector2
  2233. */
  2234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2237. * @param vector defines the vector to transform
  2238. * @param transformation defines the matrix to apply
  2239. * @returns a new Vector2
  2240. */
  2241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2242. /**
  2243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2244. * @param vector defines the vector to transform
  2245. * @param transformation defines the matrix to apply
  2246. * @param result defines the target vector
  2247. */
  2248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2249. /**
  2250. * Determines if a given vector is included in a triangle
  2251. * @param p defines the vector to test
  2252. * @param p0 defines 1st triangle point
  2253. * @param p1 defines 2nd triangle point
  2254. * @param p2 defines 3rd triangle point
  2255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2256. */
  2257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2258. /**
  2259. * Gets the distance between the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns the distance between vectors
  2263. */
  2264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2265. /**
  2266. * Returns the squared distance between the vectors "value1" and "value2"
  2267. * @param value1 defines first vector
  2268. * @param value2 defines second vector
  2269. * @returns the squared distance between vectors
  2270. */
  2271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2272. /**
  2273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns a new Vector2
  2277. */
  2278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2279. /**
  2280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2281. * @param p defines the middle point
  2282. * @param segA defines one point of the segment
  2283. * @param segB defines the other point of the segment
  2284. * @returns the shortest distance
  2285. */
  2286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2287. }
  2288. /**
  2289. * Class used to store (x,y,z) vector representation
  2290. * A Vector3 is the main object used in 3D geometry
  2291. * It can represent etiher the coordinates of a point the space, either a direction
  2292. * Reminder: js uses a left handed forward facing system
  2293. */
  2294. export class Vector3 {
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x: number;
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y: number;
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z: number;
  2307. private static _UpReadOnly;
  2308. private static _ZeroReadOnly;
  2309. /**
  2310. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2311. * @param x defines the first coordinates (on X axis)
  2312. * @param y defines the second coordinates (on Y axis)
  2313. * @param z defines the third coordinates (on Z axis)
  2314. */
  2315. constructor(
  2316. /**
  2317. * Defines the first coordinates (on X axis)
  2318. */
  2319. x?: number,
  2320. /**
  2321. * Defines the second coordinates (on Y axis)
  2322. */
  2323. y?: number,
  2324. /**
  2325. * Defines the third coordinates (on Z axis)
  2326. */
  2327. z?: number);
  2328. /**
  2329. * Creates a string representation of the Vector3
  2330. * @returns a string with the Vector3 coordinates.
  2331. */
  2332. toString(): string;
  2333. /**
  2334. * Gets the class name
  2335. * @returns the string "Vector3"
  2336. */
  2337. getClassName(): string;
  2338. /**
  2339. * Creates the Vector3 hash code
  2340. * @returns a number which tends to be unique between Vector3 instances
  2341. */
  2342. getHashCode(): number;
  2343. /**
  2344. * Creates an array containing three elements : the coordinates of the Vector3
  2345. * @returns a new array of numbers
  2346. */
  2347. asArray(): number[];
  2348. /**
  2349. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2350. * @param array defines the destination array
  2351. * @param index defines the offset in the destination array
  2352. * @returns the current Vector3
  2353. */
  2354. toArray(array: FloatArray, index?: number): Vector3;
  2355. /**
  2356. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2357. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2358. */
  2359. toQuaternion(): Quaternion;
  2360. /**
  2361. * Adds the given vector to the current Vector3
  2362. * @param otherVector defines the second operand
  2363. * @returns the current updated Vector3
  2364. */
  2365. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the given coordinates to the current Vector3
  2368. * @param x defines the x coordinate of the operand
  2369. * @param y defines the y coordinate of the operand
  2370. * @param z defines the z coordinate of the operand
  2371. * @returns the current updated Vector3
  2372. */
  2373. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2374. /**
  2375. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2376. * @param otherVector defines the second operand
  2377. * @returns the resulting Vector3
  2378. */
  2379. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2382. * @param otherVector defines the second operand
  2383. * @param result defines the Vector3 object where to store the result
  2384. * @returns the current Vector3
  2385. */
  2386. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2387. /**
  2388. * Subtract the given vector from the current Vector3
  2389. * @param otherVector defines the second operand
  2390. * @returns the current updated Vector3
  2391. */
  2392. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the resulting Vector3
  2397. */
  2398. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2401. * @param otherVector defines the second operand
  2402. * @param result defines the Vector3 object where to store the result
  2403. * @returns the current Vector3
  2404. */
  2405. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2406. /**
  2407. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2408. * @param x defines the x coordinate of the operand
  2409. * @param y defines the y coordinate of the operand
  2410. * @param z defines the z coordinate of the operand
  2411. * @returns the resulting Vector3
  2412. */
  2413. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2414. /**
  2415. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2416. * @param x defines the x coordinate of the operand
  2417. * @param y defines the y coordinate of the operand
  2418. * @param z defines the z coordinate of the operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2423. /**
  2424. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2425. * @returns a new Vector3
  2426. */
  2427. negate(): Vector3;
  2428. /**
  2429. * Negate this vector in place
  2430. * @returns this
  2431. */
  2432. negateInPlace(): Vector3;
  2433. /**
  2434. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. negateToRef(result: Vector3): Vector3;
  2439. /**
  2440. * Multiplies the Vector3 coordinates by the float "scale"
  2441. * @param scale defines the multiplier factor
  2442. * @returns the current updated Vector3
  2443. */
  2444. scaleInPlace(scale: number): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2447. * @param scale defines the multiplier factor
  2448. * @returns a new Vector3
  2449. */
  2450. scale(scale: number): Vector3;
  2451. /**
  2452. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2453. * @param scale defines the multiplier factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the current Vector3
  2456. */
  2457. scaleToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2460. * @param scale defines the scale factor
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the unmodified current Vector3
  2463. */
  2464. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2465. /**
  2466. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2467. * @param otherVector defines the second operand
  2468. * @returns true if both vectors are equals
  2469. */
  2470. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2473. * @param otherVector defines the second operand
  2474. * @param epsilon defines the minimal distance to define values as equals
  2475. * @returns true if both vectors are distant less than epsilon
  2476. */
  2477. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2478. /**
  2479. * Returns true if the current Vector3 coordinates equals the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns true if both vectors are equals
  2484. */
  2485. equalsToFloats(x: number, y: number, z: number): boolean;
  2486. /**
  2487. * Multiplies the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2494. * @param otherVector defines the second operand
  2495. * @returns the new Vector3
  2496. */
  2497. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2500. * @param otherVector defines the second operand
  2501. * @param result defines the Vector3 object where to store the result
  2502. * @returns the current Vector3
  2503. */
  2504. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2507. * @param x defines the x coordinate of the operand
  2508. * @param y defines the y coordinate of the operand
  2509. * @param z defines the z coordinate of the operand
  2510. * @returns the new Vector3
  2511. */
  2512. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2513. /**
  2514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Divides the current Vector3 coordinates by the given ones.
  2528. * @param otherVector defines the second operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. divideInPlace(otherVector: Vector3): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2534. * @param other defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2540. * @param other defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2562. * Check if is non uniform within a certain amount of decimal places to account for this
  2563. * @param epsilon the amount the values can differ
  2564. * @returns if the the vector is non uniform to a certain number of decimal places
  2565. */
  2566. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2567. /**
  2568. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2569. */
  2570. get isNonUniform(): boolean;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. floor(): Vector3;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. fract(): Vector3;
  2581. /**
  2582. * Gets the length of the Vector3
  2583. * @returns the length of the Vector3
  2584. */
  2585. length(): number;
  2586. /**
  2587. * Gets the squared length of the Vector3
  2588. * @returns squared length of the Vector3
  2589. */
  2590. lengthSquared(): number;
  2591. /**
  2592. * Normalize the current Vector3.
  2593. * Please note that this is an in place operation.
  2594. * @returns the current updated Vector3
  2595. */
  2596. normalize(): Vector3;
  2597. /**
  2598. * Reorders the x y z properties of the vector in place
  2599. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2600. * @returns the current updated vector
  2601. */
  2602. reorderInPlace(order: string): this;
  2603. /**
  2604. * Rotates the vector around 0,0,0 by a quaternion
  2605. * @param quaternion the rotation quaternion
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2610. /**
  2611. * Rotates a vector around a given point
  2612. * @param quaternion the rotation quaternion
  2613. * @param point the point to rotate around
  2614. * @param result vector to store the result
  2615. * @returns the resulting vector
  2616. */
  2617. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2618. /**
  2619. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2620. * The cross product is then orthogonal to both current and "other"
  2621. * @param other defines the right operand
  2622. * @returns the cross product
  2623. */
  2624. cross(other: Vector3): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 with the given input length.
  2627. * Please note that this is an in place operation.
  2628. * @param len the length of the vector
  2629. * @returns the current updated Vector3
  2630. */
  2631. normalizeFromLength(len: number): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to a new vector
  2634. * @returns the new Vector3
  2635. */
  2636. normalizeToNew(): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to the reference
  2639. * @param reference define the Vector3 to update
  2640. * @returns the updated Vector3
  2641. */
  2642. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Creates a new Vector3 copied from the current Vector3
  2645. * @returns the new Vector3
  2646. */
  2647. clone(): Vector3;
  2648. /**
  2649. * Copies the given vector coordinates to the current Vector3 ones
  2650. * @param source defines the source Vector3
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. copyFromFloats(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given floats to the current Vector3 coordinates
  2664. * @param x defines the x coordinate of the operand
  2665. * @param y defines the y coordinate of the operand
  2666. * @param z defines the z coordinate of the operand
  2667. * @returns the current updated Vector3
  2668. */
  2669. set(x: number, y: number, z: number): Vector3;
  2670. /**
  2671. * Copies the given float to the current Vector3 coordinates
  2672. * @param v defines the x, y and z coordinates of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. setAll(v: number): Vector3;
  2676. /**
  2677. * Get the clip factor between two vectors
  2678. * @param vector0 defines the first operand
  2679. * @param vector1 defines the second operand
  2680. * @param axis defines the axis to use
  2681. * @param size defines the size along the axis
  2682. * @returns the clip factor
  2683. */
  2684. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2685. /**
  2686. * Get angle between two vectors
  2687. * @param vector0 angle between vector0 and vector1
  2688. * @param vector1 angle between vector0 and vector1
  2689. * @param normal direction of the normal
  2690. * @return the angle between vector0 and vector1
  2691. */
  2692. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given array
  2695. * @param array defines the source array
  2696. * @param offset defines the offset in the source array
  2697. * @returns the new Vector3
  2698. */
  2699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2700. /**
  2701. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @returns the new Vector3
  2705. * @deprecated Please use FromArray instead.
  2706. */
  2707. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2710. * @param array defines the source array
  2711. * @param offset defines the offset in the source array
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2717. * @param array defines the source array
  2718. * @param offset defines the offset in the source array
  2719. * @param result defines the Vector3 where to store the result
  2720. * @deprecated Please use FromArrayToRef instead.
  2721. */
  2722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2723. /**
  2724. * Sets the given vector "result" with the given floats.
  2725. * @param x defines the x coordinate of the source
  2726. * @param y defines the y coordinate of the source
  2727. * @param z defines the z coordinate of the source
  2728. * @param result defines the Vector3 where to store the result
  2729. */
  2730. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2731. /**
  2732. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2733. * @returns a new empty Vector3
  2734. */
  2735. static Zero(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2738. * @returns a new unit Vector3
  2739. */
  2740. static One(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2743. * @returns a new up Vector3
  2744. */
  2745. static Up(): Vector3;
  2746. /**
  2747. * Gets a up Vector3 that must not be updated
  2748. */
  2749. static get UpReadOnly(): DeepImmutable<Vector3>;
  2750. /**
  2751. * Gets a zero Vector3 that must not be updated
  2752. */
  2753. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2756. * @returns a new down Vector3
  2757. */
  2758. static Down(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Forward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Backward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2771. * @returns a new right Vector3
  2772. */
  2773. static Right(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2776. * @returns a new left Vector3
  2777. */
  2778. static Left(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @returns the transformed Vector3
  2785. */
  2786. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2789. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2790. * @param vector defines the Vector3 to transform
  2791. * @param transformation defines the transformation matrix
  2792. * @param result defines the Vector3 where to store the result
  2793. */
  2794. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2795. /**
  2796. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2797. * This method computes tranformed coordinates only, not transformed direction vectors
  2798. * @param x define the x coordinate of the source vector
  2799. * @param y define the y coordinate of the source vector
  2800. * @param z define the z coordinate of the source vector
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the new Vector3
  2811. */
  2812. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2823. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2833. * @param value1 defines the first control point
  2834. * @param value2 defines the second control point
  2835. * @param value3 defines the third control point
  2836. * @param value4 defines the fourth control point
  2837. * @param amount defines the amount on the spline to use
  2838. * @returns the new Vector3
  2839. */
  2840. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2841. /**
  2842. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2843. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2844. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2845. * @param value defines the current value
  2846. * @param min defines the lower range value
  2847. * @param max defines the upper range value
  2848. * @returns the new Vector3
  2849. */
  2850. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2853. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2854. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2855. * @param value defines the current value
  2856. * @param min defines the lower range value
  2857. * @param max defines the upper range value
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2861. /**
  2862. * Checks if a given vector is inside a specific range
  2863. * @param v defines the vector to test
  2864. * @param min defines the minimum range
  2865. * @param max defines the maximum range
  2866. */
  2867. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2868. /**
  2869. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2870. * @param value1 defines the first control point
  2871. * @param tangent1 defines the first tangent vector
  2872. * @param value2 defines the second control point
  2873. * @param tangent2 defines the second tangent vector
  2874. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @returns the new Vector3
  2884. */
  2885. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2886. /**
  2887. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2888. * @param start defines the start value
  2889. * @param end defines the end value
  2890. * @param amount max defines amount between both (between 0 and 1)
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2894. /**
  2895. * Returns the dot product (float) between the vectors "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the dot product
  2899. */
  2900. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2901. /**
  2902. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @returns the cross product
  2907. */
  2908. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2909. /**
  2910. * Sets the given vector "result" with the cross product of "left" and "right"
  2911. * The cross product is then orthogonal to both "left" and "right"
  2912. * @param left defines the left operand
  2913. * @param right defines the right operand
  2914. * @param result defines the Vector3 where to store the result
  2915. */
  2916. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2917. /**
  2918. * Returns a new Vector3 as the normalization of the given vector
  2919. * @param vector defines the Vector3 to normalize
  2920. * @returns the new Vector3
  2921. */
  2922. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2923. /**
  2924. * Sets the given vector "result" with the normalization of the given first vector
  2925. * @param vector defines the Vector3 to normalize
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2929. /**
  2930. * Project a Vector3 onto screen space
  2931. * @param vector defines the Vector3 to project
  2932. * @param world defines the world matrix to use
  2933. * @param transform defines the transform (view x projection) matrix to use
  2934. * @param viewport defines the screen viewport to use
  2935. * @returns the new Vector3
  2936. */
  2937. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2938. /** @hidden */
  2939. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param source defines the screen space Vector3 to use
  2943. * @param viewportWidth defines the current width of the viewport
  2944. * @param viewportHeight defines the current height of the viewport
  2945. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @returns the new Vector3
  2948. */
  2949. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2950. /**
  2951. * Unproject from screen space to object space
  2952. * @param source defines the screen space Vector3 to use
  2953. * @param viewportWidth defines the current width of the viewport
  2954. * @param viewportHeight defines the current height of the viewport
  2955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2956. * @param view defines the view matrix to use
  2957. * @param projection defines the projection matrix to use
  2958. * @returns the new Vector3
  2959. */
  2960. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2961. /**
  2962. * Unproject from screen space to object space
  2963. * @param source defines the screen space Vector3 to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param view defines the view matrix to use
  2968. * @param projection defines the projection matrix to use
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2972. /**
  2973. * Unproject from screen space to object space
  2974. * @param sourceX defines the screen space x coordinate to use
  2975. * @param sourceY defines the screen space y coordinate to use
  2976. * @param sourceZ defines the screen space z coordinate to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Gets the minimal coordinate values between two Vector3
  2987. * @param left defines the first operand
  2988. * @param right defines the second operand
  2989. * @returns the new Vector3
  2990. */
  2991. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Gets the maximal coordinate values between two Vector3
  2994. * @param left defines the first operand
  2995. * @param right defines the second operand
  2996. * @returns the new Vector3
  2997. */
  2998. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * Returns the distance between the vectors "value1" and "value2"
  3001. * @param value1 defines the first operand
  3002. * @param value2 defines the second operand
  3003. * @returns the distance
  3004. */
  3005. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3006. /**
  3007. * Returns the squared distance between the vectors "value1" and "value2"
  3008. * @param value1 defines the first operand
  3009. * @param value2 defines the second operand
  3010. * @returns the squared distance
  3011. */
  3012. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3013. /**
  3014. * Returns a new Vector3 located at the center between "value1" and "value2"
  3015. * @param value1 defines the first operand
  3016. * @param value2 defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3022. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3023. * to something in order to rotate it from its local system to the given target system
  3024. * Note: axis1, axis2 and axis3 are normalized during this operation
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @returns a new Vector3
  3029. */
  3030. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3031. /**
  3032. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3033. * @param axis1 defines the first axis
  3034. * @param axis2 defines the second axis
  3035. * @param axis3 defines the third axis
  3036. * @param ref defines the Vector3 where to store the result
  3037. */
  3038. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3039. }
  3040. /**
  3041. * Vector4 class created for EulerAngle class conversion to Quaternion
  3042. */
  3043. export class Vector4 {
  3044. /** x value of the vector */
  3045. x: number;
  3046. /** y value of the vector */
  3047. y: number;
  3048. /** z value of the vector */
  3049. z: number;
  3050. /** w value of the vector */
  3051. w: number;
  3052. /**
  3053. * Creates a Vector4 object from the given floats.
  3054. * @param x x value of the vector
  3055. * @param y y value of the vector
  3056. * @param z z value of the vector
  3057. * @param w w value of the vector
  3058. */
  3059. constructor(
  3060. /** x value of the vector */
  3061. x: number,
  3062. /** y value of the vector */
  3063. y: number,
  3064. /** z value of the vector */
  3065. z: number,
  3066. /** w value of the vector */
  3067. w: number);
  3068. /**
  3069. * Returns the string with the Vector4 coordinates.
  3070. * @returns a string containing all the vector values
  3071. */
  3072. toString(): string;
  3073. /**
  3074. * Returns the string "Vector4".
  3075. * @returns "Vector4"
  3076. */
  3077. getClassName(): string;
  3078. /**
  3079. * Returns the Vector4 hash code.
  3080. * @returns a unique hash code
  3081. */
  3082. getHashCode(): number;
  3083. /**
  3084. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3085. * @returns the resulting array
  3086. */
  3087. asArray(): number[];
  3088. /**
  3089. * Populates the given array from the given index with the Vector4 coordinates.
  3090. * @param array array to populate
  3091. * @param index index of the array to start at (default: 0)
  3092. * @returns the Vector4.
  3093. */
  3094. toArray(array: FloatArray, index?: number): Vector4;
  3095. /**
  3096. * Adds the given vector to the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the updated Vector4.
  3099. */
  3100. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3103. * @param otherVector the vector to add
  3104. * @returns the resulting vector
  3105. */
  3106. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3107. /**
  3108. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3109. * @param otherVector the vector to add
  3110. * @param result the vector to store the result
  3111. * @returns the current Vector4.
  3112. */
  3113. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3114. /**
  3115. * Subtract in place the given vector from the current Vector4.
  3116. * @param otherVector the vector to subtract
  3117. * @returns the updated Vector4.
  3118. */
  3119. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3122. * @param otherVector the vector to add
  3123. * @returns the new vector with the result
  3124. */
  3125. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3126. /**
  3127. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3128. * @param otherVector the vector to subtract
  3129. * @param result the vector to store the result
  3130. * @returns the current Vector4.
  3131. */
  3132. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3133. /**
  3134. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3135. */
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @returns new vector containing the result
  3143. */
  3144. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3147. * @param x value to subtract
  3148. * @param y value to subtract
  3149. * @param z value to subtract
  3150. * @param w value to subtract
  3151. * @param result the vector to store the result in
  3152. * @returns the current Vector4.
  3153. */
  3154. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3155. /**
  3156. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3157. * @returns a new vector with the negated values
  3158. */
  3159. negate(): Vector4;
  3160. /**
  3161. * Negate this vector in place
  3162. * @returns this
  3163. */
  3164. negateInPlace(): Vector4;
  3165. /**
  3166. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3167. * @param result defines the Vector3 object where to store the result
  3168. * @returns the current Vector4
  3169. */
  3170. negateToRef(result: Vector4): Vector4;
  3171. /**
  3172. * Multiplies the current Vector4 coordinates by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns the updated Vector4.
  3175. */
  3176. scaleInPlace(scale: number): Vector4;
  3177. /**
  3178. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @returns a new vector with the result
  3181. */
  3182. scale(scale: number): Vector4;
  3183. /**
  3184. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3185. * @param scale the number to scale with
  3186. * @param result a vector to store the result in
  3187. * @returns the current Vector4.
  3188. */
  3189. scaleToRef(scale: number, result: Vector4): Vector4;
  3190. /**
  3191. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3192. * @param scale defines the scale factor
  3193. * @param result defines the Vector4 object where to store the result
  3194. * @returns the unmodified current Vector4
  3195. */
  3196. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3199. * @param otherVector the vector to compare against
  3200. * @returns true if they are equal
  3201. */
  3202. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3203. /**
  3204. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3205. * @param otherVector vector to compare against
  3206. * @param epsilon (Default: very small number)
  3207. * @returns true if they are equal
  3208. */
  3209. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3210. /**
  3211. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3212. * @param x x value to compare against
  3213. * @param y y value to compare against
  3214. * @param z z value to compare against
  3215. * @param w w value to compare against
  3216. * @returns true if equal
  3217. */
  3218. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3219. /**
  3220. * Multiplies in place the current Vector4 by the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns the updated Vector4.
  3223. */
  3224. multiplyInPlace(otherVector: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @returns resulting new vector
  3229. */
  3230. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3233. * @param otherVector vector to multiple with
  3234. * @param result vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3240. * @param x x value multiply with
  3241. * @param y y value multiply with
  3242. * @param z z value multiply with
  3243. * @param w w value multiply with
  3244. * @returns resulting new vector
  3245. */
  3246. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @returns resulting new vector
  3251. */
  3252. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3255. * @param otherVector vector to devide with
  3256. * @param result vector to store the result
  3257. * @returns the current Vector4.
  3258. */
  3259. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3260. /**
  3261. * Divides the current Vector3 coordinates by the given ones.
  3262. * @param otherVector vector to devide with
  3263. * @returns the updated Vector3.
  3264. */
  3265. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3274. * @param other defines the second operand
  3275. * @returns the current updated Vector4
  3276. */
  3277. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector4 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. floor(): Vector4;
  3283. /**
  3284. * Gets a new Vector4 from current Vector3 floored values
  3285. * @returns a new Vector4
  3286. */
  3287. fract(): Vector4;
  3288. /**
  3289. * Returns the Vector4 length (float).
  3290. * @returns the length
  3291. */
  3292. length(): number;
  3293. /**
  3294. * Returns the Vector4 squared length (float).
  3295. * @returns the length squared
  3296. */
  3297. lengthSquared(): number;
  3298. /**
  3299. * Normalizes in place the Vector4.
  3300. * @returns the updated Vector4.
  3301. */
  3302. normalize(): Vector4;
  3303. /**
  3304. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3305. * @returns this converted to a new vector3
  3306. */
  3307. toVector3(): Vector3;
  3308. /**
  3309. * Returns a new Vector4 copied from the current one.
  3310. * @returns the new cloned vector
  3311. */
  3312. clone(): Vector4;
  3313. /**
  3314. * Updates the current Vector4 with the given one coordinates.
  3315. * @param source the source vector to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to copy from
  3322. * @param y float to copy from
  3323. * @param z float to copy from
  3324. * @param w float to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @returns the updated Vector4.
  3335. */
  3336. set(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Copies the given float to the current Vector3 coordinates
  3339. * @param v defines the x, y, z and w coordinates of the operand
  3340. * @returns the current updated Vector3
  3341. */
  3342. setAll(v: number): Vector4;
  3343. /**
  3344. * Returns a new Vector4 set from the starting index of the given array.
  3345. * @param array the array to pull values from
  3346. * @param offset the offset into the array to start at
  3347. * @returns the new vector
  3348. */
  3349. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3350. /**
  3351. * Updates the given vector "result" from the starting index of the given array.
  3352. * @param array the array to pull values from
  3353. * @param offset the offset into the array to start at
  3354. * @param result the vector to store the result in
  3355. */
  3356. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3357. /**
  3358. * Updates the given vector "result" from the starting index of the given Float32Array.
  3359. * @param array the array to pull values from
  3360. * @param offset the offset into the array to start at
  3361. * @param result the vector to store the result in
  3362. */
  3363. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3364. /**
  3365. * Updates the given vector "result" coordinates from the given floats.
  3366. * @param x float to set from
  3367. * @param y float to set from
  3368. * @param z float to set from
  3369. * @param w float to set from
  3370. * @param result the vector to the floats in
  3371. */
  3372. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3373. /**
  3374. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3375. * @returns the new vector
  3376. */
  3377. static Zero(): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3380. * @returns the new vector
  3381. */
  3382. static One(): Vector4;
  3383. /**
  3384. * Returns a new normalized Vector4 from the given one.
  3385. * @param vector the vector to normalize
  3386. * @returns the vector
  3387. */
  3388. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Updates the given vector "result" from the normalization of the given one.
  3391. * @param vector the vector to normalize
  3392. * @param result the vector to store the result in
  3393. */
  3394. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3395. /**
  3396. * Returns a vector with the minimum values from the left and right vectors
  3397. * @param left left vector to minimize
  3398. * @param right right vector to minimize
  3399. * @returns a new vector with the minimum of the left and right vector values
  3400. */
  3401. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Returns a vector with the maximum values from the left and right vectors
  3404. * @param left left vector to maximize
  3405. * @param right right vector to maximize
  3406. * @returns a new vector with the maximum of the left and right vector values
  3407. */
  3408. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Returns the distance (float) between the vectors "value1" and "value2".
  3411. * @param value1 value to calulate the distance between
  3412. * @param value2 value to calulate the distance between
  3413. * @return the distance between the two vectors
  3414. */
  3415. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3416. /**
  3417. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3418. * @param value1 value to calulate the distance between
  3419. * @param value2 value to calulate the distance between
  3420. * @return the distance between the two vectors squared
  3421. */
  3422. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3423. /**
  3424. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3425. * @param value1 value to calulate the center between
  3426. * @param value2 value to calulate the center between
  3427. * @return the center between the two vectors
  3428. */
  3429. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @returns the new vector
  3436. */
  3437. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param vector the vector to transform
  3442. * @param transformation the transformation matrix to apply
  3443. * @param result the vector to store the result in
  3444. */
  3445. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3446. /**
  3447. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3448. * This methods computes transformed normalized direction vectors only.
  3449. * @param x value to transform
  3450. * @param y value to transform
  3451. * @param z value to transform
  3452. * @param w value to transform
  3453. * @param transformation the transformation matrix to apply
  3454. * @param result the vector to store the results in
  3455. */
  3456. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3457. /**
  3458. * Creates a new Vector4 from a Vector3
  3459. * @param source defines the source data
  3460. * @param w defines the 4th component (default is 0)
  3461. * @returns a new Vector4
  3462. */
  3463. static FromVector3(source: Vector3, w?: number): Vector4;
  3464. }
  3465. /**
  3466. * Class used to store quaternion data
  3467. * @see https://en.wikipedia.org/wiki/Quaternion
  3468. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3469. */
  3470. export class Quaternion {
  3471. /** defines the first component (0 by default) */
  3472. x: number;
  3473. /** defines the second component (0 by default) */
  3474. y: number;
  3475. /** defines the third component (0 by default) */
  3476. z: number;
  3477. /** defines the fourth component (1.0 by default) */
  3478. w: number;
  3479. /**
  3480. * Creates a new Quaternion from the given floats
  3481. * @param x defines the first component (0 by default)
  3482. * @param y defines the second component (0 by default)
  3483. * @param z defines the third component (0 by default)
  3484. * @param w defines the fourth component (1.0 by default)
  3485. */
  3486. constructor(
  3487. /** defines the first component (0 by default) */
  3488. x?: number,
  3489. /** defines the second component (0 by default) */
  3490. y?: number,
  3491. /** defines the third component (0 by default) */
  3492. z?: number,
  3493. /** defines the fourth component (1.0 by default) */
  3494. w?: number);
  3495. /**
  3496. * Gets a string representation for the current quaternion
  3497. * @returns a string with the Quaternion coordinates
  3498. */
  3499. toString(): string;
  3500. /**
  3501. * Gets the class name of the quaternion
  3502. * @returns the string "Quaternion"
  3503. */
  3504. getClassName(): string;
  3505. /**
  3506. * Gets a hash code for this quaternion
  3507. * @returns the quaternion hash code
  3508. */
  3509. getHashCode(): number;
  3510. /**
  3511. * Copy the quaternion to an array
  3512. * @returns a new array populated with 4 elements from the quaternion coordinates
  3513. */
  3514. asArray(): number[];
  3515. /**
  3516. * Check if two quaternions are equals
  3517. * @param otherQuaternion defines the second operand
  3518. * @return true if the current quaternion and the given one coordinates are strictly equals
  3519. */
  3520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3521. /**
  3522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3523. * @param otherQuaternion defines the other quaternion
  3524. * @param epsilon defines the minimal distance to consider equality
  3525. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3526. */
  3527. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3528. /**
  3529. * Clone the current quaternion
  3530. * @returns a new quaternion copied from the current one
  3531. */
  3532. clone(): Quaternion;
  3533. /**
  3534. * Copy a quaternion to the current one
  3535. * @param other defines the other quaternion
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3539. /**
  3540. * Updates the current quaternion with the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Updates the current quaternion from the given float coordinates
  3550. * @param x defines the x coordinate
  3551. * @param y defines the y coordinate
  3552. * @param z defines the z coordinate
  3553. * @param w defines the w coordinate
  3554. * @returns the updated current quaternion
  3555. */
  3556. set(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Adds two quaternions
  3559. * @param other defines the second operand
  3560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3561. */
  3562. add(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Add a quaternion to the current one
  3565. * @param other defines the quaternion to add
  3566. * @returns the current quaternion
  3567. */
  3568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3569. /**
  3570. * Subtract two quaternions
  3571. * @param other defines the second operand
  3572. * @returns a new quaternion as the subtraction result of the given one from the current one
  3573. */
  3574. subtract(other: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3579. */
  3580. scale(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies in place the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns the current modified quaternion
  3592. */
  3593. scaleInPlace(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies two quaternions
  3603. * @param q1 defines the second operand
  3604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3605. */
  3606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3609. * @param q1 defines the second operand
  3610. * @param result defines the target quaternion
  3611. * @returns the current quaternion
  3612. */
  3613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3614. /**
  3615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3616. * @param q1 defines the second operand
  3617. * @returns the currentupdated quaternion
  3618. */
  3619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3622. * @param ref defines the target quaternion
  3623. * @returns the current quaternion
  3624. */
  3625. conjugateToRef(ref: Quaternion): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. conjugateInPlace(): Quaternion;
  3631. /**
  3632. * Conjugates in place (1-q) the current quaternion
  3633. * @returns a new quaternion
  3634. */
  3635. conjugate(): Quaternion;
  3636. /**
  3637. * Gets length of current quaternion
  3638. * @returns the quaternion length (float)
  3639. */
  3640. length(): number;
  3641. /**
  3642. * Normalize in place the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. normalize(): Quaternion;
  3646. /**
  3647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3648. * @param order is a reserved parameter and is ignore for now
  3649. * @returns a new Vector3 containing the Euler angles
  3650. */
  3651. toEulerAngles(order?: string): Vector3;
  3652. /**
  3653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3654. * @param result defines the vector which will be filled with the Euler angles
  3655. * @param order is a reserved parameter and is ignore for now
  3656. * @returns the current unchanged quaternion
  3657. */
  3658. toEulerAnglesToRef(result: Vector3): Quaternion;
  3659. /**
  3660. * Updates the given rotation matrix with the current quaternion values
  3661. * @param result defines the target matrix
  3662. * @returns the current unchanged quaternion
  3663. */
  3664. toRotationMatrix(result: Matrix): Quaternion;
  3665. /**
  3666. * Updates the current quaternion from the given rotation matrix values
  3667. * @param matrix defines the source matrix
  3668. * @returns the current updated quaternion
  3669. */
  3670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3671. /**
  3672. * Creates a new quaternion from a rotation matrix
  3673. * @param matrix defines the source matrix
  3674. * @returns a new quaternion created from the given rotation matrix values
  3675. */
  3676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3677. /**
  3678. * Updates the given quaternion with the given rotation matrix values
  3679. * @param matrix defines the source matrix
  3680. * @param result defines the target quaternion
  3681. */
  3682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3683. /**
  3684. * Returns the dot product (float) between the quaternions "left" and "right"
  3685. * @param left defines the left operand
  3686. * @param right defines the right operand
  3687. * @returns the dot product
  3688. */
  3689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3690. /**
  3691. * Checks if the two quaternions are close to each other
  3692. * @param quat0 defines the first quaternion to check
  3693. * @param quat1 defines the second quaternion to check
  3694. * @returns true if the two quaternions are close to each other
  3695. */
  3696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3697. /**
  3698. * Creates an empty quaternion
  3699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3700. */
  3701. static Zero(): Quaternion;
  3702. /**
  3703. * Inverse a given quaternion
  3704. * @param q defines the source quaternion
  3705. * @returns a new quaternion as the inverted current quaternion
  3706. */
  3707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3708. /**
  3709. * Inverse a given quaternion
  3710. * @param q defines the source quaternion
  3711. * @param result the quaternion the result will be stored in
  3712. * @returns the result quaternion
  3713. */
  3714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3715. /**
  3716. * Creates an identity quaternion
  3717. * @returns the identity quaternion
  3718. */
  3719. static Identity(): Quaternion;
  3720. /**
  3721. * Gets a boolean indicating if the given quaternion is identity
  3722. * @param quaternion defines the quaternion to check
  3723. * @returns true if the quaternion is identity
  3724. */
  3725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3726. /**
  3727. * Creates a quaternion from a rotation around an axis
  3728. * @param axis defines the axis to use
  3729. * @param angle defines the angle to use
  3730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3731. */
  3732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3733. /**
  3734. * Creates a rotation around an axis and stores it into the given quaternion
  3735. * @param axis defines the axis to use
  3736. * @param angle defines the angle to use
  3737. * @param result defines the target quaternion
  3738. * @returns the target quaternion
  3739. */
  3740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3741. /**
  3742. * Creates a new quaternion from data stored into an array
  3743. * @param array defines the data source
  3744. * @param offset defines the offset in the source array where the data starts
  3745. * @returns a new quaternion
  3746. */
  3747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3748. /**
  3749. * Updates the given quaternion "result" from the starting index of the given array.
  3750. * @param array the array to pull values from
  3751. * @param offset the offset into the array to start at
  3752. * @param result the quaternion to store the result in
  3753. */
  3754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3755. /**
  3756. * Create a quaternion from Euler rotation angles
  3757. * @param x Pitch
  3758. * @param y Yaw
  3759. * @param z Roll
  3760. * @returns the new Quaternion
  3761. */
  3762. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3763. /**
  3764. * Updates a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @param result the quaternion to store the result
  3769. * @returns the updated quaternion
  3770. */
  3771. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Create a quaternion from Euler rotation vector
  3774. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3775. * @returns the new Quaternion
  3776. */
  3777. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3778. /**
  3779. * Updates a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @param result the quaternion to store the result
  3782. * @returns the updated quaternion
  3783. */
  3784. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3785. /**
  3786. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3787. * @param yaw defines the rotation around Y axis
  3788. * @param pitch defines the rotation around X axis
  3789. * @param roll defines the rotation around Z axis
  3790. * @returns the new quaternion
  3791. */
  3792. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3793. /**
  3794. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @param result defines the target quaternion
  3799. */
  3800. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3801. /**
  3802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3803. * @param alpha defines the rotation around first axis
  3804. * @param beta defines the rotation around second axis
  3805. * @param gamma defines the rotation around third axis
  3806. * @returns the new quaternion
  3807. */
  3808. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @param result defines the target quaternion
  3815. */
  3816. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3817. /**
  3818. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3819. * @param axis1 defines the first axis
  3820. * @param axis2 defines the second axis
  3821. * @param axis3 defines the third axis
  3822. * @returns the new quaternion
  3823. */
  3824. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3825. /**
  3826. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @param ref defines the target quaternion
  3831. */
  3832. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3833. /**
  3834. * Interpolates between two quaternions
  3835. * @param left defines first quaternion
  3836. * @param right defines second quaternion
  3837. * @param amount defines the gradient to use
  3838. * @returns the new interpolated quaternion
  3839. */
  3840. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3841. /**
  3842. * Interpolates between two quaternions and stores it into a target quaternion
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @param result defines the target quaternion
  3847. */
  3848. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3849. /**
  3850. * Interpolate between two quaternions using Hermite interpolation
  3851. * @param value1 defines first quaternion
  3852. * @param tangent1 defines the incoming tangent
  3853. * @param value2 defines second quaternion
  3854. * @param tangent2 defines the outgoing tangent
  3855. * @param amount defines the target quaternion
  3856. * @returns the new interpolated quaternion
  3857. */
  3858. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3859. }
  3860. /**
  3861. * Class used to store matrix data (4x4)
  3862. */
  3863. export class Matrix {
  3864. private static _updateFlagSeed;
  3865. private static _identityReadOnly;
  3866. private _isIdentity;
  3867. private _isIdentityDirty;
  3868. private _isIdentity3x2;
  3869. private _isIdentity3x2Dirty;
  3870. /**
  3871. * Gets the update flag of the matrix which is an unique number for the matrix.
  3872. * It will be incremented every time the matrix data change.
  3873. * You can use it to speed the comparison between two versions of the same matrix.
  3874. */
  3875. updateFlag: number;
  3876. private readonly _m;
  3877. /**
  3878. * Gets the internal data of the matrix
  3879. */
  3880. get m(): DeepImmutable<Float32Array>;
  3881. /** @hidden */
  3882. _markAsUpdated(): void;
  3883. /** @hidden */
  3884. private _updateIdentityStatus;
  3885. /**
  3886. * Creates an empty matrix (filled with zeros)
  3887. */
  3888. constructor();
  3889. /**
  3890. * Check if the current matrix is identity
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentity(): boolean;
  3894. /**
  3895. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3896. * @returns true is the matrix is the identity matrix
  3897. */
  3898. isIdentityAs3x2(): boolean;
  3899. /**
  3900. * Gets the determinant of the matrix
  3901. * @returns the matrix determinant
  3902. */
  3903. determinant(): number;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array
  3907. */
  3908. toArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Returns the matrix as a Float32Array
  3911. * @returns the matrix underlying array.
  3912. */
  3913. asArray(): DeepImmutable<Float32Array>;
  3914. /**
  3915. * Inverts the current matrix in place
  3916. * @returns the current inverted matrix
  3917. */
  3918. invert(): Matrix;
  3919. /**
  3920. * Sets all the matrix elements to zero
  3921. * @returns the current matrix
  3922. */
  3923. reset(): Matrix;
  3924. /**
  3925. * Adds the current matrix with a second one
  3926. * @param other defines the matrix to add
  3927. * @returns a new matrix as the addition of the current matrix and the given one
  3928. */
  3929. add(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3932. * @param other defines the matrix to add
  3933. * @param result defines the target matrix
  3934. * @returns the current matrix
  3935. */
  3936. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3937. /**
  3938. * Adds in place the given matrix to the current matrix
  3939. * @param other defines the second operand
  3940. * @returns the current updated matrix
  3941. */
  3942. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3943. /**
  3944. * Sets the given matrix to the current inverted Matrix
  3945. * @param other defines the target matrix
  3946. * @returns the unmodified current matrix
  3947. */
  3948. invertToRef(other: Matrix): Matrix;
  3949. /**
  3950. * add a value at the specified position in the current Matrix
  3951. * @param index the index of the value within the matrix. between 0 and 15.
  3952. * @param value the value to be added
  3953. * @returns the current updated matrix
  3954. */
  3955. addAtIndex(index: number, value: number): Matrix;
  3956. /**
  3957. * mutiply the specified position in the current Matrix by a value
  3958. * @param index the index of the value within the matrix. between 0 and 15.
  3959. * @param value the value to be added
  3960. * @returns the current updated matrix
  3961. */
  3962. multiplyAtIndex(index: number, value: number): Matrix;
  3963. /**
  3964. * Inserts the translation vector (using 3 floats) in the current matrix
  3965. * @param x defines the 1st component of the translation
  3966. * @param y defines the 2nd component of the translation
  3967. * @param z defines the 3rd component of the translation
  3968. * @returns the current updated matrix
  3969. */
  3970. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3971. /**
  3972. * Adds the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Inserts the translation vector in the current matrix
  3981. * @param vector3 defines the translation to insert
  3982. * @returns the current updated matrix
  3983. */
  3984. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3985. /**
  3986. * Gets the translation value of the current matrix
  3987. * @returns a new Vector3 as the extracted translation from the matrix
  3988. */
  3989. getTranslation(): Vector3;
  3990. /**
  3991. * Fill a Vector3 with the extracted translation from the matrix
  3992. * @param result defines the Vector3 where to store the translation
  3993. * @returns the current matrix
  3994. */
  3995. getTranslationToRef(result: Vector3): Matrix;
  3996. /**
  3997. * Remove rotation and scaling part from the matrix
  3998. * @returns the updated matrix
  3999. */
  4000. removeRotationAndScaling(): Matrix;
  4001. /**
  4002. * Multiply two matrices
  4003. * @param other defines the second operand
  4004. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4005. */
  4006. multiply(other: DeepImmutable<Matrix>): Matrix;
  4007. /**
  4008. * Copy the current matrix from the given one
  4009. * @param other defines the source matrix
  4010. * @returns the current updated matrix
  4011. */
  4012. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Populates the given array from the starting index with the current matrix values
  4015. * @param array defines the target array
  4016. * @param offset defines the offset in the target array where to start storing values
  4017. * @returns the current matrix
  4018. */
  4019. copyToArray(array: Float32Array, offset?: number): Matrix;
  4020. /**
  4021. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4022. * @param other defines the second operand
  4023. * @param result defines the matrix where to store the multiplication
  4024. * @returns the current matrix
  4025. */
  4026. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4027. /**
  4028. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4029. * @param other defines the second operand
  4030. * @param result defines the array where to store the multiplication
  4031. * @param offset defines the offset in the target array where to start storing values
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4035. /**
  4036. * Check equality between this matrix and a second one
  4037. * @param value defines the second matrix to compare
  4038. * @returns true is the current matrix and the given one values are strictly equal
  4039. */
  4040. equals(value: DeepImmutable<Matrix>): boolean;
  4041. /**
  4042. * Clone the current matrix
  4043. * @returns a new matrix from the current matrix
  4044. */
  4045. clone(): Matrix;
  4046. /**
  4047. * Returns the name of the current matrix class
  4048. * @returns the string "Matrix"
  4049. */
  4050. getClassName(): string;
  4051. /**
  4052. * Gets the hash code of the current matrix
  4053. * @returns the hash code
  4054. */
  4055. getHashCode(): number;
  4056. /**
  4057. * Decomposes the current Matrix into a translation, rotation and scaling components
  4058. * @param scale defines the scale vector3 given as a reference to update
  4059. * @param rotation defines the rotation quaternion given as a reference to update
  4060. * @param translation defines the translation vector3 given as a reference to update
  4061. * @returns true if operation was successful
  4062. */
  4063. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4064. /**
  4065. * Gets specific row of the matrix
  4066. * @param index defines the number of the row to get
  4067. * @returns the index-th row of the current matrix as a new Vector4
  4068. */
  4069. getRow(index: number): Nullable<Vector4>;
  4070. /**
  4071. * Sets the index-th row of the current matrix to the vector4 values
  4072. * @param index defines the number of the row to set
  4073. * @param row defines the target vector4
  4074. * @returns the updated current matrix
  4075. */
  4076. setRow(index: number, row: Vector4): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix
  4079. * @returns the new transposed matrix
  4080. */
  4081. transpose(): Matrix;
  4082. /**
  4083. * Compute the transpose of the matrix and store it in a given matrix
  4084. * @param result defines the target matrix
  4085. * @returns the current matrix
  4086. */
  4087. transposeToRef(result: Matrix): Matrix;
  4088. /**
  4089. * Sets the index-th row of the current matrix with the given 4 x float values
  4090. * @param index defines the row index
  4091. * @param x defines the x component to set
  4092. * @param y defines the y component to set
  4093. * @param z defines the z component to set
  4094. * @param w defines the w component to set
  4095. * @returns the updated current matrix
  4096. */
  4097. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4098. /**
  4099. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4100. * @param scale defines the scale factor
  4101. * @returns a new matrix
  4102. */
  4103. scale(scale: number): Matrix;
  4104. /**
  4105. * Scale the current matrix values by a factor to a given result matrix
  4106. * @param scale defines the scale factor
  4107. * @param result defines the matrix to store the result
  4108. * @returns the current matrix
  4109. */
  4110. scaleToRef(scale: number, result: Matrix): Matrix;
  4111. /**
  4112. * Scale the current matrix values by a factor and add the result to a given matrix
  4113. * @param scale defines the scale factor
  4114. * @param result defines the Matrix to store the result
  4115. * @returns the current matrix
  4116. */
  4117. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4118. /**
  4119. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4120. * @param ref matrix to store the result
  4121. */
  4122. toNormalMatrix(ref: Matrix): void;
  4123. /**
  4124. * Gets only rotation part of the current matrix
  4125. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4126. */
  4127. getRotationMatrix(): Matrix;
  4128. /**
  4129. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4130. * @param result defines the target matrix to store data to
  4131. * @returns the current matrix
  4132. */
  4133. getRotationMatrixToRef(result: Matrix): Matrix;
  4134. /**
  4135. * Toggles model matrix from being right handed to left handed in place and vice versa
  4136. */
  4137. toggleModelMatrixHandInPlace(): void;
  4138. /**
  4139. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4140. */
  4141. toggleProjectionMatrixHandInPlace(): void;
  4142. /**
  4143. * Creates a matrix from an array
  4144. * @param array defines the source array
  4145. * @param offset defines an offset in the source array
  4146. * @returns a new Matrix set from the starting index of the given array
  4147. */
  4148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4149. /**
  4150. * Copy the content of an array into a given matrix
  4151. * @param array defines the source array
  4152. * @param offset defines an offset in the source array
  4153. * @param result defines the target matrix
  4154. */
  4155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4156. /**
  4157. * Stores an array into a matrix after having multiplied each component by a given factor
  4158. * @param array defines the source array
  4159. * @param offset defines the offset in the source array
  4160. * @param scale defines the scaling factor
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4164. /**
  4165. * Gets an identity matrix that must not be updated
  4166. */
  4167. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4168. /**
  4169. * Stores a list of values (16) inside a given matrix
  4170. * @param initialM11 defines 1st value of 1st row
  4171. * @param initialM12 defines 2nd value of 1st row
  4172. * @param initialM13 defines 3rd value of 1st row
  4173. * @param initialM14 defines 4th value of 1st row
  4174. * @param initialM21 defines 1st value of 2nd row
  4175. * @param initialM22 defines 2nd value of 2nd row
  4176. * @param initialM23 defines 3rd value of 2nd row
  4177. * @param initialM24 defines 4th value of 2nd row
  4178. * @param initialM31 defines 1st value of 3rd row
  4179. * @param initialM32 defines 2nd value of 3rd row
  4180. * @param initialM33 defines 3rd value of 3rd row
  4181. * @param initialM34 defines 4th value of 3rd row
  4182. * @param initialM41 defines 1st value of 4th row
  4183. * @param initialM42 defines 2nd value of 4th row
  4184. * @param initialM43 defines 3rd value of 4th row
  4185. * @param initialM44 defines 4th value of 4th row
  4186. * @param result defines the target matrix
  4187. */
  4188. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4189. /**
  4190. * Creates new matrix from a list of values (16)
  4191. * @param initialM11 defines 1st value of 1st row
  4192. * @param initialM12 defines 2nd value of 1st row
  4193. * @param initialM13 defines 3rd value of 1st row
  4194. * @param initialM14 defines 4th value of 1st row
  4195. * @param initialM21 defines 1st value of 2nd row
  4196. * @param initialM22 defines 2nd value of 2nd row
  4197. * @param initialM23 defines 3rd value of 2nd row
  4198. * @param initialM24 defines 4th value of 2nd row
  4199. * @param initialM31 defines 1st value of 3rd row
  4200. * @param initialM32 defines 2nd value of 3rd row
  4201. * @param initialM33 defines 3rd value of 3rd row
  4202. * @param initialM34 defines 4th value of 3rd row
  4203. * @param initialM41 defines 1st value of 4th row
  4204. * @param initialM42 defines 2nd value of 4th row
  4205. * @param initialM43 defines 3rd value of 4th row
  4206. * @param initialM44 defines 4th value of 4th row
  4207. * @returns the new matrix
  4208. */
  4209. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4210. /**
  4211. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4212. * @param scale defines the scale vector3
  4213. * @param rotation defines the rotation quaternion
  4214. * @param translation defines the translation vector3
  4215. * @returns a new matrix
  4216. */
  4217. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4218. /**
  4219. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @param result defines the target matrix
  4224. */
  4225. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4226. /**
  4227. * Creates a new identity matrix
  4228. * @returns a new identity matrix
  4229. */
  4230. static Identity(): Matrix;
  4231. /**
  4232. * Creates a new identity matrix and stores the result in a given matrix
  4233. * @param result defines the target matrix
  4234. */
  4235. static IdentityToRef(result: Matrix): void;
  4236. /**
  4237. * Creates a new zero matrix
  4238. * @returns a new zero matrix
  4239. */
  4240. static Zero(): Matrix;
  4241. /**
  4242. * Creates a new rotation matrix for "angle" radians around the X axis
  4243. * @param angle defines the angle (in radians) to use
  4244. * @return the new matrix
  4245. */
  4246. static RotationX(angle: number): Matrix;
  4247. /**
  4248. * Creates a new matrix as the invert of a given matrix
  4249. * @param source defines the source matrix
  4250. * @returns the new matrix
  4251. */
  4252. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4255. * @param angle defines the angle (in radians) to use
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationXToRef(angle: number, result: Matrix): void;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the Y axis
  4261. * @param angle defines the angle (in radians) to use
  4262. * @return the new matrix
  4263. */
  4264. static RotationY(angle: number): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYToRef(angle: number, result: Matrix): void;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Z axis
  4273. * @param angle defines the angle (in radians) to use
  4274. * @return the new matrix
  4275. */
  4276. static RotationZ(angle: number): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationZToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the given axis
  4285. * @param axis defines the axis to use
  4286. * @param angle defines the angle (in radians) to use
  4287. * @return the new matrix
  4288. */
  4289. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4290. /**
  4291. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4292. * @param axis defines the axis to use
  4293. * @param angle defines the angle (in radians) to use
  4294. * @param result defines the target matrix
  4295. */
  4296. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4297. /**
  4298. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4299. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4300. * @param from defines the vector to align
  4301. * @param to defines the vector to align to
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4305. /**
  4306. * Creates a rotation matrix
  4307. * @param yaw defines the yaw angle in radians (Y axis)
  4308. * @param pitch defines the pitch angle in radians (X axis)
  4309. * @param roll defines the roll angle in radians (X axis)
  4310. * @returns the new rotation matrix
  4311. */
  4312. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4313. /**
  4314. * Creates a rotation matrix and stores it in a given matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4321. /**
  4322. * Creates a scaling matrix
  4323. * @param x defines the scale factor on X axis
  4324. * @param y defines the scale factor on Y axis
  4325. * @param z defines the scale factor on Z axis
  4326. * @returns the new matrix
  4327. */
  4328. static Scaling(x: number, y: number, z: number): Matrix;
  4329. /**
  4330. * Creates a scaling matrix and stores it in a given matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @param result defines the target matrix
  4335. */
  4336. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4337. /**
  4338. * Creates a translation matrix
  4339. * @param x defines the translation on X axis
  4340. * @param y defines the translation on Y axis
  4341. * @param z defines the translationon Z axis
  4342. * @returns the new matrix
  4343. */
  4344. static Translation(x: number, y: number, z: number): Matrix;
  4345. /**
  4346. * Creates a translation matrix and stores it in a given matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @param result defines the target matrix
  4351. */
  4352. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4353. /**
  4354. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4355. * @param startValue defines the start value
  4356. * @param endValue defines the end value
  4357. * @param gradient defines the gradient factor
  4358. * @returns the new matrix
  4359. */
  4360. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4361. /**
  4362. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @param result defines the Matrix object where to store data
  4367. */
  4368. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * Builds a new matrix whose values are computed by:
  4371. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4372. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4373. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4374. * @param startValue defines the first matrix
  4375. * @param endValue defines the second matrix
  4376. * @param gradient defines the gradient between the two matrices
  4377. * @returns the new matrix
  4378. */
  4379. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4380. /**
  4381. * Update a matrix to values which are computed by:
  4382. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4383. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4384. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4385. * @param startValue defines the first matrix
  4386. * @param endValue defines the second matrix
  4387. * @param gradient defines the gradient between the two matrices
  4388. * @param result defines the target matrix
  4389. */
  4390. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4391. /**
  4392. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @returns the new matrix
  4398. */
  4399. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4400. /**
  4401. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4402. * This function works in left handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @param result defines the target matrix
  4407. */
  4408. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4409. /**
  4410. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @returns the new matrix
  4416. */
  4417. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4418. /**
  4419. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4420. * This function works in right handed mode
  4421. * @param eye defines the final position of the entity
  4422. * @param target defines where the entity should look at
  4423. * @param up defines the up vector for the entity
  4424. * @param result defines the target matrix
  4425. */
  4426. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4427. /**
  4428. * Create a left-handed orthographic projection matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Store a left-handed orthographic projection to a given matrix
  4438. * @param width defines the viewport width
  4439. * @param height defines the viewport height
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Create a left-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a left-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a left-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a right-handed orthographic projection matrix
  4469. * @param left defines the viewport left coordinate
  4470. * @param right defines the viewport right coordinate
  4471. * @param bottom defines the viewport bottom coordinate
  4472. * @param top defines the viewport top coordinate
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a right-handed orthographic projection matrix
  4476. */
  4477. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Stores a right-handed orthographic projection into a given matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. */
  4488. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param width defines the viewport width
  4492. * @param height defines the viewport height
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Creates a left-handed perspective projection matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @returns a new matrix as a left-handed perspective projection matrix
  4505. */
  4506. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4507. /**
  4508. * Stores a left-handed perspective projection into a given matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @param result defines the target matrix
  4514. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4515. */
  4516. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar not used as infinity is used as far clip
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Creates a right-handed perspective projection matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @returns a new matrix as a right-handed perspective projection matrix
  4534. */
  4535. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4536. /**
  4537. * Stores a right-handed perspective projection into a given matrix
  4538. * @param fov defines the horizontal field of view
  4539. * @param aspect defines the aspect ratio
  4540. * @param znear defines the near clip plane
  4541. * @param zfar defines the far clip plane
  4542. * @param result defines the target matrix
  4543. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4544. */
  4545. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar not used as infinity is used as far clip
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a perspective projection for WebVR info a given matrix
  4558. * @param fov defines the field of view
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @param result defines the target matrix
  4562. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4563. */
  4564. static PerspectiveFovWebVRToRef(fov: {
  4565. upDegrees: number;
  4566. downDegrees: number;
  4567. leftDegrees: number;
  4568. rightDegrees: number;
  4569. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4570. /**
  4571. * Computes a complete transformation matrix
  4572. * @param viewport defines the viewport to use
  4573. * @param world defines the world matrix
  4574. * @param view defines the view matrix
  4575. * @param projection defines the projection matrix
  4576. * @param zmin defines the near clip plane
  4577. * @param zmax defines the far clip plane
  4578. * @returns the transformation matrix
  4579. */
  4580. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4581. /**
  4582. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4583. * @param matrix defines the matrix to use
  4584. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4585. */
  4586. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4587. /**
  4588. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Compute the transpose of a given matrix
  4595. * @param matrix defines the matrix to transpose
  4596. * @returns the new matrix
  4597. */
  4598. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4599. /**
  4600. * Compute the transpose of a matrix and store it in a target matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @param result defines the target matrix
  4603. */
  4604. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4605. /**
  4606. * Computes a reflection matrix from a plane
  4607. * @param plane defines the reflection plane
  4608. * @returns a new matrix
  4609. */
  4610. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @param result defines the target matrix
  4615. */
  4616. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4617. /**
  4618. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4619. * @param xaxis defines the value of the 1st axis
  4620. * @param yaxis defines the value of the 2nd axis
  4621. * @param zaxis defines the value of the 3rd axis
  4622. * @param result defines the target matrix
  4623. */
  4624. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4627. * @param quat defines the quaternion to use
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4631. }
  4632. /**
  4633. * @hidden
  4634. */
  4635. export class TmpVectors {
  4636. static Vector2: Vector2[];
  4637. static Vector3: Vector3[];
  4638. static Vector4: Vector4[];
  4639. static Quaternion: Quaternion[];
  4640. static Matrix: Matrix[];
  4641. }
  4642. }
  4643. declare module BABYLON {
  4644. /**
  4645. * Defines potential orientation for back face culling
  4646. */
  4647. export enum Orientation {
  4648. /**
  4649. * Clockwise
  4650. */
  4651. CW = 0,
  4652. /** Counter clockwise */
  4653. CCW = 1
  4654. }
  4655. /** Class used to represent a Bezier curve */
  4656. export class BezierCurve {
  4657. /**
  4658. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4659. * @param t defines the time
  4660. * @param x1 defines the left coordinate on X axis
  4661. * @param y1 defines the left coordinate on Y axis
  4662. * @param x2 defines the right coordinate on X axis
  4663. * @param y2 defines the right coordinate on Y axis
  4664. * @returns the interpolated value
  4665. */
  4666. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4667. }
  4668. /**
  4669. * Defines angle representation
  4670. */
  4671. export class Angle {
  4672. private _radians;
  4673. /**
  4674. * Creates an Angle object of "radians" radians (float).
  4675. * @param radians the angle in radians
  4676. */
  4677. constructor(radians: number);
  4678. /**
  4679. * Get value in degrees
  4680. * @returns the Angle value in degrees (float)
  4681. */
  4682. degrees(): number;
  4683. /**
  4684. * Get value in radians
  4685. * @returns the Angle value in radians (float)
  4686. */
  4687. radians(): number;
  4688. /**
  4689. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4690. * @param a defines first vector
  4691. * @param b defines second vector
  4692. * @returns a new Angle
  4693. */
  4694. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4695. /**
  4696. * Gets a new Angle object from the given float in radians
  4697. * @param radians defines the angle value in radians
  4698. * @returns a new Angle
  4699. */
  4700. static FromRadians(radians: number): Angle;
  4701. /**
  4702. * Gets a new Angle object from the given float in degrees
  4703. * @param degrees defines the angle value in degrees
  4704. * @returns a new Angle
  4705. */
  4706. static FromDegrees(degrees: number): Angle;
  4707. }
  4708. /**
  4709. * This represents an arc in a 2d space.
  4710. */
  4711. export class Arc2 {
  4712. /** Defines the start point of the arc */
  4713. startPoint: Vector2;
  4714. /** Defines the mid point of the arc */
  4715. midPoint: Vector2;
  4716. /** Defines the end point of the arc */
  4717. endPoint: Vector2;
  4718. /**
  4719. * Defines the center point of the arc.
  4720. */
  4721. centerPoint: Vector2;
  4722. /**
  4723. * Defines the radius of the arc.
  4724. */
  4725. radius: number;
  4726. /**
  4727. * Defines the angle of the arc (from mid point to end point).
  4728. */
  4729. angle: Angle;
  4730. /**
  4731. * Defines the start angle of the arc (from start point to middle point).
  4732. */
  4733. startAngle: Angle;
  4734. /**
  4735. * Defines the orientation of the arc (clock wise/counter clock wise).
  4736. */
  4737. orientation: Orientation;
  4738. /**
  4739. * Creates an Arc object from the three given points : start, middle and end.
  4740. * @param startPoint Defines the start point of the arc
  4741. * @param midPoint Defines the midlle point of the arc
  4742. * @param endPoint Defines the end point of the arc
  4743. */
  4744. constructor(
  4745. /** Defines the start point of the arc */
  4746. startPoint: Vector2,
  4747. /** Defines the mid point of the arc */
  4748. midPoint: Vector2,
  4749. /** Defines the end point of the arc */
  4750. endPoint: Vector2);
  4751. }
  4752. /**
  4753. * Represents a 2D path made up of multiple 2D points
  4754. */
  4755. export class Path2 {
  4756. private _points;
  4757. private _length;
  4758. /**
  4759. * If the path start and end point are the same
  4760. */
  4761. closed: boolean;
  4762. /**
  4763. * Creates a Path2 object from the starting 2D coordinates x and y.
  4764. * @param x the starting points x value
  4765. * @param y the starting points y value
  4766. */
  4767. constructor(x: number, y: number);
  4768. /**
  4769. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4770. * @param x the added points x value
  4771. * @param y the added points y value
  4772. * @returns the updated Path2.
  4773. */
  4774. addLineTo(x: number, y: number): Path2;
  4775. /**
  4776. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4777. * @param midX middle point x value
  4778. * @param midY middle point y value
  4779. * @param endX end point x value
  4780. * @param endY end point y value
  4781. * @param numberOfSegments (default: 36)
  4782. * @returns the updated Path2.
  4783. */
  4784. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4785. /**
  4786. * Closes the Path2.
  4787. * @returns the Path2.
  4788. */
  4789. close(): Path2;
  4790. /**
  4791. * Gets the sum of the distance between each sequential point in the path
  4792. * @returns the Path2 total length (float).
  4793. */
  4794. length(): number;
  4795. /**
  4796. * Gets the points which construct the path
  4797. * @returns the Path2 internal array of points.
  4798. */
  4799. getPoints(): Vector2[];
  4800. /**
  4801. * Retreives the point at the distance aways from the starting point
  4802. * @param normalizedLengthPosition the length along the path to retreive the point from
  4803. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4804. */
  4805. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4806. /**
  4807. * Creates a new path starting from an x and y position
  4808. * @param x starting x value
  4809. * @param y starting y value
  4810. * @returns a new Path2 starting at the coordinates (x, y).
  4811. */
  4812. static StartingAt(x: number, y: number): Path2;
  4813. }
  4814. /**
  4815. * Represents a 3D path made up of multiple 3D points
  4816. */
  4817. export class Path3D {
  4818. /**
  4819. * an array of Vector3, the curve axis of the Path3D
  4820. */
  4821. path: Vector3[];
  4822. private _curve;
  4823. private _distances;
  4824. private _tangents;
  4825. private _normals;
  4826. private _binormals;
  4827. private _raw;
  4828. private _alignTangentsWithPath;
  4829. private readonly _pointAtData;
  4830. /**
  4831. * new Path3D(path, normal, raw)
  4832. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4833. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4834. * @param path an array of Vector3, the curve axis of the Path3D
  4835. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4836. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4837. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4838. */
  4839. constructor(
  4840. /**
  4841. * an array of Vector3, the curve axis of the Path3D
  4842. */
  4843. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getCurve(): Vector3[];
  4849. /**
  4850. * Returns the Path3D array of successive Vector3 designing its curve.
  4851. * @returns the Path3D array of successive Vector3 designing its curve.
  4852. */
  4853. getPoints(): Vector3[];
  4854. /**
  4855. * @returns the computed length (float) of the path.
  4856. */
  4857. length(): number;
  4858. /**
  4859. * Returns an array populated with tangent vectors on each Path3D curve point.
  4860. * @returns an array populated with tangent vectors on each Path3D curve point.
  4861. */
  4862. getTangents(): Vector3[];
  4863. /**
  4864. * Returns an array populated with normal vectors on each Path3D curve point.
  4865. * @returns an array populated with normal vectors on each Path3D curve point.
  4866. */
  4867. getNormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with binormal vectors on each Path3D curve point.
  4870. * @returns an array populated with binormal vectors on each Path3D curve point.
  4871. */
  4872. getBinormals(): Vector3[];
  4873. /**
  4874. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4875. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4876. */
  4877. getDistances(): number[];
  4878. /**
  4879. * Returns an interpolated point along this path
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns a new Vector3 as the point
  4882. */
  4883. getPointAt(position: number): Vector3;
  4884. /**
  4885. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4886. * @param position the position of the point along this path, from 0.0 to 1.0
  4887. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4888. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4889. */
  4890. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4891. /**
  4892. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4893. * @param position the position of the point along this path, from 0.0 to 1.0
  4894. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4895. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4896. */
  4897. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4898. /**
  4899. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4900. * @param position the position of the point along this path, from 0.0 to 1.0
  4901. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4902. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4903. */
  4904. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4905. /**
  4906. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4907. * @param position the position of the point along this path, from 0.0 to 1.0
  4908. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4909. */
  4910. getDistanceAt(position: number): number;
  4911. /**
  4912. * Returns the array index of the previous point of an interpolated point along this path
  4913. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4914. * @returns the array index
  4915. */
  4916. getPreviousPointIndexAt(position: number): number;
  4917. /**
  4918. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4919. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4920. * @returns the sub position
  4921. */
  4922. getSubPositionAt(position: number): number;
  4923. /**
  4924. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4925. * @param target the vector of which to get the closest position to
  4926. * @returns the position of the closest virtual point on this path to the target vector
  4927. */
  4928. getClosestPositionTo(target: Vector3): number;
  4929. /**
  4930. * Returns a sub path (slice) of this path
  4931. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4932. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4933. * @returns a sub path (slice) of this path
  4934. */
  4935. slice(start?: number, end?: number): Path3D;
  4936. /**
  4937. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4938. * @param path path which all values are copied into the curves points
  4939. * @param firstNormal which should be projected onto the curve
  4940. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4941. * @returns the same object updated.
  4942. */
  4943. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4944. private _compute;
  4945. private _getFirstNonNullVector;
  4946. private _getLastNonNullVector;
  4947. private _normalVector;
  4948. /**
  4949. * Updates the point at data for an interpolated point along this curve
  4950. * @param position the position of the point along this curve, from 0.0 to 1.0
  4951. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4952. * @returns the (updated) point at data
  4953. */
  4954. private _updatePointAtData;
  4955. /**
  4956. * Updates the point at data from the specified parameters
  4957. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4958. * @param point the interpolated point
  4959. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4960. */
  4961. private _setPointAtData;
  4962. /**
  4963. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4964. */
  4965. private _updateInterpolationMatrix;
  4966. }
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4971. */
  4972. export class Curve3 {
  4973. private _points;
  4974. private _length;
  4975. /**
  4976. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4978. * @param v1 (Vector3) the control point
  4979. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4986. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4987. * @param v1 (Vector3) the first control point
  4988. * @param v2 (Vector3) the second control point
  4989. * @param v3 (Vector3) the end point of the Cubic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4996. * @param p1 (Vector3) the origin point of the Hermite Spline
  4997. * @param t1 (Vector3) the tangent vector at the origin point
  4998. * @param p2 (Vector3) the end point of the Hermite Spline
  4999. * @param t2 (Vector3) the tangent vector at the end point
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a CatmullRom Spline curve :
  5006. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5007. * @param nbPoints (integer) the wanted number of points between each curve control points
  5008. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5012. /**
  5013. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5014. * A Curve3 is designed from a series of successive Vector3.
  5015. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5016. * @param points points which make up the curve
  5017. */
  5018. constructor(points: Vector3[]);
  5019. /**
  5020. * @returns the Curve3 stored array of successive Vector3
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the curve.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5029. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5030. * curveA and curveB keep unchanged.
  5031. * @param curve the curve to continue from this curve
  5032. * @returns the newly constructed curve
  5033. */
  5034. continue(curve: DeepImmutable<Curve3>): Curve3;
  5035. private _computeLength;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * This represents the main contract an easing function should follow.
  5041. * Easing functions are used throughout the animation system.
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export interface IEasingFunction {
  5045. /**
  5046. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5047. * of the easing function.
  5048. * The link below provides some of the most common examples of easing functions.
  5049. * @see https://easings.net/
  5050. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5051. * @returns the corresponding value on the curve defined by the easing function
  5052. */
  5053. ease(gradient: number): number;
  5054. }
  5055. /**
  5056. * Base class used for every default easing function.
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class EasingFunction implements IEasingFunction {
  5060. /**
  5061. * Interpolation follows the mathematical formula associated with the easing function.
  5062. */
  5063. static readonly EASINGMODE_EASEIN: number;
  5064. /**
  5065. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5066. */
  5067. static readonly EASINGMODE_EASEOUT: number;
  5068. /**
  5069. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5070. */
  5071. static readonly EASINGMODE_EASEINOUT: number;
  5072. private _easingMode;
  5073. /**
  5074. * Sets the easing mode of the current function.
  5075. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5076. */
  5077. setEasingMode(easingMode: number): void;
  5078. /**
  5079. * Gets the current easing mode.
  5080. * @returns the easing mode
  5081. */
  5082. getEasingMode(): number;
  5083. /**
  5084. * @hidden
  5085. */
  5086. easeInCore(gradient: number): number;
  5087. /**
  5088. * Given an input gradient between 0 and 1, this returns the corresponding value
  5089. * of the easing function.
  5090. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5091. * @returns the corresponding value on the curve defined by the easing function
  5092. */
  5093. ease(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a circle shape (see link below).
  5097. * @see https://easings.net/#easeInCirc
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CircleEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with a ease back shape (see link below).
  5106. * @see https://easings.net/#easeInBack
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class BackEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the amplitude of the function */
  5111. amplitude: number;
  5112. /**
  5113. * Instantiates a back ease easing
  5114. * @see https://easings.net/#easeInBack
  5115. * @param amplitude Defines the amplitude of the function
  5116. */
  5117. constructor(
  5118. /** Defines the amplitude of the function */
  5119. amplitude?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with a bouncing shape (see link below).
  5125. * @see https://easings.net/#easeInBounce
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class BounceEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the number of bounces */
  5130. bounces: number;
  5131. /** Defines the amplitude of the bounce */
  5132. bounciness: number;
  5133. /**
  5134. * Instantiates a bounce easing
  5135. * @see https://easings.net/#easeInBounce
  5136. * @param bounces Defines the number of bounces
  5137. * @param bounciness Defines the amplitude of the bounce
  5138. */
  5139. constructor(
  5140. /** Defines the number of bounces */
  5141. bounces?: number,
  5142. /** Defines the amplitude of the bounce */
  5143. bounciness?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power of 3 shape (see link below).
  5149. * @see https://easings.net/#easeInCubic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class CubicEase extends EasingFunction implements IEasingFunction {
  5153. /** @hidden */
  5154. easeInCore(gradient: number): number;
  5155. }
  5156. /**
  5157. * Easing function with an elastic shape (see link below).
  5158. * @see https://easings.net/#easeInElastic
  5159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5160. */
  5161. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5162. /** Defines the number of oscillations*/
  5163. oscillations: number;
  5164. /** Defines the amplitude of the oscillations*/
  5165. springiness: number;
  5166. /**
  5167. * Instantiates an elastic easing function
  5168. * @see https://easings.net/#easeInElastic
  5169. * @param oscillations Defines the number of oscillations
  5170. * @param springiness Defines the amplitude of the oscillations
  5171. */
  5172. constructor(
  5173. /** Defines the number of oscillations*/
  5174. oscillations?: number,
  5175. /** Defines the amplitude of the oscillations*/
  5176. springiness?: number);
  5177. /** @hidden */
  5178. easeInCore(gradient: number): number;
  5179. }
  5180. /**
  5181. * Easing function with an exponential shape (see link below).
  5182. * @see https://easings.net/#easeInExpo
  5183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5184. */
  5185. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5186. /** Defines the exponent of the function */
  5187. exponent: number;
  5188. /**
  5189. * Instantiates an exponential easing function
  5190. * @see https://easings.net/#easeInExpo
  5191. * @param exponent Defines the exponent of the function
  5192. */
  5193. constructor(
  5194. /** Defines the exponent of the function */
  5195. exponent?: number);
  5196. /** @hidden */
  5197. easeInCore(gradient: number): number;
  5198. }
  5199. /**
  5200. * Easing function with a power shape (see link below).
  5201. * @see https://easings.net/#easeInQuad
  5202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5203. */
  5204. export class PowerEase extends EasingFunction implements IEasingFunction {
  5205. /** Defines the power of the function */
  5206. power: number;
  5207. /**
  5208. * Instantiates an power base easing function
  5209. * @see https://easings.net/#easeInQuad
  5210. * @param power Defines the power of the function
  5211. */
  5212. constructor(
  5213. /** Defines the power of the function */
  5214. power?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 2 shape (see link below).
  5220. * @see https://easings.net/#easeInQuad
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 4 shape (see link below).
  5229. * @see https://easings.net/#easeInQuart
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a power of 5 shape (see link below).
  5238. * @see https://easings.net/#easeInQuint
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a sin shape (see link below).
  5247. * @see https://easings.net/#easeInSine
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class SineEase extends EasingFunction implements IEasingFunction {
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bezier shape (see link below).
  5256. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the x component of the start tangent in the bezier curve */
  5261. x1: number;
  5262. /** Defines the y component of the start tangent in the bezier curve */
  5263. y1: number;
  5264. /** Defines the x component of the end tangent in the bezier curve */
  5265. x2: number;
  5266. /** Defines the y component of the end tangent in the bezier curve */
  5267. y2: number;
  5268. /**
  5269. * Instantiates a bezier function
  5270. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5271. * @param x1 Defines the x component of the start tangent in the bezier curve
  5272. * @param y1 Defines the y component of the start tangent in the bezier curve
  5273. * @param x2 Defines the x component of the end tangent in the bezier curve
  5274. * @param y2 Defines the y component of the end tangent in the bezier curve
  5275. */
  5276. constructor(
  5277. /** Defines the x component of the start tangent in the bezier curve */
  5278. x1?: number,
  5279. /** Defines the y component of the start tangent in the bezier curve */
  5280. y1?: number,
  5281. /** Defines the x component of the end tangent in the bezier curve */
  5282. x2?: number,
  5283. /** Defines the y component of the end tangent in the bezier curve */
  5284. y2?: number);
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * Class used to hold a RBG color
  5292. */
  5293. export class Color3 {
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r: number;
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g: number;
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b: number;
  5306. /**
  5307. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5308. * @param r defines the red component (between 0 and 1, default is 0)
  5309. * @param g defines the green component (between 0 and 1, default is 0)
  5310. * @param b defines the blue component (between 0 and 1, default is 0)
  5311. */
  5312. constructor(
  5313. /**
  5314. * Defines the red component (between 0 and 1, default is 0)
  5315. */
  5316. r?: number,
  5317. /**
  5318. * Defines the green component (between 0 and 1, default is 0)
  5319. */
  5320. g?: number,
  5321. /**
  5322. * Defines the blue component (between 0 and 1, default is 0)
  5323. */
  5324. b?: number);
  5325. /**
  5326. * Creates a string with the Color3 current values
  5327. * @returns the string representation of the Color3 object
  5328. */
  5329. toString(): string;
  5330. /**
  5331. * Returns the string "Color3"
  5332. * @returns "Color3"
  5333. */
  5334. getClassName(): string;
  5335. /**
  5336. * Compute the Color3 hash code
  5337. * @returns an unique number that can be used to hash Color3 objects
  5338. */
  5339. getHashCode(): number;
  5340. /**
  5341. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5342. * @param array defines the array where to store the r,g,b components
  5343. * @param index defines an optional index in the target array to define where to start storing values
  5344. * @returns the current Color3 object
  5345. */
  5346. toArray(array: FloatArray, index?: number): Color3;
  5347. /**
  5348. * Returns a new Color4 object from the current Color3 and the given alpha
  5349. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5350. * @returns a new Color4 object
  5351. */
  5352. toColor4(alpha?: number): Color4;
  5353. /**
  5354. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5355. * @returns the new array
  5356. */
  5357. asArray(): number[];
  5358. /**
  5359. * Returns the luminance value
  5360. * @returns a float value
  5361. */
  5362. toLuminance(): number;
  5363. /**
  5364. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5365. * @param otherColor defines the second operand
  5366. * @returns the new Color3 object
  5367. */
  5368. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5369. /**
  5370. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5371. * @param otherColor defines the second operand
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the current Color3
  5374. */
  5375. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5376. /**
  5377. * Determines equality between Color3 objects
  5378. * @param otherColor defines the second operand
  5379. * @returns true if the rgb values are equal to the given ones
  5380. */
  5381. equals(otherColor: DeepImmutable<Color3>): boolean;
  5382. /**
  5383. * Determines equality between the current Color3 object and a set of r,b,g values
  5384. * @param r defines the red component to check
  5385. * @param g defines the green component to check
  5386. * @param b defines the blue component to check
  5387. * @returns true if the rgb values are equal to the given ones
  5388. */
  5389. equalsFloats(r: number, g: number, b: number): boolean;
  5390. /**
  5391. * Multiplies in place each rgb value by scale
  5392. * @param scale defines the scaling factor
  5393. * @returns the updated Color3
  5394. */
  5395. scale(scale: number): Color3;
  5396. /**
  5397. * Multiplies the rgb values by scale and stores the result into "result"
  5398. * @param scale defines the scaling factor
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the unmodified current Color3
  5401. */
  5402. scaleToRef(scale: number, result: Color3): Color3;
  5403. /**
  5404. * Scale the current Color3 values by a factor and add the result to a given Color3
  5405. * @param scale defines the scale factor
  5406. * @param result defines color to store the result into
  5407. * @returns the unmodified current Color3
  5408. */
  5409. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5410. /**
  5411. * Clamps the rgb values by the min and max values and stores the result into "result"
  5412. * @param min defines minimum clamping value (default is 0)
  5413. * @param max defines maximum clamping value (default is 1)
  5414. * @param result defines color to store the result into
  5415. * @returns the original Color3
  5416. */
  5417. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5418. /**
  5419. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5420. * @param otherColor defines the second operand
  5421. * @returns the new Color3
  5422. */
  5423. add(otherColor: DeepImmutable<Color3>): Color3;
  5424. /**
  5425. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5426. * @param otherColor defines the second operand
  5427. * @param result defines Color3 object to store the result into
  5428. * @returns the unmodified current Color3
  5429. */
  5430. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5431. /**
  5432. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Copy the current object
  5446. * @returns a new Color3 copied the current one
  5447. */
  5448. clone(): Color3;
  5449. /**
  5450. * Copies the rgb values from the source in the current Color3
  5451. * @param source defines the source Color3 object
  5452. * @returns the updated Color3 object
  5453. */
  5454. copyFrom(source: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Updates the Color3 rgb values from the given floats
  5457. * @param r defines the red component to read from
  5458. * @param g defines the green component to read from
  5459. * @param b defines the blue component to read from
  5460. * @returns the current Color3 object
  5461. */
  5462. copyFromFloats(r: number, g: number, b: number): Color3;
  5463. /**
  5464. * Updates the Color3 rgb values from the given floats
  5465. * @param r defines the red component to read from
  5466. * @param g defines the green component to read from
  5467. * @param b defines the blue component to read from
  5468. * @returns the current Color3 object
  5469. */
  5470. set(r: number, g: number, b: number): Color3;
  5471. /**
  5472. * Compute the Color3 hexadecimal code as a string
  5473. * @returns a string containing the hexadecimal representation of the Color3 object
  5474. */
  5475. toHexString(): string;
  5476. /**
  5477. * Computes a new Color3 converted from the current one to linear space
  5478. * @returns a new Color3 object
  5479. */
  5480. toLinearSpace(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @returns a new color3 representing the HSV values
  5484. */
  5485. toHSV(): Color3;
  5486. /**
  5487. * Converts current color in rgb space to HSV values
  5488. * @param result defines the Color3 where to store the HSV values
  5489. */
  5490. toHSVToRef(result: Color3): void;
  5491. /**
  5492. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5493. * @param convertedColor defines the Color3 object where to store the linear space version
  5494. * @returns the unmodified Color3
  5495. */
  5496. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5497. /**
  5498. * Computes a new Color3 converted from the current one to gamma space
  5499. * @returns a new Color3 object
  5500. */
  5501. toGammaSpace(): Color3;
  5502. /**
  5503. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the gamma space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5508. private static _BlackReadOnly;
  5509. /**
  5510. * Convert Hue, saturation and value to a Color3 (RGB)
  5511. * @param hue defines the hue
  5512. * @param saturation defines the saturation
  5513. * @param value defines the value
  5514. * @param result defines the Color3 where to store the RGB values
  5515. */
  5516. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5517. /**
  5518. * Creates a new Color3 from the string containing valid hexadecimal values
  5519. * @param hex defines a string containing valid hexadecimal values
  5520. * @returns a new Color3 object
  5521. */
  5522. static FromHexString(hex: string): Color3;
  5523. /**
  5524. * Creates a new Color3 from the starting index of the given array
  5525. * @param array defines the source array
  5526. * @param offset defines an offset in the source array
  5527. * @returns a new Color3 object
  5528. */
  5529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5530. /**
  5531. * Creates a new Color3 from integer values (< 256)
  5532. * @param r defines the red component to read from (value between 0 and 255)
  5533. * @param g defines the green component to read from (value between 0 and 255)
  5534. * @param b defines the blue component to read from (value between 0 and 255)
  5535. * @returns a new Color3 object
  5536. */
  5537. static FromInts(r: number, g: number, b: number): Color3;
  5538. /**
  5539. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5540. * @param start defines the start Color3 value
  5541. * @param end defines the end Color3 value
  5542. * @param amount defines the gradient value between start and end
  5543. * @returns a new Color3 object
  5544. */
  5545. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5546. /**
  5547. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5548. * @param left defines the start value
  5549. * @param right defines the end value
  5550. * @param amount defines the gradient factor
  5551. * @param result defines the Color3 object where to store the result
  5552. */
  5553. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5554. /**
  5555. * Returns a Color3 value containing a red color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Red(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a green color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Green(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a blue color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Blue(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a black color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Black(): Color3;
  5574. /**
  5575. * Gets a Color3 value containing a black color that must not be updated
  5576. */
  5577. static get BlackReadOnly(): DeepImmutable<Color3>;
  5578. /**
  5579. * Returns a Color3 value containing a white color
  5580. * @returns a new Color3 object
  5581. */
  5582. static White(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a purple color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Purple(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a magenta color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Magenta(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a yellow color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Yellow(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a gray color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Gray(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a teal color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Teal(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a random color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Random(): Color3;
  5613. }
  5614. /**
  5615. * Class used to hold a RBGA color
  5616. */
  5617. export class Color4 {
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r: number;
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g: number;
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b: number;
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a: number;
  5634. /**
  5635. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5636. * @param r defines the red component (between 0 and 1, default is 0)
  5637. * @param g defines the green component (between 0 and 1, default is 0)
  5638. * @param b defines the blue component (between 0 and 1, default is 0)
  5639. * @param a defines the alpha component (between 0 and 1, default is 1)
  5640. */
  5641. constructor(
  5642. /**
  5643. * Defines the red component (between 0 and 1, default is 0)
  5644. */
  5645. r?: number,
  5646. /**
  5647. * Defines the green component (between 0 and 1, default is 0)
  5648. */
  5649. g?: number,
  5650. /**
  5651. * Defines the blue component (between 0 and 1, default is 0)
  5652. */
  5653. b?: number,
  5654. /**
  5655. * Defines the alpha component (between 0 and 1, default is 1)
  5656. */
  5657. a?: number);
  5658. /**
  5659. * Adds in place the given Color4 values to the current Color4 object
  5660. * @param right defines the second operand
  5661. * @returns the current updated Color4 object
  5662. */
  5663. addInPlace(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5666. * @returns the new array
  5667. */
  5668. asArray(): number[];
  5669. /**
  5670. * Stores from the starting index in the given array the Color4 successive values
  5671. * @param array defines the array where to store the r,g,b components
  5672. * @param index defines an optional index in the target array to define where to start storing values
  5673. * @returns the current Color4 object
  5674. */
  5675. toArray(array: number[], index?: number): Color4;
  5676. /**
  5677. * Determines equality between Color4 objects
  5678. * @param otherColor defines the second operand
  5679. * @returns true if the rgba values are equal to the given ones
  5680. */
  5681. equals(otherColor: DeepImmutable<Color4>): boolean;
  5682. /**
  5683. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5684. * @param right defines the second operand
  5685. * @returns a new Color4 object
  5686. */
  5687. add(right: DeepImmutable<Color4>): Color4;
  5688. /**
  5689. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5690. * @param right defines the second operand
  5691. * @returns a new Color4 object
  5692. */
  5693. subtract(right: DeepImmutable<Color4>): Color4;
  5694. /**
  5695. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5696. * @param right defines the second operand
  5697. * @param result defines the Color4 object where to store the result
  5698. * @returns the current Color4 object
  5699. */
  5700. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5701. /**
  5702. * Creates a new Color4 with the current Color4 values multiplied by scale
  5703. * @param scale defines the scaling factor to apply
  5704. * @returns a new Color4 object
  5705. */
  5706. scale(scale: number): Color4;
  5707. /**
  5708. * Multiplies the current Color4 values by scale and stores the result in "result"
  5709. * @param scale defines the scaling factor to apply
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current unmodified Color4
  5712. */
  5713. scaleToRef(scale: number, result: Color4): Color4;
  5714. /**
  5715. * Scale the current Color4 values by a factor and add the result to a given Color4
  5716. * @param scale defines the scale factor
  5717. * @param result defines the Color4 object where to store the result
  5718. * @returns the unmodified current Color4
  5719. */
  5720. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5721. /**
  5722. * Clamps the rgb values by the min and max values and stores the result into "result"
  5723. * @param min defines minimum clamping value (default is 0)
  5724. * @param max defines maximum clamping value (default is 1)
  5725. * @param result defines color to store the result into.
  5726. * @returns the cuurent Color4
  5727. */
  5728. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5729. /**
  5730. * Multipy an Color4 value by another and return a new Color4 object
  5731. * @param color defines the Color4 value to multiply by
  5732. * @returns a new Color4 object
  5733. */
  5734. multiply(color: Color4): Color4;
  5735. /**
  5736. * Multipy a Color4 value by another and push the result in a reference value
  5737. * @param color defines the Color4 value to multiply by
  5738. * @param result defines the Color4 to fill the result in
  5739. * @returns the result Color4
  5740. */
  5741. multiplyToRef(color: Color4, result: Color4): Color4;
  5742. /**
  5743. * Creates a string with the Color4 current values
  5744. * @returns the string representation of the Color4 object
  5745. */
  5746. toString(): string;
  5747. /**
  5748. * Returns the string "Color4"
  5749. * @returns "Color4"
  5750. */
  5751. getClassName(): string;
  5752. /**
  5753. * Compute the Color4 hash code
  5754. * @returns an unique number that can be used to hash Color4 objects
  5755. */
  5756. getHashCode(): number;
  5757. /**
  5758. * Creates a new Color4 copied from the current one
  5759. * @returns a new Color4 object
  5760. */
  5761. clone(): Color4;
  5762. /**
  5763. * Copies the given Color4 values into the current one
  5764. * @param source defines the source Color4 object
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFrom(source: Color4): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. set(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Compute the Color4 hexadecimal code as a string
  5788. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5789. * @returns a string containing the hexadecimal representation of the Color4 object
  5790. */
  5791. toHexString(returnAsColor3?: boolean): string;
  5792. /**
  5793. * Computes a new Color4 converted from the current one to linear space
  5794. * @returns a new Color4 object
  5795. */
  5796. toLinearSpace(): Color4;
  5797. /**
  5798. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5799. * @param convertedColor defines the Color4 object where to store the linear space version
  5800. * @returns the unmodified Color4
  5801. */
  5802. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5803. /**
  5804. * Computes a new Color4 converted from the current one to gamma space
  5805. * @returns a new Color4 object
  5806. */
  5807. toGammaSpace(): Color4;
  5808. /**
  5809. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5810. * @param convertedColor defines the Color4 object where to store the gamma space version
  5811. * @returns the unmodified Color4
  5812. */
  5813. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5814. /**
  5815. * Creates a new Color4 from the string containing valid hexadecimal values
  5816. * @param hex defines a string containing valid hexadecimal values
  5817. * @returns a new Color4 object
  5818. */
  5819. static FromHexString(hex: string): Color4;
  5820. /**
  5821. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5822. * @param left defines the start value
  5823. * @param right defines the end value
  5824. * @param amount defines the gradient factor
  5825. * @returns a new Color4 object
  5826. */
  5827. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5828. /**
  5829. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @param result defines the Color4 object where to store data
  5834. */
  5835. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5836. /**
  5837. * Creates a new Color4 from a Color3 and an alpha value
  5838. * @param color3 defines the source Color3 to read from
  5839. * @param alpha defines the alpha component (1.0 by default)
  5840. * @returns a new Color4 object
  5841. */
  5842. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5843. /**
  5844. * Creates a new Color4 from the starting index element of the given array
  5845. * @param array defines the source array to read from
  5846. * @param offset defines the offset in the source array
  5847. * @returns a new Color4 object
  5848. */
  5849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5850. /**
  5851. * Creates a new Color3 from integer values (< 256)
  5852. * @param r defines the red component to read from (value between 0 and 255)
  5853. * @param g defines the green component to read from (value between 0 and 255)
  5854. * @param b defines the blue component to read from (value between 0 and 255)
  5855. * @param a defines the alpha component to read from (value between 0 and 255)
  5856. * @returns a new Color3 object
  5857. */
  5858. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5859. /**
  5860. * Check the content of a given array and convert it to an array containing RGBA data
  5861. * If the original array was already containing count * 4 values then it is returned directly
  5862. * @param colors defines the array to check
  5863. * @param count defines the number of RGBA data to expect
  5864. * @returns an array containing count * 4 values (RGBA)
  5865. */
  5866. static CheckColors4(colors: number[], count: number): number[];
  5867. }
  5868. /**
  5869. * @hidden
  5870. */
  5871. export class TmpColors {
  5872. static Color3: Color3[];
  5873. static Color4: Color4[];
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Defines an interface which represents an animation key frame
  5879. */
  5880. export interface IAnimationKey {
  5881. /**
  5882. * Frame of the key frame
  5883. */
  5884. frame: number;
  5885. /**
  5886. * Value at the specifies key frame
  5887. */
  5888. value: any;
  5889. /**
  5890. * The input tangent for the cubic hermite spline
  5891. */
  5892. inTangent?: any;
  5893. /**
  5894. * The output tangent for the cubic hermite spline
  5895. */
  5896. outTangent?: any;
  5897. /**
  5898. * The animation interpolation type
  5899. */
  5900. interpolation?: AnimationKeyInterpolation;
  5901. }
  5902. /**
  5903. * Enum for the animation key frame interpolation type
  5904. */
  5905. export enum AnimationKeyInterpolation {
  5906. /**
  5907. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5908. */
  5909. STEP = 1
  5910. }
  5911. }
  5912. declare module BABYLON {
  5913. /**
  5914. * Represents the range of an animation
  5915. */
  5916. export class AnimationRange {
  5917. /**The name of the animation range**/
  5918. name: string;
  5919. /**The starting frame of the animation */
  5920. from: number;
  5921. /**The ending frame of the animation*/
  5922. to: number;
  5923. /**
  5924. * Initializes the range of an animation
  5925. * @param name The name of the animation range
  5926. * @param from The starting frame of the animation
  5927. * @param to The ending frame of the animation
  5928. */
  5929. constructor(
  5930. /**The name of the animation range**/
  5931. name: string,
  5932. /**The starting frame of the animation */
  5933. from: number,
  5934. /**The ending frame of the animation*/
  5935. to: number);
  5936. /**
  5937. * Makes a copy of the animation range
  5938. * @returns A copy of the animation range
  5939. */
  5940. clone(): AnimationRange;
  5941. }
  5942. }
  5943. declare module BABYLON {
  5944. /**
  5945. * Composed of a frame, and an action function
  5946. */
  5947. export class AnimationEvent {
  5948. /** The frame for which the event is triggered **/
  5949. frame: number;
  5950. /** The event to perform when triggered **/
  5951. action: (currentFrame: number) => void;
  5952. /** Specifies if the event should be triggered only once**/
  5953. onlyOnce?: boolean | undefined;
  5954. /**
  5955. * Specifies if the animation event is done
  5956. */
  5957. isDone: boolean;
  5958. /**
  5959. * Initializes the animation event
  5960. * @param frame The frame for which the event is triggered
  5961. * @param action The event to perform when triggered
  5962. * @param onlyOnce Specifies if the event should be triggered only once
  5963. */
  5964. constructor(
  5965. /** The frame for which the event is triggered **/
  5966. frame: number,
  5967. /** The event to perform when triggered **/
  5968. action: (currentFrame: number) => void,
  5969. /** Specifies if the event should be triggered only once**/
  5970. onlyOnce?: boolean | undefined);
  5971. /** @hidden */
  5972. _clone(): AnimationEvent;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Interface used to define a behavior
  5978. */
  5979. export interface Behavior<T> {
  5980. /** gets or sets behavior's name */
  5981. name: string;
  5982. /**
  5983. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5984. */
  5985. init(): void;
  5986. /**
  5987. * Called when the behavior is attached to a target
  5988. * @param target defines the target where the behavior is attached to
  5989. */
  5990. attach(target: T): void;
  5991. /**
  5992. * Called when the behavior is detached from its target
  5993. */
  5994. detach(): void;
  5995. }
  5996. /**
  5997. * Interface implemented by classes supporting behaviors
  5998. */
  5999. export interface IBehaviorAware<T> {
  6000. /**
  6001. * Attach a behavior
  6002. * @param behavior defines the behavior to attach
  6003. * @returns the current host
  6004. */
  6005. addBehavior(behavior: Behavior<T>): T;
  6006. /**
  6007. * Remove a behavior from the current object
  6008. * @param behavior defines the behavior to detach
  6009. * @returns the current host
  6010. */
  6011. removeBehavior(behavior: Behavior<T>): T;
  6012. /**
  6013. * Gets a behavior using its name to search
  6014. * @param name defines the name to search
  6015. * @returns the behavior or null if not found
  6016. */
  6017. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. /**
  6022. * Defines an array and its length.
  6023. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6024. */
  6025. export interface ISmartArrayLike<T> {
  6026. /**
  6027. * The data of the array.
  6028. */
  6029. data: Array<T>;
  6030. /**
  6031. * The active length of the array.
  6032. */
  6033. length: number;
  6034. }
  6035. /**
  6036. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6037. */
  6038. export class SmartArray<T> implements ISmartArrayLike<T> {
  6039. /**
  6040. * The full set of data from the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. protected _id: number;
  6048. /**
  6049. * Instantiates a Smart Array.
  6050. * @param capacity defines the default capacity of the array.
  6051. */
  6052. constructor(capacity: number);
  6053. /**
  6054. * Pushes a value at the end of the active data.
  6055. * @param value defines the object to push in the array.
  6056. */
  6057. push(value: T): void;
  6058. /**
  6059. * Iterates over the active data and apply the lambda to them.
  6060. * @param func defines the action to apply on each value.
  6061. */
  6062. forEach(func: (content: T) => void): void;
  6063. /**
  6064. * Sorts the full sets of data.
  6065. * @param compareFn defines the comparison function to apply.
  6066. */
  6067. sort(compareFn: (a: T, b: T) => number): void;
  6068. /**
  6069. * Resets the active data to an empty array.
  6070. */
  6071. reset(): void;
  6072. /**
  6073. * Releases all the data from the array as well as the array.
  6074. */
  6075. dispose(): void;
  6076. /**
  6077. * Concats the active data with a given array.
  6078. * @param array defines the data to concatenate with.
  6079. */
  6080. concat(array: any): void;
  6081. /**
  6082. * Returns the position of a value in the active data.
  6083. * @param value defines the value to find the index for
  6084. * @returns the index if found in the active data otherwise -1
  6085. */
  6086. indexOf(value: T): number;
  6087. /**
  6088. * Returns whether an element is part of the active data.
  6089. * @param value defines the value to look for
  6090. * @returns true if found in the active data otherwise false
  6091. */
  6092. contains(value: T): boolean;
  6093. private static _GlobalId;
  6094. }
  6095. /**
  6096. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6097. * The data in this array can only be present once
  6098. */
  6099. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6100. private _duplicateId;
  6101. /**
  6102. * Pushes a value at the end of the active data.
  6103. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6104. * @param value defines the object to push in the array.
  6105. */
  6106. push(value: T): void;
  6107. /**
  6108. * Pushes a value at the end of the active data.
  6109. * If the data is already present, it won t be added again
  6110. * @param value defines the object to push in the array.
  6111. * @returns true if added false if it was already present
  6112. */
  6113. pushNoDuplicate(value: T): boolean;
  6114. /**
  6115. * Resets the active data to an empty array.
  6116. */
  6117. reset(): void;
  6118. /**
  6119. * Concats the active data with a given array.
  6120. * This ensures no dupplicate will be present in the result.
  6121. * @param array defines the data to concatenate with.
  6122. */
  6123. concatWithNoDuplicate(array: any): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @ignore
  6129. * This is a list of all the different input types that are available in the application.
  6130. * Fo instance: ArcRotateCameraGamepadInput...
  6131. */
  6132. export var CameraInputTypes: {};
  6133. /**
  6134. * This is the contract to implement in order to create a new input class.
  6135. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6136. */
  6137. export interface ICameraInput<TCamera extends Camera> {
  6138. /**
  6139. * Defines the camera the input is attached to.
  6140. */
  6141. camera: Nullable<TCamera>;
  6142. /**
  6143. * Gets the class name of the current intput.
  6144. * @returns the class name
  6145. */
  6146. getClassName(): string;
  6147. /**
  6148. * Get the friendly name associated with the input class.
  6149. * @returns the input friendly name
  6150. */
  6151. getSimpleName(): string;
  6152. /**
  6153. * Attach the input controls to a specific dom element to get the input from.
  6154. * @param element Defines the element the controls should be listened from
  6155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6156. */
  6157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6158. /**
  6159. * Detach the current controls from the specified dom element.
  6160. * @param element Defines the element to stop listening the inputs from
  6161. */
  6162. detachControl(element: Nullable<HTMLElement>): void;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs?: () => void;
  6168. }
  6169. /**
  6170. * Represents a map of input types to input instance or input index to input instance.
  6171. */
  6172. export interface CameraInputsMap<TCamera extends Camera> {
  6173. /**
  6174. * Accessor to the input by input type.
  6175. */
  6176. [name: string]: ICameraInput<TCamera>;
  6177. /**
  6178. * Accessor to the input by input index.
  6179. */
  6180. [idx: number]: ICameraInput<TCamera>;
  6181. }
  6182. /**
  6183. * This represents the input manager used within a camera.
  6184. * It helps dealing with all the different kind of input attached to a camera.
  6185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6186. */
  6187. export class CameraInputsManager<TCamera extends Camera> {
  6188. /**
  6189. * Defines the list of inputs attahed to the camera.
  6190. */
  6191. attached: CameraInputsMap<TCamera>;
  6192. /**
  6193. * Defines the dom element the camera is collecting inputs from.
  6194. * This is null if the controls have not been attached.
  6195. */
  6196. attachedElement: Nullable<HTMLElement>;
  6197. /**
  6198. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6199. */
  6200. noPreventDefault: boolean;
  6201. /**
  6202. * Defined the camera the input manager belongs to.
  6203. */
  6204. camera: TCamera;
  6205. /**
  6206. * Update the current camera state depending on the inputs that have been used this frame.
  6207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6208. */
  6209. checkInputs: () => void;
  6210. /**
  6211. * Instantiate a new Camera Input Manager.
  6212. * @param camera Defines the camera the input manager blongs to
  6213. */
  6214. constructor(camera: TCamera);
  6215. /**
  6216. * Add an input method to a camera
  6217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6218. * @param input camera input method
  6219. */
  6220. add(input: ICameraInput<TCamera>): void;
  6221. /**
  6222. * Remove a specific input method from a camera
  6223. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6224. * @param inputToRemove camera input method
  6225. */
  6226. remove(inputToRemove: ICameraInput<TCamera>): void;
  6227. /**
  6228. * Remove a specific input type from a camera
  6229. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6230. * @param inputType the type of the input to remove
  6231. */
  6232. removeByType(inputType: string): void;
  6233. private _addCheckInputs;
  6234. /**
  6235. * Attach the input controls to the currently attached dom element to listen the events from.
  6236. * @param input Defines the input to attach
  6237. */
  6238. attachInput(input: ICameraInput<TCamera>): void;
  6239. /**
  6240. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6241. * @param element Defines the dom element to collect the events from
  6242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6243. */
  6244. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6245. /**
  6246. * Detach the current manager inputs controls from a specific dom element.
  6247. * @param element Defines the dom element to collect the events from
  6248. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6249. */
  6250. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6251. /**
  6252. * Rebuild the dynamic inputCheck function from the current list of
  6253. * defined inputs in the manager.
  6254. */
  6255. rebuildInputCheck(): void;
  6256. /**
  6257. * Remove all attached input methods from a camera
  6258. */
  6259. clear(): void;
  6260. /**
  6261. * Serialize the current input manager attached to a camera.
  6262. * This ensures than once parsed,
  6263. * the input associated to the camera will be identical to the current ones
  6264. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6265. */
  6266. serialize(serializedCamera: any): void;
  6267. /**
  6268. * Parses an input manager serialized JSON to restore the previous list of inputs
  6269. * and states associated to a camera.
  6270. * @param parsedCamera Defines the JSON to parse
  6271. */
  6272. parse(parsedCamera: any): void;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. /**
  6277. * Class used to store data that will be store in GPU memory
  6278. */
  6279. export class Buffer {
  6280. private _engine;
  6281. private _buffer;
  6282. /** @hidden */
  6283. _data: Nullable<DataArray>;
  6284. private _updatable;
  6285. private _instanced;
  6286. private _divisor;
  6287. /**
  6288. * Gets the byte stride.
  6289. */
  6290. readonly byteStride: number;
  6291. /**
  6292. * Constructor
  6293. * @param engine the engine
  6294. * @param data the data to use for this buffer
  6295. * @param updatable whether the data is updatable
  6296. * @param stride the stride (optional)
  6297. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6298. * @param instanced whether the buffer is instanced (optional)
  6299. * @param useBytes set to true if the stride in in bytes (optional)
  6300. * @param divisor sets an optional divisor for instances (1 by default)
  6301. */
  6302. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6303. /**
  6304. * Create a new VertexBuffer based on the current buffer
  6305. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6306. * @param offset defines offset in the buffer (0 by default)
  6307. * @param size defines the size in floats of attributes (position is 3 for instance)
  6308. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6309. * @param instanced defines if the vertex buffer contains indexed data
  6310. * @param useBytes defines if the offset and stride are in bytes *
  6311. * @param divisor sets an optional divisor for instances (1 by default)
  6312. * @returns the new vertex buffer
  6313. */
  6314. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6315. /**
  6316. * Gets a boolean indicating if the Buffer is updatable?
  6317. * @returns true if the buffer is updatable
  6318. */
  6319. isUpdatable(): boolean;
  6320. /**
  6321. * Gets current buffer's data
  6322. * @returns a DataArray or null
  6323. */
  6324. getData(): Nullable<DataArray>;
  6325. /**
  6326. * Gets underlying native buffer
  6327. * @returns underlying native buffer
  6328. */
  6329. getBuffer(): Nullable<DataBuffer>;
  6330. /**
  6331. * Gets the stride in float32 units (i.e. byte stride / 4).
  6332. * May not be an integer if the byte stride is not divisible by 4.
  6333. * @returns the stride in float32 units
  6334. * @deprecated Please use byteStride instead.
  6335. */
  6336. getStrideSize(): number;
  6337. /**
  6338. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6339. * @param data defines the data to store
  6340. */
  6341. create(data?: Nullable<DataArray>): void;
  6342. /** @hidden */
  6343. _rebuild(): void;
  6344. /**
  6345. * Update current buffer data
  6346. * @param data defines the data to store
  6347. */
  6348. update(data: DataArray): void;
  6349. /**
  6350. * Updates the data directly.
  6351. * @param data the new data
  6352. * @param offset the new offset
  6353. * @param vertexCount the vertex count (optional)
  6354. * @param useBytes set to true if the offset is in bytes
  6355. */
  6356. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6357. /**
  6358. * Release all resources
  6359. */
  6360. dispose(): void;
  6361. }
  6362. /**
  6363. * Specialized buffer used to store vertex data
  6364. */
  6365. export class VertexBuffer {
  6366. /** @hidden */
  6367. _buffer: Buffer;
  6368. private _kind;
  6369. private _size;
  6370. private _ownsBuffer;
  6371. private _instanced;
  6372. private _instanceDivisor;
  6373. /**
  6374. * The byte type.
  6375. */
  6376. static readonly BYTE: number;
  6377. /**
  6378. * The unsigned byte type.
  6379. */
  6380. static readonly UNSIGNED_BYTE: number;
  6381. /**
  6382. * The short type.
  6383. */
  6384. static readonly SHORT: number;
  6385. /**
  6386. * The unsigned short type.
  6387. */
  6388. static readonly UNSIGNED_SHORT: number;
  6389. /**
  6390. * The integer type.
  6391. */
  6392. static readonly INT: number;
  6393. /**
  6394. * The unsigned integer type.
  6395. */
  6396. static readonly UNSIGNED_INT: number;
  6397. /**
  6398. * The float type.
  6399. */
  6400. static readonly FLOAT: number;
  6401. /**
  6402. * Gets or sets the instance divisor when in instanced mode
  6403. */
  6404. get instanceDivisor(): number;
  6405. set instanceDivisor(value: number);
  6406. /**
  6407. * Gets the byte stride.
  6408. */
  6409. readonly byteStride: number;
  6410. /**
  6411. * Gets the byte offset.
  6412. */
  6413. readonly byteOffset: number;
  6414. /**
  6415. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6416. */
  6417. readonly normalized: boolean;
  6418. /**
  6419. * Gets the data type of each component in the array.
  6420. */
  6421. readonly type: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this vertex buffer
  6426. * @param kind the vertex buffer kind
  6427. * @param updatable whether the data is updatable
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param stride the stride (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param offset the offset of the data (optional)
  6432. * @param size the number of components (optional)
  6433. * @param type the type of the component (optional)
  6434. * @param normalized whether the data contains normalized data (optional)
  6435. * @param useBytes set to true if stride and offset are in bytes (optional)
  6436. * @param divisor defines the instance divisor to use (1 by default)
  6437. */
  6438. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6439. /** @hidden */
  6440. _rebuild(): void;
  6441. /**
  6442. * Returns the kind of the VertexBuffer (string)
  6443. * @returns a string
  6444. */
  6445. getKind(): string;
  6446. /**
  6447. * Gets a boolean indicating if the VertexBuffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Returns the offset as a multiple of the type byte length.
  6470. * @returns the offset in bytes
  6471. * @deprecated Please use byteOffset instead.
  6472. */
  6473. getOffset(): number;
  6474. /**
  6475. * Returns the number of components per vertex attribute (integer)
  6476. * @returns the size in float
  6477. */
  6478. getSize(): number;
  6479. /**
  6480. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6481. * @returns true if this buffer is instanced
  6482. */
  6483. getIsInstanced(): boolean;
  6484. /**
  6485. * Returns the instancing divisor, zero for non-instanced (integer).
  6486. * @returns a number
  6487. */
  6488. getInstanceDivisor(): number;
  6489. /**
  6490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6491. * @param data defines the data to store
  6492. */
  6493. create(data?: DataArray): void;
  6494. /**
  6495. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6496. * This function will create a new buffer if the current one is not updatable
  6497. * @param data defines the data to store
  6498. */
  6499. update(data: DataArray): void;
  6500. /**
  6501. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6502. * Returns the directly updated WebGLBuffer.
  6503. * @param data the new data
  6504. * @param offset the new offset
  6505. * @param useBytes set to true if the offset is in bytes
  6506. */
  6507. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6508. /**
  6509. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6510. */
  6511. dispose(): void;
  6512. /**
  6513. * Enumerates each value of this vertex buffer as numbers.
  6514. * @param count the number of values to enumerate
  6515. * @param callback the callback function called for each value
  6516. */
  6517. forEach(count: number, callback: (value: number, index: number) => void): void;
  6518. /**
  6519. * Positions
  6520. */
  6521. static readonly PositionKind: string;
  6522. /**
  6523. * Normals
  6524. */
  6525. static readonly NormalKind: string;
  6526. /**
  6527. * Tangents
  6528. */
  6529. static readonly TangentKind: string;
  6530. /**
  6531. * Texture coordinates
  6532. */
  6533. static readonly UVKind: string;
  6534. /**
  6535. * Texture coordinates 2
  6536. */
  6537. static readonly UV2Kind: string;
  6538. /**
  6539. * Texture coordinates 3
  6540. */
  6541. static readonly UV3Kind: string;
  6542. /**
  6543. * Texture coordinates 4
  6544. */
  6545. static readonly UV4Kind: string;
  6546. /**
  6547. * Texture coordinates 5
  6548. */
  6549. static readonly UV5Kind: string;
  6550. /**
  6551. * Texture coordinates 6
  6552. */
  6553. static readonly UV6Kind: string;
  6554. /**
  6555. * Colors
  6556. */
  6557. static readonly ColorKind: string;
  6558. /**
  6559. * Matrix indices (for bones)
  6560. */
  6561. static readonly MatricesIndicesKind: string;
  6562. /**
  6563. * Matrix weights (for bones)
  6564. */
  6565. static readonly MatricesWeightsKind: string;
  6566. /**
  6567. * Additional matrix indices (for bones)
  6568. */
  6569. static readonly MatricesIndicesExtraKind: string;
  6570. /**
  6571. * Additional matrix weights (for bones)
  6572. */
  6573. static readonly MatricesWeightsExtraKind: string;
  6574. /**
  6575. * Deduces the stride given a kind.
  6576. * @param kind The kind string to deduce
  6577. * @returns The deduced stride
  6578. */
  6579. static DeduceStride(kind: string): number;
  6580. /**
  6581. * Gets the byte length of the given type.
  6582. * @param type the type
  6583. * @returns the number of bytes
  6584. */
  6585. static GetTypeByteLength(type: number): number;
  6586. /**
  6587. * Enumerates each value of the given parameters as numbers.
  6588. * @param data the data to enumerate
  6589. * @param byteOffset the byte offset of the data
  6590. * @param byteStride the byte stride of the data
  6591. * @param componentCount the number of components per element
  6592. * @param componentType the type of the component
  6593. * @param count the number of values to enumerate
  6594. * @param normalized whether the data is normalized
  6595. * @param callback the callback function called for each value
  6596. */
  6597. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6598. private static _GetFloatValue;
  6599. }
  6600. }
  6601. declare module BABYLON {
  6602. /**
  6603. * @hidden
  6604. */
  6605. export class IntersectionInfo {
  6606. bu: Nullable<number>;
  6607. bv: Nullable<number>;
  6608. distance: number;
  6609. faceId: number;
  6610. subMeshId: number;
  6611. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6612. }
  6613. }
  6614. declare module BABYLON {
  6615. /**
  6616. * Represens a plane by the equation ax + by + cz + d = 0
  6617. */
  6618. export class Plane {
  6619. private static _TmpMatrix;
  6620. /**
  6621. * Normal of the plane (a,b,c)
  6622. */
  6623. normal: Vector3;
  6624. /**
  6625. * d component of the plane
  6626. */
  6627. d: number;
  6628. /**
  6629. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6630. * @param a a component of the plane
  6631. * @param b b component of the plane
  6632. * @param c c component of the plane
  6633. * @param d d component of the plane
  6634. */
  6635. constructor(a: number, b: number, c: number, d: number);
  6636. /**
  6637. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6638. */
  6639. asArray(): number[];
  6640. /**
  6641. * @returns a new plane copied from the current Plane.
  6642. */
  6643. clone(): Plane;
  6644. /**
  6645. * @returns the string "Plane".
  6646. */
  6647. getClassName(): string;
  6648. /**
  6649. * @returns the Plane hash code.
  6650. */
  6651. getHashCode(): number;
  6652. /**
  6653. * Normalize the current Plane in place.
  6654. * @returns the updated Plane.
  6655. */
  6656. normalize(): Plane;
  6657. /**
  6658. * Applies a transformation the plane and returns the result
  6659. * @param transformation the transformation matrix to be applied to the plane
  6660. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6661. */
  6662. transform(transformation: DeepImmutable<Matrix>): Plane;
  6663. /**
  6664. * Calcualtte the dot product between the point and the plane normal
  6665. * @param point point to calculate the dot product with
  6666. * @returns the dot product (float) of the point coordinates and the plane normal.
  6667. */
  6668. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6669. /**
  6670. * Updates the current Plane from the plane defined by the three given points.
  6671. * @param point1 one of the points used to contruct the plane
  6672. * @param point2 one of the points used to contruct the plane
  6673. * @param point3 one of the points used to contruct the plane
  6674. * @returns the updated Plane.
  6675. */
  6676. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Checks if the plane is facing a given direction
  6679. * @param direction the direction to check if the plane is facing
  6680. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6681. * @returns True is the vector "direction" is the same side than the plane normal.
  6682. */
  6683. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6684. /**
  6685. * Calculates the distance to a point
  6686. * @param point point to calculate distance to
  6687. * @returns the signed distance (float) from the given point to the Plane.
  6688. */
  6689. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6690. /**
  6691. * Creates a plane from an array
  6692. * @param array the array to create a plane from
  6693. * @returns a new Plane from the given array.
  6694. */
  6695. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6696. /**
  6697. * Creates a plane from three points
  6698. * @param point1 point used to create the plane
  6699. * @param point2 point used to create the plane
  6700. * @param point3 point used to create the plane
  6701. * @returns a new Plane defined by the three given points.
  6702. */
  6703. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6704. /**
  6705. * Creates a plane from an origin point and a normal
  6706. * @param origin origin of the plane to be constructed
  6707. * @param normal normal of the plane to be constructed
  6708. * @returns a new Plane the normal vector to this plane at the given origin point.
  6709. * Note : the vector "normal" is updated because normalized.
  6710. */
  6711. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6712. /**
  6713. * Calculates the distance from a plane and a point
  6714. * @param origin origin of the plane to be constructed
  6715. * @param normal normal of the plane to be constructed
  6716. * @param point point to calculate distance to
  6717. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6718. */
  6719. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6720. }
  6721. }
  6722. declare module BABYLON {
  6723. /**
  6724. * Class used to store bounding sphere information
  6725. */
  6726. export class BoundingSphere {
  6727. /**
  6728. * Gets the center of the bounding sphere in local space
  6729. */
  6730. readonly center: Vector3;
  6731. /**
  6732. * Radius of the bounding sphere in local space
  6733. */
  6734. radius: number;
  6735. /**
  6736. * Gets the center of the bounding sphere in world space
  6737. */
  6738. readonly centerWorld: Vector3;
  6739. /**
  6740. * Radius of the bounding sphere in world space
  6741. */
  6742. radiusWorld: number;
  6743. /**
  6744. * Gets the minimum vector in local space
  6745. */
  6746. readonly minimum: Vector3;
  6747. /**
  6748. * Gets the maximum vector in local space
  6749. */
  6750. readonly maximum: Vector3;
  6751. private _worldMatrix;
  6752. private static readonly TmpVector3;
  6753. /**
  6754. * Creates a new bounding sphere
  6755. * @param min defines the minimum vector (in local space)
  6756. * @param max defines the maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6760. /**
  6761. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6762. * @param min defines the new minimum vector (in local space)
  6763. * @param max defines the new maximum vector (in local space)
  6764. * @param worldMatrix defines the new world matrix
  6765. */
  6766. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Scale the current bounding sphere by applying a scale factor
  6769. * @param factor defines the scale factor to apply
  6770. * @returns the current bounding box
  6771. */
  6772. scale(factor: number): BoundingSphere;
  6773. /**
  6774. * Gets the world matrix of the bounding box
  6775. * @returns a matrix
  6776. */
  6777. getWorldMatrix(): DeepImmutable<Matrix>;
  6778. /** @hidden */
  6779. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6780. /**
  6781. * Tests if the bounding sphere is intersecting the frustum planes
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if there is an intersection
  6784. */
  6785. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if the bounding sphere center is in between the frustum planes.
  6788. * Used for optimistic fast inclusion.
  6789. * @param frustumPlanes defines the frustum planes to test
  6790. * @returns true if the sphere center is in between the frustum planes
  6791. */
  6792. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6793. /**
  6794. * Tests if a point is inside the bounding sphere
  6795. * @param point defines the point to test
  6796. * @returns true if the point is inside the bounding sphere
  6797. */
  6798. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6799. /**
  6800. * Checks if two sphere intersct
  6801. * @param sphere0 sphere 0
  6802. * @param sphere1 sphere 1
  6803. * @returns true if the speres intersect
  6804. */
  6805. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6806. }
  6807. }
  6808. declare module BABYLON {
  6809. /**
  6810. * Class used to store bounding box information
  6811. */
  6812. export class BoundingBox implements ICullable {
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in local space
  6815. */
  6816. readonly vectors: Vector3[];
  6817. /**
  6818. * Gets the center of the bounding box in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Gets the center of the bounding box in world space
  6823. */
  6824. readonly centerWorld: Vector3;
  6825. /**
  6826. * Gets the extend size in local space
  6827. */
  6828. readonly extendSize: Vector3;
  6829. /**
  6830. * Gets the extend size in world space
  6831. */
  6832. readonly extendSizeWorld: Vector3;
  6833. /**
  6834. * Gets the OBB (object bounding box) directions
  6835. */
  6836. readonly directions: Vector3[];
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in world space
  6839. */
  6840. readonly vectorsWorld: Vector3[];
  6841. /**
  6842. * Gets the minimum vector in world space
  6843. */
  6844. readonly minimumWorld: Vector3;
  6845. /**
  6846. * Gets the maximum vector in world space
  6847. */
  6848. readonly maximumWorld: Vector3;
  6849. /**
  6850. * Gets the minimum vector in local space
  6851. */
  6852. readonly minimum: Vector3;
  6853. /**
  6854. * Gets the maximum vector in local space
  6855. */
  6856. readonly maximum: Vector3;
  6857. private _worldMatrix;
  6858. private static readonly TmpVector3;
  6859. /**
  6860. * @hidden
  6861. */
  6862. _tag: number;
  6863. /**
  6864. * Creates a new bounding box
  6865. * @param min defines the minimum vector (in local space)
  6866. * @param max defines the maximum vector (in local space)
  6867. * @param worldMatrix defines the new world matrix
  6868. */
  6869. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6870. /**
  6871. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6872. * @param min defines the new minimum vector (in local space)
  6873. * @param max defines the new maximum vector (in local space)
  6874. * @param worldMatrix defines the new world matrix
  6875. */
  6876. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6877. /**
  6878. * Scale the current bounding box by applying a scale factor
  6879. * @param factor defines the scale factor to apply
  6880. * @returns the current bounding box
  6881. */
  6882. scale(factor: number): BoundingBox;
  6883. /**
  6884. * Gets the world matrix of the bounding box
  6885. * @returns a matrix
  6886. */
  6887. getWorldMatrix(): DeepImmutable<Matrix>;
  6888. /** @hidden */
  6889. _update(world: DeepImmutable<Matrix>): void;
  6890. /**
  6891. * Tests if the bounding box is intersecting the frustum planes
  6892. * @param frustumPlanes defines the frustum planes to test
  6893. * @returns true if there is an intersection
  6894. */
  6895. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6896. /**
  6897. * Tests if the bounding box is entirely inside the frustum planes
  6898. * @param frustumPlanes defines the frustum planes to test
  6899. * @returns true if there is an inclusion
  6900. */
  6901. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6902. /**
  6903. * Tests if a point is inside the bounding box
  6904. * @param point defines the point to test
  6905. * @returns true if the point is inside the bounding box
  6906. */
  6907. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6908. /**
  6909. * Tests if the bounding box intersects with a bounding sphere
  6910. * @param sphere defines the sphere to test
  6911. * @returns true if there is an intersection
  6912. */
  6913. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6914. /**
  6915. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6916. * @param min defines the min vector to use
  6917. * @param max defines the max vector to use
  6918. * @returns true if there is an intersection
  6919. */
  6920. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Tests if two bounding boxes are intersections
  6923. * @param box0 defines the first box to test
  6924. * @param box1 defines the second box to test
  6925. * @returns true if there is an intersection
  6926. */
  6927. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6928. /**
  6929. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6930. * @param minPoint defines the minimum vector of the bounding box
  6931. * @param maxPoint defines the maximum vector of the bounding box
  6932. * @param sphereCenter defines the sphere center
  6933. * @param sphereRadius defines the sphere radius
  6934. * @returns true if there is an intersection
  6935. */
  6936. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6937. /**
  6938. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6939. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @return true if there is an inclusion
  6942. */
  6943. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6947. * @param frustumPlanes defines the frustum planes to test
  6948. * @return true if there is an intersection
  6949. */
  6950. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6951. }
  6952. }
  6953. declare module BABYLON {
  6954. /** @hidden */
  6955. export class Collider {
  6956. /** Define if a collision was found */
  6957. collisionFound: boolean;
  6958. /**
  6959. * Define last intersection point in local space
  6960. */
  6961. intersectionPoint: Vector3;
  6962. /**
  6963. * Define last collided mesh
  6964. */
  6965. collidedMesh: Nullable<AbstractMesh>;
  6966. private _collisionPoint;
  6967. private _planeIntersectionPoint;
  6968. private _tempVector;
  6969. private _tempVector2;
  6970. private _tempVector3;
  6971. private _tempVector4;
  6972. private _edge;
  6973. private _baseToVertex;
  6974. private _destinationPoint;
  6975. private _slidePlaneNormal;
  6976. private _displacementVector;
  6977. /** @hidden */
  6978. _radius: Vector3;
  6979. /** @hidden */
  6980. _retry: number;
  6981. private _velocity;
  6982. private _basePoint;
  6983. private _epsilon;
  6984. /** @hidden */
  6985. _velocityWorldLength: number;
  6986. /** @hidden */
  6987. _basePointWorld: Vector3;
  6988. private _velocityWorld;
  6989. private _normalizedVelocity;
  6990. /** @hidden */
  6991. _initialVelocity: Vector3;
  6992. /** @hidden */
  6993. _initialPosition: Vector3;
  6994. private _nearestDistance;
  6995. private _collisionMask;
  6996. get collisionMask(): number;
  6997. set collisionMask(mask: number);
  6998. /**
  6999. * Gets the plane normal used to compute the sliding response (in local space)
  7000. */
  7001. get slidePlaneNormal(): Vector3;
  7002. /** @hidden */
  7003. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7004. /** @hidden */
  7005. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7006. /** @hidden */
  7007. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7008. /** @hidden */
  7009. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _getResponse(pos: Vector3, vel: Vector3): void;
  7014. }
  7015. }
  7016. declare module BABYLON {
  7017. /**
  7018. * Interface for cullable objects
  7019. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7020. */
  7021. export interface ICullable {
  7022. /**
  7023. * Checks if the object or part of the object is in the frustum
  7024. * @param frustumPlanes Camera near/planes
  7025. * @returns true if the object is in frustum otherwise false
  7026. */
  7027. isInFrustum(frustumPlanes: Plane[]): boolean;
  7028. /**
  7029. * Checks if a cullable object (mesh...) is in the camera frustum
  7030. * Unlike isInFrustum this cheks the full bounding box
  7031. * @param frustumPlanes Camera near/planes
  7032. * @returns true if the object is in frustum otherwise false
  7033. */
  7034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7035. }
  7036. /**
  7037. * Info for a bounding data of a mesh
  7038. */
  7039. export class BoundingInfo implements ICullable {
  7040. /**
  7041. * Bounding box for the mesh
  7042. */
  7043. readonly boundingBox: BoundingBox;
  7044. /**
  7045. * Bounding sphere for the mesh
  7046. */
  7047. readonly boundingSphere: BoundingSphere;
  7048. private _isLocked;
  7049. private static readonly TmpVector3;
  7050. /**
  7051. * Constructs bounding info
  7052. * @param minimum min vector of the bounding box/sphere
  7053. * @param maximum max vector of the bounding box/sphere
  7054. * @param worldMatrix defines the new world matrix
  7055. */
  7056. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7057. /**
  7058. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7059. * @param min defines the new minimum vector (in local space)
  7060. * @param max defines the new maximum vector (in local space)
  7061. * @param worldMatrix defines the new world matrix
  7062. */
  7063. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7064. /**
  7065. * min vector of the bounding box/sphere
  7066. */
  7067. get minimum(): Vector3;
  7068. /**
  7069. * max vector of the bounding box/sphere
  7070. */
  7071. get maximum(): Vector3;
  7072. /**
  7073. * If the info is locked and won't be updated to avoid perf overhead
  7074. */
  7075. get isLocked(): boolean;
  7076. set isLocked(value: boolean);
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. get diagonalLength(): number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module BABYLON {
  7161. /** @hidden */
  7162. export class WebGLDataBuffer extends DataBuffer {
  7163. private _buffer;
  7164. constructor(resource: WebGLBuffer);
  7165. get underlyingResource(): any;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /** @hidden */
  7170. export class WebGLPipelineContext implements IPipelineContext {
  7171. engine: ThinEngine;
  7172. program: Nullable<WebGLProgram>;
  7173. context?: WebGLRenderingContext;
  7174. vertexShader?: WebGLShader;
  7175. fragmentShader?: WebGLShader;
  7176. isParallelCompiled: boolean;
  7177. onCompiled?: () => void;
  7178. transformFeedback?: WebGLTransformFeedback | null;
  7179. vertexCompilationError: Nullable<string>;
  7180. fragmentCompilationError: Nullable<string>;
  7181. programLinkError: Nullable<string>;
  7182. programValidationError: Nullable<string>;
  7183. get isAsync(): boolean;
  7184. get isReady(): boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. _getVertexShaderCode(): string | null;
  7187. _getFragmentShaderCode(): string | null;
  7188. }
  7189. }
  7190. declare module BABYLON {
  7191. interface ThinEngine {
  7192. /**
  7193. * Create an uniform buffer
  7194. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7195. * @param elements defines the content of the uniform buffer
  7196. * @returns the webGL uniform buffer
  7197. */
  7198. createUniformBuffer(elements: FloatArray): DataBuffer;
  7199. /**
  7200. * Create a dynamic uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Update an existing uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param uniformBuffer defines the target uniform buffer
  7210. * @param elements defines the content to update
  7211. * @param offset defines the offset in the uniform buffer where update should start
  7212. * @param count defines the size of the data to update
  7213. */
  7214. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7215. /**
  7216. * Bind an uniform buffer to the current webGL context
  7217. * @param buffer defines the buffer to bind
  7218. */
  7219. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7220. /**
  7221. * Bind a buffer to the current webGL context at a given location
  7222. * @param buffer defines the buffer to bind
  7223. * @param location defines the index where to bind the buffer
  7224. */
  7225. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7226. /**
  7227. * Bind a specific block at a given index in a specific shader program
  7228. * @param pipelineContext defines the pipeline context to use
  7229. * @param blockName defines the block name
  7230. * @param index defines the index where to bind the block
  7231. */
  7232. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Uniform buffer objects.
  7238. *
  7239. * Handles blocks of uniform on the GPU.
  7240. *
  7241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7242. *
  7243. * For more information, please refer to :
  7244. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7245. */
  7246. export class UniformBuffer {
  7247. private _engine;
  7248. private _buffer;
  7249. private _data;
  7250. private _bufferData;
  7251. private _dynamic?;
  7252. private _uniformLocations;
  7253. private _uniformSizes;
  7254. private _uniformLocationPointer;
  7255. private _needSync;
  7256. private _noUBO;
  7257. private _currentEffect;
  7258. /** @hidden */
  7259. _alreadyBound: boolean;
  7260. private static _MAX_UNIFORM_SIZE;
  7261. private static _tempBuffer;
  7262. /**
  7263. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7268. /**
  7269. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7274. /**
  7275. * Lambda to Update a single float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat: (name: string, x: number) => void;
  7280. /**
  7281. * Lambda to Update a vec2 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a vec3 of float in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update a vec4 of float in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateMatrix: (name: string, mat: Matrix) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateVector3: (name: string, vector: Vector3) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateVector4: (name: string, vector: Vector4) => void;
  7316. /**
  7317. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7328. /**
  7329. * Instantiates a new Uniform buffer objects.
  7330. *
  7331. * Handles blocks of uniform on the GPU.
  7332. *
  7333. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7334. *
  7335. * For more information, please refer to :
  7336. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7337. * @param engine Define the engine the buffer is associated with
  7338. * @param data Define the data contained in the buffer
  7339. * @param dynamic Define if the buffer is updatable
  7340. */
  7341. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7342. /**
  7343. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7344. * or just falling back on setUniformXXX calls.
  7345. */
  7346. get useUbo(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is in sync
  7349. * with the javascript cache data.
  7350. */
  7351. get isSync(): boolean;
  7352. /**
  7353. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7354. * Also, a dynamic UniformBuffer will disable cache verification and always
  7355. * update the underlying WebGL uniform buffer to the GPU.
  7356. * @returns if Dynamic, otherwise false
  7357. */
  7358. isDynamic(): boolean;
  7359. /**
  7360. * The data cache on JS side.
  7361. * @returns the underlying data as a float array
  7362. */
  7363. getData(): Float32Array;
  7364. /**
  7365. * The underlying WebGL Uniform buffer.
  7366. * @returns the webgl buffer
  7367. */
  7368. getBuffer(): Nullable<DataBuffer>;
  7369. /**
  7370. * std140 layout specifies how to align data within an UBO structure.
  7371. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7372. * for specs.
  7373. */
  7374. private _fillAlignment;
  7375. /**
  7376. * Adds an uniform in the buffer.
  7377. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7378. * for the layout to be correct !
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param size Data size, or data directly.
  7381. */
  7382. addUniform(name: string, size: number | number[]): void;
  7383. /**
  7384. * Adds a Matrix 4x4 to the uniform buffer.
  7385. * @param name Name of the uniform, as used in the uniform block in the shader.
  7386. * @param mat A 4x4 matrix.
  7387. */
  7388. addMatrix(name: string, mat: Matrix): void;
  7389. /**
  7390. * Adds a vec2 to the uniform buffer.
  7391. * @param name Name of the uniform, as used in the uniform block in the shader.
  7392. * @param x Define the x component value of the vec2
  7393. * @param y Define the y component value of the vec2
  7394. */
  7395. addFloat2(name: string, x: number, y: number): void;
  7396. /**
  7397. * Adds a vec3 to the uniform buffer.
  7398. * @param name Name of the uniform, as used in the uniform block in the shader.
  7399. * @param x Define the x component value of the vec3
  7400. * @param y Define the y component value of the vec3
  7401. * @param z Define the z component value of the vec3
  7402. */
  7403. addFloat3(name: string, x: number, y: number, z: number): void;
  7404. /**
  7405. * Adds a vec3 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. * @param color Define the vec3 from a Color
  7408. */
  7409. addColor3(name: string, color: Color3): void;
  7410. /**
  7411. * Adds a vec4 to the uniform buffer.
  7412. * @param name Name of the uniform, as used in the uniform block in the shader.
  7413. * @param color Define the rgb components from a Color
  7414. * @param alpha Define the a component of the vec4
  7415. */
  7416. addColor4(name: string, color: Color3, alpha: number): void;
  7417. /**
  7418. * Adds a vec3 to the uniform buffer.
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param vector Define the vec3 components from a Vector
  7421. */
  7422. addVector3(name: string, vector: Vector3): void;
  7423. /**
  7424. * Adds a Matrix 3x3 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix3x3(name: string): void;
  7428. /**
  7429. * Adds a Matrix 2x2 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. */
  7432. addMatrix2x2(name: string): void;
  7433. /**
  7434. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7435. */
  7436. create(): void;
  7437. /** @hidden */
  7438. _rebuild(): void;
  7439. /**
  7440. * Updates the WebGL Uniform Buffer on the GPU.
  7441. * If the `dynamic` flag is set to true, no cache comparison is done.
  7442. * Otherwise, the buffer will be updated only if the cache differs.
  7443. */
  7444. update(): void;
  7445. /**
  7446. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7447. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7448. * @param data Define the flattened data
  7449. * @param size Define the size of the data.
  7450. */
  7451. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7452. private _valueCache;
  7453. private _cacheMatrix;
  7454. private _updateMatrix3x3ForUniform;
  7455. private _updateMatrix3x3ForEffect;
  7456. private _updateMatrix2x2ForEffect;
  7457. private _updateMatrix2x2ForUniform;
  7458. private _updateFloatForEffect;
  7459. private _updateFloatForUniform;
  7460. private _updateFloat2ForEffect;
  7461. private _updateFloat2ForUniform;
  7462. private _updateFloat3ForEffect;
  7463. private _updateFloat3ForUniform;
  7464. private _updateFloat4ForEffect;
  7465. private _updateFloat4ForUniform;
  7466. private _updateMatrixForEffect;
  7467. private _updateMatrixForUniform;
  7468. private _updateVector3ForEffect;
  7469. private _updateVector3ForUniform;
  7470. private _updateVector4ForEffect;
  7471. private _updateVector4ForUniform;
  7472. private _updateColor3ForEffect;
  7473. private _updateColor3ForUniform;
  7474. private _updateColor4ForEffect;
  7475. private _updateColor4ForUniform;
  7476. /**
  7477. * Sets a sampler uniform on the effect.
  7478. * @param name Define the name of the sampler.
  7479. * @param texture Define the texture to set in the sampler
  7480. */
  7481. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7482. /**
  7483. * Directly updates the value of the uniform in the cache AND on the GPU.
  7484. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7485. * @param data Define the flattened data
  7486. */
  7487. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7488. /**
  7489. * Binds this uniform buffer to an effect.
  7490. * @param effect Define the effect to bind the buffer to
  7491. * @param name Name of the uniform block in the shader.
  7492. */
  7493. bindToEffect(effect: Effect, name: string): void;
  7494. /**
  7495. * Disposes the uniform buffer.
  7496. */
  7497. dispose(): void;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Enum that determines the text-wrapping mode to use.
  7503. */
  7504. export enum InspectableType {
  7505. /**
  7506. * Checkbox for booleans
  7507. */
  7508. Checkbox = 0,
  7509. /**
  7510. * Sliders for numbers
  7511. */
  7512. Slider = 1,
  7513. /**
  7514. * Vector3
  7515. */
  7516. Vector3 = 2,
  7517. /**
  7518. * Quaternions
  7519. */
  7520. Quaternion = 3,
  7521. /**
  7522. * Color3
  7523. */
  7524. Color3 = 4,
  7525. /**
  7526. * String
  7527. */
  7528. String = 5
  7529. }
  7530. /**
  7531. * Interface used to define custom inspectable properties.
  7532. * This interface is used by the inspector to display custom property grids
  7533. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7534. */
  7535. export interface IInspectable {
  7536. /**
  7537. * Gets the label to display
  7538. */
  7539. label: string;
  7540. /**
  7541. * Gets the name of the property to edit
  7542. */
  7543. propertyName: string;
  7544. /**
  7545. * Gets the type of the editor to use
  7546. */
  7547. type: InspectableType;
  7548. /**
  7549. * Gets the minimum value of the property when using in "slider" mode
  7550. */
  7551. min?: number;
  7552. /**
  7553. * Gets the maximum value of the property when using in "slider" mode
  7554. */
  7555. max?: number;
  7556. /**
  7557. * Gets the setp to use when using in "slider" mode
  7558. */
  7559. step?: number;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to provide helper for timing
  7565. */
  7566. export class TimingTools {
  7567. /**
  7568. * Polyfill for setImmediate
  7569. * @param action defines the action to execute after the current execution block
  7570. */
  7571. static SetImmediate(action: () => void): void;
  7572. }
  7573. }
  7574. declare module BABYLON {
  7575. /**
  7576. * Class used to enable instatition of objects by class name
  7577. */
  7578. export class InstantiationTools {
  7579. /**
  7580. * Use this object to register external classes like custom textures or material
  7581. * to allow the laoders to instantiate them
  7582. */
  7583. static RegisteredExternalClasses: {
  7584. [key: string]: Object;
  7585. };
  7586. /**
  7587. * Tries to instantiate a new object from a given class name
  7588. * @param className defines the class name to instantiate
  7589. * @returns the new object or null if the system was not able to do the instantiation
  7590. */
  7591. static Instantiate(className: string): any;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Define options used to create a depth texture
  7597. */
  7598. export class DepthTextureCreationOptions {
  7599. /** Specifies whether or not a stencil should be allocated in the texture */
  7600. generateStencil?: boolean;
  7601. /** Specifies whether or not bilinear filtering is enable on the texture */
  7602. bilinearFiltering?: boolean;
  7603. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7604. comparisonFunction?: number;
  7605. /** Specifies if the created texture is a cube texture */
  7606. isCube?: boolean;
  7607. }
  7608. }
  7609. declare module BABYLON {
  7610. interface ThinEngine {
  7611. /**
  7612. * Creates a depth stencil cube texture.
  7613. * This is only available in WebGL 2.
  7614. * @param size The size of face edge in the cube texture.
  7615. * @param options The options defining the cube texture.
  7616. * @returns The cube texture
  7617. */
  7618. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @returns the cube texture as an InternalTexture
  7647. */
  7648. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7649. /**
  7650. * Creates a cube texture
  7651. * @param rootUrl defines the url where the files to load is located
  7652. * @param scene defines the current scene
  7653. * @param files defines the list of files to load (1 per face)
  7654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7655. * @param onLoad defines an optional callback raised when the texture is loaded
  7656. * @param onError defines an optional callback raised if there is an issue to load the texture
  7657. * @param format defines the format of the data
  7658. * @param forcedExtension defines the extension to use to pick the right loader
  7659. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7665. /** @hidden */
  7666. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /** @hidden */
  7672. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /**
  7674. * @hidden
  7675. */
  7676. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * Observable triggered once the texture has been loaded.
  7687. */
  7688. onLoadObservable: Observable<CubeTexture>;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. set boundingBoxSize(value: Vector3);
  7707. /**
  7708. * Returns the bounding box size
  7709. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7710. */
  7711. get boundingBoxSize(): Vector3;
  7712. protected _rotationY: number;
  7713. /**
  7714. * Sets texture matrix rotation angle around Y axis in radians.
  7715. */
  7716. set rotationY(value: number);
  7717. /**
  7718. * Gets texture matrix rotation angle around Y axis radians.
  7719. */
  7720. get rotationY(): number;
  7721. /**
  7722. * Are mip maps generated for this texture or not.
  7723. */
  7724. get noMipmap(): boolean;
  7725. private _noMipmap;
  7726. private _files;
  7727. protected _forcedExtension: Nullable<string>;
  7728. private _extensions;
  7729. private _textureMatrix;
  7730. private _format;
  7731. private _createPolynomials;
  7732. /** @hidden */
  7733. _prefiltered: boolean;
  7734. /**
  7735. * Creates a cube texture from an array of image urls
  7736. * @param files defines an array of image urls
  7737. * @param scene defines the hosting scene
  7738. * @param noMipmap specifies if mip maps are not used
  7739. * @returns a cube texture
  7740. */
  7741. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7742. /**
  7743. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7744. * @param url defines the url of the prefiltered texture
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param forcedExtension defines the extension of the file if different from the url
  7747. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7748. * @return the prefiltered texture
  7749. */
  7750. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7751. /**
  7752. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7753. * as prefiltered data.
  7754. * @param rootUrl defines the url of the texture or the root name of the six images
  7755. * @param scene defines the scene the texture is attached to
  7756. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7757. * @param noMipmap defines if mipmaps should be created or not
  7758. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7759. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7760. * @param onError defines a callback triggered in case of error during load
  7761. * @param format defines the internal format to use for the texture once loaded
  7762. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7763. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7764. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7765. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7766. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7767. * @return the cube texture
  7768. */
  7769. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7770. /**
  7771. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7772. */
  7773. get isPrefiltered(): boolean;
  7774. /**
  7775. * Get the current class name of the texture useful for serialization or dynamic coding.
  7776. * @returns "CubeTexture"
  7777. */
  7778. getClassName(): string;
  7779. /**
  7780. * Update the url (and optional buffer) of this texture if url was null during construction.
  7781. * @param url the url of the texture
  7782. * @param forcedExtension defines the extension to use
  7783. * @param onLoad callback called when the texture is loaded (defaults to null)
  7784. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7785. */
  7786. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7787. /**
  7788. * Delays loading of the cube texture
  7789. * @param forcedExtension defines the extension to use
  7790. */
  7791. delayLoad(forcedExtension?: string): void;
  7792. /**
  7793. * Returns the reflection texture matrix
  7794. * @returns the reflection texture matrix
  7795. */
  7796. getReflectionTextureMatrix(): Matrix;
  7797. /**
  7798. * Sets the reflection texture matrix
  7799. * @param value Reflection texture matrix
  7800. */
  7801. setReflectionTextureMatrix(value: Matrix): void;
  7802. /**
  7803. * Parses text to create a cube texture
  7804. * @param parsedTexture define the serialized text to read from
  7805. * @param scene defines the hosting scene
  7806. * @param rootUrl defines the root url of the cube texture
  7807. * @returns a cube texture
  7808. */
  7809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7810. /**
  7811. * Makes a clone, or deep copy, of the cube texture
  7812. * @returns a new cube texture
  7813. */
  7814. clone(): CubeTexture;
  7815. }
  7816. }
  7817. declare module BABYLON {
  7818. /**
  7819. * Manages the defines for the Material
  7820. */
  7821. export class MaterialDefines {
  7822. /** @hidden */
  7823. protected _keys: string[];
  7824. private _isDirty;
  7825. /** @hidden */
  7826. _renderId: number;
  7827. /** @hidden */
  7828. _areLightsDirty: boolean;
  7829. /** @hidden */
  7830. _areLightsDisposed: boolean;
  7831. /** @hidden */
  7832. _areAttributesDirty: boolean;
  7833. /** @hidden */
  7834. _areTexturesDirty: boolean;
  7835. /** @hidden */
  7836. _areFresnelDirty: boolean;
  7837. /** @hidden */
  7838. _areMiscDirty: boolean;
  7839. /** @hidden */
  7840. _areImageProcessingDirty: boolean;
  7841. /** @hidden */
  7842. _normals: boolean;
  7843. /** @hidden */
  7844. _uvs: boolean;
  7845. /** @hidden */
  7846. _needNormals: boolean;
  7847. /** @hidden */
  7848. _needUVs: boolean;
  7849. [id: string]: any;
  7850. /**
  7851. * Specifies if the material needs to be re-calculated
  7852. */
  7853. get isDirty(): boolean;
  7854. /**
  7855. * Marks the material to indicate that it has been re-calculated
  7856. */
  7857. markAsProcessed(): void;
  7858. /**
  7859. * Marks the material to indicate that it needs to be re-calculated
  7860. */
  7861. markAsUnprocessed(): void;
  7862. /**
  7863. * Marks the material to indicate all of its defines need to be re-calculated
  7864. */
  7865. markAllAsDirty(): void;
  7866. /**
  7867. * Marks the material to indicate that image processing needs to be re-calculated
  7868. */
  7869. markAsImageProcessingDirty(): void;
  7870. /**
  7871. * Marks the material to indicate the lights need to be re-calculated
  7872. * @param disposed Defines whether the light is dirty due to dispose or not
  7873. */
  7874. markAsLightDirty(disposed?: boolean): void;
  7875. /**
  7876. * Marks the attribute state as changed
  7877. */
  7878. markAsAttributesDirty(): void;
  7879. /**
  7880. * Marks the texture state as changed
  7881. */
  7882. markAsTexturesDirty(): void;
  7883. /**
  7884. * Marks the fresnel state as changed
  7885. */
  7886. markAsFresnelDirty(): void;
  7887. /**
  7888. * Marks the misc state as changed
  7889. */
  7890. markAsMiscDirty(): void;
  7891. /**
  7892. * Rebuilds the material defines
  7893. */
  7894. rebuild(): void;
  7895. /**
  7896. * Specifies if two material defines are equal
  7897. * @param other - A material define instance to compare to
  7898. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7899. */
  7900. isEqual(other: MaterialDefines): boolean;
  7901. /**
  7902. * Clones this instance's defines to another instance
  7903. * @param other - material defines to clone values to
  7904. */
  7905. cloneTo(other: MaterialDefines): void;
  7906. /**
  7907. * Resets the material define values
  7908. */
  7909. reset(): void;
  7910. /**
  7911. * Converts the material define values to a string
  7912. * @returns - String of material define information
  7913. */
  7914. toString(): string;
  7915. }
  7916. }
  7917. declare module BABYLON {
  7918. /**
  7919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7921. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7923. */
  7924. export class ColorCurves {
  7925. private _dirty;
  7926. private _tempColor;
  7927. private _globalCurve;
  7928. private _highlightsCurve;
  7929. private _midtonesCurve;
  7930. private _shadowsCurve;
  7931. private _positiveCurve;
  7932. private _negativeCurve;
  7933. private _globalHue;
  7934. private _globalDensity;
  7935. private _globalSaturation;
  7936. private _globalExposure;
  7937. /**
  7938. * Gets the global Hue value.
  7939. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7940. */
  7941. get globalHue(): number;
  7942. /**
  7943. * Sets the global Hue value.
  7944. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7945. */
  7946. set globalHue(value: number);
  7947. /**
  7948. * Gets the global Density value.
  7949. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7950. * Values less than zero provide a filter of opposite hue.
  7951. */
  7952. get globalDensity(): number;
  7953. /**
  7954. * Sets the global Density value.
  7955. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7956. * Values less than zero provide a filter of opposite hue.
  7957. */
  7958. set globalDensity(value: number);
  7959. /**
  7960. * Gets the global Saturation value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7962. */
  7963. get globalSaturation(): number;
  7964. /**
  7965. * Sets the global Saturation value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7967. */
  7968. set globalSaturation(value: number);
  7969. /**
  7970. * Gets the global Exposure value.
  7971. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7972. */
  7973. get globalExposure(): number;
  7974. /**
  7975. * Sets the global Exposure value.
  7976. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7977. */
  7978. set globalExposure(value: number);
  7979. private _highlightsHue;
  7980. private _highlightsDensity;
  7981. private _highlightsSaturation;
  7982. private _highlightsExposure;
  7983. /**
  7984. * Gets the highlights Hue value.
  7985. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7986. */
  7987. get highlightsHue(): number;
  7988. /**
  7989. * Sets the highlights Hue value.
  7990. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7991. */
  7992. set highlightsHue(value: number);
  7993. /**
  7994. * Gets the highlights Density value.
  7995. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7996. * Values less than zero provide a filter of opposite hue.
  7997. */
  7998. get highlightsDensity(): number;
  7999. /**
  8000. * Sets the highlights Density value.
  8001. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. set highlightsDensity(value: number);
  8005. /**
  8006. * Gets the highlights Saturation value.
  8007. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8008. */
  8009. get highlightsSaturation(): number;
  8010. /**
  8011. * Sets the highlights Saturation value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8013. */
  8014. set highlightsSaturation(value: number);
  8015. /**
  8016. * Gets the highlights Exposure value.
  8017. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8018. */
  8019. get highlightsExposure(): number;
  8020. /**
  8021. * Sets the highlights Exposure value.
  8022. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8023. */
  8024. set highlightsExposure(value: number);
  8025. private _midtonesHue;
  8026. private _midtonesDensity;
  8027. private _midtonesSaturation;
  8028. private _midtonesExposure;
  8029. /**
  8030. * Gets the midtones Hue value.
  8031. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8032. */
  8033. get midtonesHue(): number;
  8034. /**
  8035. * Sets the midtones Hue value.
  8036. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8037. */
  8038. set midtonesHue(value: number);
  8039. /**
  8040. * Gets the midtones Density value.
  8041. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8042. * Values less than zero provide a filter of opposite hue.
  8043. */
  8044. get midtonesDensity(): number;
  8045. /**
  8046. * Sets the midtones Density value.
  8047. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8048. * Values less than zero provide a filter of opposite hue.
  8049. */
  8050. set midtonesDensity(value: number);
  8051. /**
  8052. * Gets the midtones Saturation value.
  8053. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8054. */
  8055. get midtonesSaturation(): number;
  8056. /**
  8057. * Sets the midtones Saturation value.
  8058. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8059. */
  8060. set midtonesSaturation(value: number);
  8061. /**
  8062. * Gets the midtones Exposure value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8064. */
  8065. get midtonesExposure(): number;
  8066. /**
  8067. * Sets the midtones Exposure value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8069. */
  8070. set midtonesExposure(value: number);
  8071. private _shadowsHue;
  8072. private _shadowsDensity;
  8073. private _shadowsSaturation;
  8074. private _shadowsExposure;
  8075. /**
  8076. * Gets the shadows Hue value.
  8077. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8078. */
  8079. get shadowsHue(): number;
  8080. /**
  8081. * Sets the shadows Hue value.
  8082. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8083. */
  8084. set shadowsHue(value: number);
  8085. /**
  8086. * Gets the shadows Density value.
  8087. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8088. * Values less than zero provide a filter of opposite hue.
  8089. */
  8090. get shadowsDensity(): number;
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. set shadowsDensity(value: number);
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8100. */
  8101. get shadowsSaturation(): number;
  8102. /**
  8103. * Sets the shadows Saturation value.
  8104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8105. */
  8106. set shadowsSaturation(value: number);
  8107. /**
  8108. * Gets the shadows Exposure value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8110. */
  8111. get shadowsExposure(): number;
  8112. /**
  8113. * Sets the shadows Exposure value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8115. */
  8116. set shadowsExposure(value: number);
  8117. /**
  8118. * Returns the class name
  8119. * @returns The class name
  8120. */
  8121. getClassName(): string;
  8122. /**
  8123. * Binds the color curves to the shader.
  8124. * @param colorCurves The color curve to bind
  8125. * @param effect The effect to bind to
  8126. * @param positiveUniform The positive uniform shader parameter
  8127. * @param neutralUniform The neutral uniform shader parameter
  8128. * @param negativeUniform The negative uniform shader parameter
  8129. */
  8130. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8131. /**
  8132. * Prepare the list of uniforms associated with the ColorCurves effects.
  8133. * @param uniformsList The list of uniforms used in the effect
  8134. */
  8135. static PrepareUniforms(uniformsList: string[]): void;
  8136. /**
  8137. * Returns color grading data based on a hue, density, saturation and exposure value.
  8138. * @param filterHue The hue of the color filter.
  8139. * @param filterDensity The density of the color filter.
  8140. * @param saturation The saturation.
  8141. * @param exposure The exposure.
  8142. * @param result The result data container.
  8143. */
  8144. private getColorGradingDataToRef;
  8145. /**
  8146. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8147. * @param value The input slider value in range [-100,100].
  8148. * @returns Adjusted value.
  8149. */
  8150. private static applyColorGradingSliderNonlinear;
  8151. /**
  8152. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8153. * @param hue The hue (H) input.
  8154. * @param saturation The saturation (S) input.
  8155. * @param brightness The brightness (B) input.
  8156. * @result An RGBA color represented as Vector4.
  8157. */
  8158. private static fromHSBToRef;
  8159. /**
  8160. * Returns a value clamped between min and max
  8161. * @param value The value to clamp
  8162. * @param min The minimum of value
  8163. * @param max The maximum of value
  8164. * @returns The clamped value.
  8165. */
  8166. private static clamp;
  8167. /**
  8168. * Clones the current color curve instance.
  8169. * @return The cloned curves
  8170. */
  8171. clone(): ColorCurves;
  8172. /**
  8173. * Serializes the current color curve instance to a json representation.
  8174. * @return a JSON representation
  8175. */
  8176. serialize(): any;
  8177. /**
  8178. * Parses the color curve from a json representation.
  8179. * @param source the JSON source to parse
  8180. * @return The parsed curves
  8181. */
  8182. static Parse(source: any): ColorCurves;
  8183. }
  8184. }
  8185. declare module BABYLON {
  8186. /**
  8187. * Interface to follow in your material defines to integrate easily the
  8188. * Image proccessing functions.
  8189. * @hidden
  8190. */
  8191. export interface IImageProcessingConfigurationDefines {
  8192. IMAGEPROCESSING: boolean;
  8193. VIGNETTE: boolean;
  8194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8195. VIGNETTEBLENDMODEOPAQUE: boolean;
  8196. TONEMAPPING: boolean;
  8197. TONEMAPPING_ACES: boolean;
  8198. CONTRAST: boolean;
  8199. EXPOSURE: boolean;
  8200. COLORCURVES: boolean;
  8201. COLORGRADING: boolean;
  8202. COLORGRADING3D: boolean;
  8203. SAMPLER3DGREENDEPTH: boolean;
  8204. SAMPLER3DBGRMAP: boolean;
  8205. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8206. }
  8207. /**
  8208. * @hidden
  8209. */
  8210. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8211. IMAGEPROCESSING: boolean;
  8212. VIGNETTE: boolean;
  8213. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8214. VIGNETTEBLENDMODEOPAQUE: boolean;
  8215. TONEMAPPING: boolean;
  8216. TONEMAPPING_ACES: boolean;
  8217. CONTRAST: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. EXPOSURE: boolean;
  8225. constructor();
  8226. }
  8227. /**
  8228. * This groups together the common properties used for image processing either in direct forward pass
  8229. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8230. * or not.
  8231. */
  8232. export class ImageProcessingConfiguration {
  8233. /**
  8234. * Default tone mapping applied in BabylonJS.
  8235. */
  8236. static readonly TONEMAPPING_STANDARD: number;
  8237. /**
  8238. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8239. * to other engines rendering to increase portability.
  8240. */
  8241. static readonly TONEMAPPING_ACES: number;
  8242. /**
  8243. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8244. */
  8245. colorCurves: Nullable<ColorCurves>;
  8246. private _colorCurvesEnabled;
  8247. /**
  8248. * Gets wether the color curves effect is enabled.
  8249. */
  8250. get colorCurvesEnabled(): boolean;
  8251. /**
  8252. * Sets wether the color curves effect is enabled.
  8253. */
  8254. set colorCurvesEnabled(value: boolean);
  8255. private _colorGradingTexture;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. get colorGradingTexture(): Nullable<BaseTexture>;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. set colorGradingTexture(value: Nullable<BaseTexture>);
  8264. private _colorGradingEnabled;
  8265. /**
  8266. * Gets wether the color grading effect is enabled.
  8267. */
  8268. get colorGradingEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is enabled.
  8271. */
  8272. set colorGradingEnabled(value: boolean);
  8273. private _colorGradingWithGreenDepth;
  8274. /**
  8275. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. get colorGradingWithGreenDepth(): boolean;
  8278. /**
  8279. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8280. */
  8281. set colorGradingWithGreenDepth(value: boolean);
  8282. private _colorGradingBGR;
  8283. /**
  8284. * Gets wether the color grading texture contains BGR values.
  8285. */
  8286. get colorGradingBGR(): boolean;
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. set colorGradingBGR(value: boolean);
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. get exposure(): number;
  8297. /**
  8298. * Sets the Exposure used in the effect.
  8299. */
  8300. set exposure(value: number);
  8301. private _toneMappingEnabled;
  8302. /**
  8303. * Gets wether the tone mapping effect is enabled.
  8304. */
  8305. get toneMappingEnabled(): boolean;
  8306. /**
  8307. * Sets wether the tone mapping effect is enabled.
  8308. */
  8309. set toneMappingEnabled(value: boolean);
  8310. private _toneMappingType;
  8311. /**
  8312. * Gets the type of tone mapping effect.
  8313. */
  8314. get toneMappingType(): number;
  8315. /**
  8316. * Sets the type of tone mapping effect used in BabylonJS.
  8317. */
  8318. set toneMappingType(value: number);
  8319. protected _contrast: number;
  8320. /**
  8321. * Gets the contrast used in the effect.
  8322. */
  8323. get contrast(): number;
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. set contrast(value: number);
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. get vignetteBlendMode(): number;
  8358. /**
  8359. * Sets the vignette blend mode allowing different kind of effect.
  8360. */
  8361. set vignetteBlendMode(value: number);
  8362. private _vignetteEnabled;
  8363. /**
  8364. * Gets wether the vignette effect is enabled.
  8365. */
  8366. get vignetteEnabled(): boolean;
  8367. /**
  8368. * Sets wether the vignette effect is enabled.
  8369. */
  8370. set vignetteEnabled(value: boolean);
  8371. private _applyByPostProcess;
  8372. /**
  8373. * Gets wether the image processing is applied through a post process or not.
  8374. */
  8375. get applyByPostProcess(): boolean;
  8376. /**
  8377. * Sets wether the image processing is applied through a post process or not.
  8378. */
  8379. set applyByPostProcess(value: boolean);
  8380. private _isEnabled;
  8381. /**
  8382. * Gets wether the image processing is enabled or not.
  8383. */
  8384. get isEnabled(): boolean;
  8385. /**
  8386. * Sets wether the image processing is enabled or not.
  8387. */
  8388. set isEnabled(value: boolean);
  8389. /**
  8390. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8391. */
  8392. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8393. /**
  8394. * Method called each time the image processing information changes requires to recompile the effect.
  8395. */
  8396. protected _updateParameters(): void;
  8397. /**
  8398. * Gets the current class name.
  8399. * @return "ImageProcessingConfiguration"
  8400. */
  8401. getClassName(): string;
  8402. /**
  8403. * Prepare the list of uniforms associated with the Image Processing effects.
  8404. * @param uniforms The list of uniforms used in the effect
  8405. * @param defines the list of defines currently in use
  8406. */
  8407. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8408. /**
  8409. * Prepare the list of samplers associated with the Image Processing effects.
  8410. * @param samplersList The list of uniforms used in the effect
  8411. * @param defines the list of defines currently in use
  8412. */
  8413. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8414. /**
  8415. * Prepare the list of defines associated to the shader.
  8416. * @param defines the list of defines to complete
  8417. * @param forPostProcess Define if we are currently in post process mode or not
  8418. */
  8419. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8420. /**
  8421. * Returns true if all the image processing information are ready.
  8422. * @returns True if ready, otherwise, false
  8423. */
  8424. isReady(): boolean;
  8425. /**
  8426. * Binds the image processing to the shader.
  8427. * @param effect The effect to bind to
  8428. * @param overrideAspectRatio Override the aspect ratio of the effect
  8429. */
  8430. bind(effect: Effect, overrideAspectRatio?: number): void;
  8431. /**
  8432. * Clones the current image processing instance.
  8433. * @return The cloned image processing
  8434. */
  8435. clone(): ImageProcessingConfiguration;
  8436. /**
  8437. * Serializes the current image processing instance to a json representation.
  8438. * @return a JSON representation
  8439. */
  8440. serialize(): any;
  8441. /**
  8442. * Parses the image processing from a json representation.
  8443. * @param source the JSON source to parse
  8444. * @return The parsed image processing
  8445. */
  8446. static Parse(source: any): ImageProcessingConfiguration;
  8447. private static _VIGNETTEMODE_MULTIPLY;
  8448. private static _VIGNETTEMODE_OPAQUE;
  8449. /**
  8450. * Used to apply the vignette as a mix with the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_MULTIPLY(): number;
  8453. /**
  8454. * Used to apply the vignette as a replacement of the pixel color.
  8455. */
  8456. static get VIGNETTEMODE_OPAQUE(): number;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /** @hidden */
  8461. export var postprocessVertexShader: {
  8462. name: string;
  8463. shader: string;
  8464. };
  8465. }
  8466. declare module BABYLON {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. layers?: number;
  8478. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8479. /**
  8480. * Creates a depth stencil texture.
  8481. * This is only available in WebGL 2 or with the depth texture extension available.
  8482. * @param size The size of face edge in the texture.
  8483. * @param options The options defining the texture.
  8484. * @returns The texture
  8485. */
  8486. createDepthStencilTexture(size: number | {
  8487. width: number;
  8488. height: number;
  8489. layers?: number;
  8490. }, options: DepthTextureCreationOptions): InternalTexture;
  8491. /** @hidden */
  8492. _createDepthStencilTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: DepthTextureCreationOptions): InternalTexture;
  8497. }
  8498. }
  8499. declare module BABYLON {
  8500. /** Defines supported spaces */
  8501. export enum Space {
  8502. /** Local (object) space */
  8503. LOCAL = 0,
  8504. /** World space */
  8505. WORLD = 1,
  8506. /** Bone space */
  8507. BONE = 2
  8508. }
  8509. /** Defines the 3 main axes */
  8510. export class Axis {
  8511. /** X axis */
  8512. static X: Vector3;
  8513. /** Y axis */
  8514. static Y: Vector3;
  8515. /** Z axis */
  8516. static Z: Vector3;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. */
  8525. export class TargetCamera extends Camera {
  8526. private static _RigCamTransformMatrix;
  8527. private static _TargetTransformMatrix;
  8528. private static _TargetFocalPoint;
  8529. /**
  8530. * Define the current direction the camera is moving to
  8531. */
  8532. cameraDirection: Vector3;
  8533. /**
  8534. * Define the current rotation the camera is rotating to
  8535. */
  8536. cameraRotation: Vector2;
  8537. /**
  8538. * When set, the up vector of the camera will be updated by the rotation of the camera
  8539. */
  8540. updateUpVectorFromRotation: boolean;
  8541. private _tmpQuaternion;
  8542. /**
  8543. * Define the current rotation of the camera
  8544. */
  8545. rotation: Vector3;
  8546. /**
  8547. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8548. */
  8549. rotationQuaternion: Quaternion;
  8550. /**
  8551. * Define the current speed of the camera
  8552. */
  8553. speed: number;
  8554. /**
  8555. * Add constraint to the camera to prevent it to move freely in all directions and
  8556. * around all axis.
  8557. */
  8558. noRotationConstraint: boolean;
  8559. /**
  8560. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8561. * panning
  8562. */
  8563. invertRotation: boolean;
  8564. /**
  8565. * Speed multiplier for inverse camera panning
  8566. */
  8567. inverseRotationSpeed: number;
  8568. /**
  8569. * Define the current target of the camera as an object or a position.
  8570. */
  8571. lockedTarget: any;
  8572. /** @hidden */
  8573. _currentTarget: Vector3;
  8574. /** @hidden */
  8575. _initialFocalDistance: number;
  8576. /** @hidden */
  8577. _viewMatrix: Matrix;
  8578. /** @hidden */
  8579. _camMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraTransformMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraRotationMatrix: Matrix;
  8584. /** @hidden */
  8585. _referencePoint: Vector3;
  8586. /** @hidden */
  8587. _transformedReferencePoint: Vector3;
  8588. protected _globalCurrentTarget: Vector3;
  8589. protected _globalCurrentUpVector: Vector3;
  8590. /** @hidden */
  8591. _reset: () => void;
  8592. private _defaultUp;
  8593. /**
  8594. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8595. * This is the base of the follow, arc rotate cameras and Free camera
  8596. * @see http://doc.babylonjs.com/features/cameras
  8597. * @param name Defines the name of the camera in the scene
  8598. * @param position Defines the start position of the camera in the scene
  8599. * @param scene Defines the scene the camera belongs to
  8600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8601. */
  8602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8603. /**
  8604. * Gets the position in front of the camera at a given distance.
  8605. * @param distance The distance from the camera we want the position to be
  8606. * @returns the position
  8607. */
  8608. getFrontPosition(distance: number): Vector3;
  8609. /** @hidden */
  8610. _getLockedTargetPosition(): Nullable<Vector3>;
  8611. private _storedPosition;
  8612. private _storedRotation;
  8613. private _storedRotationQuaternion;
  8614. /**
  8615. * Store current camera state of the camera (fov, position, rotation, etc..)
  8616. * @returns the camera
  8617. */
  8618. storeState(): Camera;
  8619. /**
  8620. * Restored camera state. You must call storeState() first
  8621. * @returns whether it was successful or not
  8622. * @hidden
  8623. */
  8624. _restoreStateValues(): boolean;
  8625. /** @hidden */
  8626. _initCache(): void;
  8627. /** @hidden */
  8628. _updateCache(ignoreParentClass?: boolean): void;
  8629. /** @hidden */
  8630. _isSynchronizedViewMatrix(): boolean;
  8631. /** @hidden */
  8632. _computeLocalCameraSpeed(): number;
  8633. /**
  8634. * Defines the target the camera should look at.
  8635. * @param target Defines the new target as a Vector or a mesh
  8636. */
  8637. setTarget(target: Vector3): void;
  8638. /**
  8639. * Return the current target position of the camera. This value is expressed in local space.
  8640. * @returns the target position
  8641. */
  8642. getTarget(): Vector3;
  8643. /** @hidden */
  8644. _decideIfNeedsToMove(): boolean;
  8645. /** @hidden */
  8646. _updatePosition(): void;
  8647. /** @hidden */
  8648. _checkInputs(): void;
  8649. protected _updateCameraRotationMatrix(): void;
  8650. /**
  8651. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8652. * @returns the current camera
  8653. */
  8654. private _rotateUpVectorWithCameraRotationMatrix;
  8655. private _cachedRotationZ;
  8656. private _cachedQuaternionRotationZ;
  8657. /** @hidden */
  8658. _getViewMatrix(): Matrix;
  8659. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8660. /**
  8661. * @hidden
  8662. */
  8663. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8664. /**
  8665. * @hidden
  8666. */
  8667. _updateRigCameras(): void;
  8668. private _getRigCamPositionAndTarget;
  8669. /**
  8670. * Gets the current object class name.
  8671. * @return the class name
  8672. */
  8673. getClassName(): string;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Gather the list of keyboard event types as constants.
  8679. */
  8680. export class KeyboardEventTypes {
  8681. /**
  8682. * The keydown event is fired when a key becomes active (pressed).
  8683. */
  8684. static readonly KEYDOWN: number;
  8685. /**
  8686. * The keyup event is fired when a key has been released.
  8687. */
  8688. static readonly KEYUP: number;
  8689. }
  8690. /**
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. */
  8693. export class KeyboardInfo {
  8694. /**
  8695. * Defines the type of event (KeyboardEventTypes)
  8696. */
  8697. type: number;
  8698. /**
  8699. * Defines the related dom event
  8700. */
  8701. event: KeyboardEvent;
  8702. /**
  8703. * Instantiates a new keyboard info.
  8704. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. /**
  8719. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8720. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8721. */
  8722. export class KeyboardInfoPre extends KeyboardInfo {
  8723. /**
  8724. * Defines the type of event (KeyboardEventTypes)
  8725. */
  8726. type: number;
  8727. /**
  8728. * Defines the related dom event
  8729. */
  8730. event: KeyboardEvent;
  8731. /**
  8732. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8733. */
  8734. skipOnPointerObservable: boolean;
  8735. /**
  8736. * Instantiates a new keyboard pre info.
  8737. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8738. * @param type Defines the type of event (KeyboardEventTypes)
  8739. * @param event Defines the related dom event
  8740. */
  8741. constructor(
  8742. /**
  8743. * Defines the type of event (KeyboardEventTypes)
  8744. */
  8745. type: number,
  8746. /**
  8747. * Defines the related dom event
  8748. */
  8749. event: KeyboardEvent);
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Manage the keyboard inputs to control the movement of a free camera.
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. */
  8757. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8758. /**
  8759. * Defines the camera the input is attached to.
  8760. */
  8761. camera: FreeCamera;
  8762. /**
  8763. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8764. */
  8765. keysUp: number[];
  8766. /**
  8767. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8768. */
  8769. keysUpward: number[];
  8770. /**
  8771. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8772. */
  8773. keysDown: number[];
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8776. */
  8777. keysDownward: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8780. */
  8781. keysLeft: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8784. */
  8785. keysRight: number[];
  8786. private _keys;
  8787. private _onCanvasBlurObserver;
  8788. private _onKeyboardObserver;
  8789. private _engine;
  8790. private _scene;
  8791. /**
  8792. * Attach the input controls to a specific dom element to get the input from.
  8793. * @param element Defines the element the controls should be listened from
  8794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8795. */
  8796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8797. /**
  8798. * Detach the current controls from the specified dom element.
  8799. * @param element Defines the element to stop listening the inputs from
  8800. */
  8801. detachControl(element: Nullable<HTMLElement>): void;
  8802. /**
  8803. * Update the current camera state depending on the inputs that have been used this frame.
  8804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8805. */
  8806. checkInputs(): void;
  8807. /**
  8808. * Gets the class name of the current intput.
  8809. * @returns the class name
  8810. */
  8811. getClassName(): string;
  8812. /** @hidden */
  8813. _onLostFocus(): void;
  8814. /**
  8815. * Get the friendly name associated with the input class.
  8816. * @returns the input friendly name
  8817. */
  8818. getSimpleName(): string;
  8819. }
  8820. }
  8821. declare module BABYLON {
  8822. /**
  8823. * Interface describing all the common properties and methods a shadow light needs to implement.
  8824. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8825. * as well as binding the different shadow properties to the effects.
  8826. */
  8827. export interface IShadowLight extends Light {
  8828. /**
  8829. * The light id in the scene (used in scene.findLighById for instance)
  8830. */
  8831. id: string;
  8832. /**
  8833. * The position the shdow will be casted from.
  8834. */
  8835. position: Vector3;
  8836. /**
  8837. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8838. */
  8839. direction: Vector3;
  8840. /**
  8841. * The transformed position. Position of the light in world space taking parenting in account.
  8842. */
  8843. transformedPosition: Vector3;
  8844. /**
  8845. * The transformed direction. Direction of the light in world space taking parenting in account.
  8846. */
  8847. transformedDirection: Vector3;
  8848. /**
  8849. * The friendly name of the light in the scene.
  8850. */
  8851. name: string;
  8852. /**
  8853. * Defines the shadow projection clipping minimum z value.
  8854. */
  8855. shadowMinZ: number;
  8856. /**
  8857. * Defines the shadow projection clipping maximum z value.
  8858. */
  8859. shadowMaxZ: number;
  8860. /**
  8861. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8862. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8863. */
  8864. computeTransformedInformation(): boolean;
  8865. /**
  8866. * Gets the scene the light belongs to.
  8867. * @returns The scene
  8868. */
  8869. getScene(): Scene;
  8870. /**
  8871. * Callback defining a custom Projection Matrix Builder.
  8872. * This can be used to override the default projection matrix computation.
  8873. */
  8874. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8875. /**
  8876. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8877. * @param matrix The materix to updated with the projection information
  8878. * @param viewMatrix The transform matrix of the light
  8879. * @param renderList The list of mesh to render in the map
  8880. * @returns The current light
  8881. */
  8882. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8883. /**
  8884. * Gets the current depth scale used in ESM.
  8885. * @returns The scale
  8886. */
  8887. getDepthScale(): number;
  8888. /**
  8889. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8890. * @returns true if a cube texture needs to be use
  8891. */
  8892. needCube(): boolean;
  8893. /**
  8894. * Detects if the projection matrix requires to be recomputed this frame.
  8895. * @returns true if it requires to be recomputed otherwise, false.
  8896. */
  8897. needProjectionMatrixCompute(): boolean;
  8898. /**
  8899. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8900. */
  8901. forceProjectionMatrixCompute(): void;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Gets the minZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the min for
  8911. * @returns the depth min z
  8912. */
  8913. getDepthMinZ(activeCamera: Camera): number;
  8914. /**
  8915. * Gets the maxZ used for shadow according to both the scene and the light.
  8916. * @param activeCamera The camera we are returning the max for
  8917. * @returns the depth max z
  8918. */
  8919. getDepthMaxZ(activeCamera: Camera): number;
  8920. }
  8921. /**
  8922. * Base implementation IShadowLight
  8923. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8924. */
  8925. export abstract class ShadowLight extends Light implements IShadowLight {
  8926. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8927. protected _position: Vector3;
  8928. protected _setPosition(value: Vector3): void;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. get position(): Vector3;
  8934. /**
  8935. * Sets the position the shadow will be casted from. Also use as the light position for both
  8936. * point and spot lights.
  8937. */
  8938. set position(value: Vector3);
  8939. protected _direction: Vector3;
  8940. protected _setDirection(value: Vector3): void;
  8941. /**
  8942. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. get direction(): Vector3;
  8946. /**
  8947. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8948. * Also use as the light direction on spot and directional lights.
  8949. */
  8950. set direction(value: Vector3);
  8951. protected _shadowMinZ: number;
  8952. /**
  8953. * Gets the shadow projection clipping minimum z value.
  8954. */
  8955. get shadowMinZ(): number;
  8956. /**
  8957. * Sets the shadow projection clipping minimum z value.
  8958. */
  8959. set shadowMinZ(value: number);
  8960. protected _shadowMaxZ: number;
  8961. /**
  8962. * Sets the shadow projection clipping maximum z value.
  8963. */
  8964. get shadowMaxZ(): number;
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. set shadowMaxZ(value: number);
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module BABYLON {
  9062. /**
  9063. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9064. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9065. */
  9066. export class EffectFallbacks implements IEffectFallbacks {
  9067. private _defines;
  9068. private _currentRank;
  9069. private _maxRank;
  9070. private _mesh;
  9071. /**
  9072. * Removes the fallback from the bound mesh.
  9073. */
  9074. unBindMesh(): void;
  9075. /**
  9076. * Adds a fallback on the specified property.
  9077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9078. * @param define The name of the define in the shader
  9079. */
  9080. addFallback(rank: number, define: string): void;
  9081. /**
  9082. * Sets the mesh to use CPU skinning when needing to fallback.
  9083. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9084. * @param mesh The mesh to use the fallbacks.
  9085. */
  9086. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9087. /**
  9088. * Checks to see if more fallbacks are still availible.
  9089. */
  9090. get hasMoreFallbacks(): boolean;
  9091. /**
  9092. * Removes the defines that should be removed when falling back.
  9093. * @param currentDefines defines the current define statements for the shader.
  9094. * @param effect defines the current effect we try to compile
  9095. * @returns The resulting defines with defines of the current rank removed.
  9096. */
  9097. reduce(currentDefines: string, effect: Effect): string;
  9098. }
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * "Static Class" containing the most commonly used helper while dealing with material for
  9103. * rendering purpose.
  9104. *
  9105. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9106. *
  9107. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9108. */
  9109. export class MaterialHelper {
  9110. /**
  9111. * Bind the current view position to an effect.
  9112. * @param effect The effect to be bound
  9113. * @param scene The scene the eyes position is used from
  9114. */
  9115. static BindEyePosition(effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Helps preparing the defines values about the UVs in used in the effect.
  9118. * UVs are shared as much as we can accross channels in the shaders.
  9119. * @param texture The texture we are preparing the UVs for
  9120. * @param defines The defines to update
  9121. * @param key The channel key "diffuse", "specular"... used in the shader
  9122. */
  9123. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9124. /**
  9125. * Binds a texture matrix value to its corrsponding uniform
  9126. * @param texture The texture to bind the matrix for
  9127. * @param uniformBuffer The uniform buffer receivin the data
  9128. * @param key The channel key "diffuse", "specular"... used in the shader
  9129. */
  9130. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9131. /**
  9132. * Gets the current status of the fog (should it be enabled?)
  9133. * @param mesh defines the mesh to evaluate for fog support
  9134. * @param scene defines the hosting scene
  9135. * @returns true if fog must be enabled
  9136. */
  9137. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9138. /**
  9139. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9140. * @param mesh defines the current mesh
  9141. * @param scene defines the current scene
  9142. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9143. * @param pointsCloud defines if point cloud rendering has to be turned on
  9144. * @param fogEnabled defines if fog has to be turned on
  9145. * @param alphaTest defines if alpha testing has to be turned on
  9146. * @param defines defines the current list of defines
  9147. */
  9148. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9149. /**
  9150. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9151. * @param scene defines the current scene
  9152. * @param engine defines the current engine
  9153. * @param defines specifies the list of active defines
  9154. * @param useInstances defines if instances have to be turned on
  9155. * @param useClipPlane defines if clip plane have to be turned on
  9156. */
  9157. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9158. /**
  9159. * Prepares the defines for bones
  9160. * @param mesh The mesh containing the geometry data we will draw
  9161. * @param defines The defines to update
  9162. */
  9163. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9164. /**
  9165. * Prepares the defines for morph targets
  9166. * @param mesh The mesh containing the geometry data we will draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9170. /**
  9171. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9172. * @param mesh The mesh containing the geometry data we will draw
  9173. * @param defines The defines to update
  9174. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9175. * @param useBones Precise whether bones should be used or not (override mesh info)
  9176. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9177. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9178. * @returns false if defines are considered not dirty and have not been checked
  9179. */
  9180. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9181. /**
  9182. * Prepares the defines related to multiview
  9183. * @param scene The scene we are intending to draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param light The light the effect is compiling for
  9192. * @param lightIndex The index of the light
  9193. * @param defines The defines to update
  9194. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9195. * @param state Defines the current state regarding what is needed (normals, etc...)
  9196. */
  9197. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9198. needNormals: boolean;
  9199. needRebuild: boolean;
  9200. shadowEnabled: boolean;
  9201. specularEnabled: boolean;
  9202. lightmapMode: boolean;
  9203. }): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param defines The defines to update
  9209. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9210. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9211. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9212. * @returns true if normals will be required for the rest of the effect
  9213. */
  9214. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9217. * @param lightIndex defines the light index
  9218. * @param uniformsList The uniform list
  9219. * @param samplersList The sampler list
  9220. * @param projectedLightTexture defines if projected texture must be used
  9221. * @param uniformBuffersList defines an optional list of uniform buffers
  9222. */
  9223. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9224. /**
  9225. * Prepares the uniforms and samplers list to be used in the effect
  9226. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9227. * @param samplersList The sampler list
  9228. * @param defines The defines helping in the list generation
  9229. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9230. */
  9231. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9232. /**
  9233. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9234. * @param defines The defines to update while falling back
  9235. * @param fallbacks The authorized effect fallbacks
  9236. * @param maxSimultaneousLights The maximum number of lights allowed
  9237. * @param rank the current rank of the Effect
  9238. * @returns The newly affected rank
  9239. */
  9240. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9241. private static _TmpMorphInfluencers;
  9242. /**
  9243. * Prepares the list of attributes required for morph targets according to the effect defines.
  9244. * @param attribs The current list of supported attribs
  9245. * @param mesh The mesh to prepare the morph targets attributes for
  9246. * @param influencers The number of influencers
  9247. */
  9248. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9249. /**
  9250. * Prepares the list of attributes required for morph targets according to the effect defines.
  9251. * @param attribs The current list of supported attribs
  9252. * @param mesh The mesh to prepare the morph targets attributes for
  9253. * @param defines The current Defines of the effect
  9254. */
  9255. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9256. /**
  9257. * Prepares the list of attributes required for bones according to the effect defines.
  9258. * @param attribs The current list of supported attribs
  9259. * @param mesh The mesh to prepare the bones attributes for
  9260. * @param defines The current Defines of the effect
  9261. * @param fallbacks The current efffect fallback strategy
  9262. */
  9263. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9264. /**
  9265. * Check and prepare the list of attributes required for instances according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param defines The current MaterialDefines of the effect
  9268. */
  9269. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9270. /**
  9271. * Add the list of attributes required for instances to the attribs array.
  9272. * @param attribs The current list of supported attribs
  9273. */
  9274. static PushAttributesForInstances(attribs: string[]): void;
  9275. /**
  9276. * Binds the light information to the effect.
  9277. * @param light The light containing the generator
  9278. * @param effect The effect we are binding the data to
  9279. * @param lightIndex The light index in the effect used to render
  9280. */
  9281. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param light Light to bind
  9285. * @param lightIndex Light index
  9286. * @param scene The scene where the light belongs to
  9287. * @param effect The effect we are binding the data to
  9288. * @param useSpecular Defines if specular is supported
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9292. /**
  9293. * Binds the lights information from the scene to the effect for the given mesh.
  9294. * @param scene The scene the lights belongs to
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. * @param defines The generated defines for the effect
  9298. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9299. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9300. */
  9301. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9302. private static _tempFogColor;
  9303. /**
  9304. * Binds the fog information from the scene to the effect for the given mesh.
  9305. * @param scene The scene the lights belongs to
  9306. * @param mesh The mesh we are binding the information to render
  9307. * @param effect The effect we are binding the data to
  9308. * @param linearSpace Defines if the fog effect is applied in linear space
  9309. */
  9310. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9311. /**
  9312. * Binds the bones information from the mesh to the effect.
  9313. * @param mesh The mesh we are binding the information to render
  9314. * @param effect The effect we are binding the data to
  9315. */
  9316. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9317. /**
  9318. * Binds the morph targets information from the mesh to the effect.
  9319. * @param abstractMesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9323. /**
  9324. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9325. * @param defines The generated defines used in the effect
  9326. * @param effect The effect we are binding the data to
  9327. * @param scene The scene we are willing to render with logarithmic scale for
  9328. */
  9329. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9330. /**
  9331. * Binds the clip plane information from the scene to the effect.
  9332. * @param scene The scene the clip plane information are extracted from
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindClipPlane(effect: Effect, scene: Scene): void;
  9336. }
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var packingFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var clipPlaneFragmentDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneFragment: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var morphTargetsVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var instancesVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var bonesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var clipPlaneVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var shadowMapVertexShader: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var depthBoxBlurPixelShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /**
  9452. * Class representing a ray with position and direction
  9453. */
  9454. export class Ray {
  9455. /** origin point */
  9456. origin: Vector3;
  9457. /** direction */
  9458. direction: Vector3;
  9459. /** length of the ray */
  9460. length: number;
  9461. private static readonly TmpVector3;
  9462. private _tmpRay;
  9463. /**
  9464. * Creates a new ray
  9465. * @param origin origin point
  9466. * @param direction direction
  9467. * @param length length of the ray
  9468. */
  9469. constructor(
  9470. /** origin point */
  9471. origin: Vector3,
  9472. /** direction */
  9473. direction: Vector3,
  9474. /** length of the ray */
  9475. length?: number);
  9476. /**
  9477. * Checks if the ray intersects a box
  9478. * @param minimum bound of the box
  9479. * @param maximum bound of the box
  9480. * @param intersectionTreshold extra extend to be added to the box in all direction
  9481. * @returns if the box was hit
  9482. */
  9483. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9484. /**
  9485. * Checks if the ray intersects a box
  9486. * @param box the bounding box to check
  9487. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9488. * @returns if the box was hit
  9489. */
  9490. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9491. /**
  9492. * If the ray hits a sphere
  9493. * @param sphere the bounding sphere to check
  9494. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9495. * @returns true if it hits the sphere
  9496. */
  9497. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9498. /**
  9499. * If the ray hits a triange
  9500. * @param vertex0 triangle vertex
  9501. * @param vertex1 triangle vertex
  9502. * @param vertex2 triangle vertex
  9503. * @returns intersection information if hit
  9504. */
  9505. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9506. /**
  9507. * Checks if ray intersects a plane
  9508. * @param plane the plane to check
  9509. * @returns the distance away it was hit
  9510. */
  9511. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9512. /**
  9513. * Calculate the intercept of a ray on a given axis
  9514. * @param axis to check 'x' | 'y' | 'z'
  9515. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9516. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9517. */
  9518. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9519. /**
  9520. * Checks if ray intersects a mesh
  9521. * @param mesh the mesh to check
  9522. * @param fastCheck if only the bounding box should checked
  9523. * @returns picking info of the intersecton
  9524. */
  9525. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9526. /**
  9527. * Checks if ray intersects a mesh
  9528. * @param meshes the meshes to check
  9529. * @param fastCheck if only the bounding box should checked
  9530. * @param results array to store result in
  9531. * @returns Array of picking infos
  9532. */
  9533. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9534. private _comparePickingInfo;
  9535. private static smallnum;
  9536. private static rayl;
  9537. /**
  9538. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9539. * @param sega the first point of the segment to test the intersection against
  9540. * @param segb the second point of the segment to test the intersection against
  9541. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9542. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9543. */
  9544. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9545. /**
  9546. * Update the ray from viewport position
  9547. * @param x position
  9548. * @param y y position
  9549. * @param viewportWidth viewport width
  9550. * @param viewportHeight viewport height
  9551. * @param world world matrix
  9552. * @param view view matrix
  9553. * @param projection projection matrix
  9554. * @returns this ray updated
  9555. */
  9556. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9557. /**
  9558. * Creates a ray with origin and direction of 0,0,0
  9559. * @returns the new ray
  9560. */
  9561. static Zero(): Ray;
  9562. /**
  9563. * Creates a new ray from screen space and viewport
  9564. * @param x position
  9565. * @param y y position
  9566. * @param viewportWidth viewport width
  9567. * @param viewportHeight viewport height
  9568. * @param world world matrix
  9569. * @param view view matrix
  9570. * @param projection projection matrix
  9571. * @returns new ray
  9572. */
  9573. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9574. /**
  9575. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9576. * transformed to the given world matrix.
  9577. * @param origin The origin point
  9578. * @param end The end point
  9579. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9580. * @returns the new ray
  9581. */
  9582. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9583. /**
  9584. * Transforms a ray by a matrix
  9585. * @param ray ray to transform
  9586. * @param matrix matrix to apply
  9587. * @returns the resulting new ray
  9588. */
  9589. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9590. /**
  9591. * Transforms a ray by a matrix
  9592. * @param ray ray to transform
  9593. * @param matrix matrix to apply
  9594. * @param result ray to store result in
  9595. */
  9596. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9597. /**
  9598. * Unproject a ray from screen space to object space
  9599. * @param sourceX defines the screen space x coordinate to use
  9600. * @param sourceY defines the screen space y coordinate to use
  9601. * @param viewportWidth defines the current width of the viewport
  9602. * @param viewportHeight defines the current height of the viewport
  9603. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9604. * @param view defines the view matrix to use
  9605. * @param projection defines the projection matrix to use
  9606. */
  9607. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9608. }
  9609. /**
  9610. * Type used to define predicate used to select faces when a mesh intersection is detected
  9611. */
  9612. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9613. interface Scene {
  9614. /** @hidden */
  9615. _tempPickingRay: Nullable<Ray>;
  9616. /** @hidden */
  9617. _cachedRayForTransform: Ray;
  9618. /** @hidden */
  9619. _pickWithRayInverseMatrix: Matrix;
  9620. /** @hidden */
  9621. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9622. /** @hidden */
  9623. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9624. }
  9625. }
  9626. declare module BABYLON {
  9627. /**
  9628. * Groups all the scene component constants in one place to ease maintenance.
  9629. * @hidden
  9630. */
  9631. export class SceneComponentConstants {
  9632. static readonly NAME_EFFECTLAYER: string;
  9633. static readonly NAME_LAYER: string;
  9634. static readonly NAME_LENSFLARESYSTEM: string;
  9635. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9636. static readonly NAME_PARTICLESYSTEM: string;
  9637. static readonly NAME_GAMEPAD: string;
  9638. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9639. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9640. static readonly NAME_DEPTHRENDERER: string;
  9641. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9642. static readonly NAME_SPRITE: string;
  9643. static readonly NAME_OUTLINERENDERER: string;
  9644. static readonly NAME_PROCEDURALTEXTURE: string;
  9645. static readonly NAME_SHADOWGENERATOR: string;
  9646. static readonly NAME_OCTREE: string;
  9647. static readonly NAME_PHYSICSENGINE: string;
  9648. static readonly NAME_AUDIO: string;
  9649. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9650. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9652. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9653. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9654. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9655. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9656. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9657. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9658. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9659. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9660. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9661. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9662. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9663. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9664. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9665. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9666. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9667. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9668. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9669. static readonly STEP_AFTERRENDER_AUDIO: number;
  9670. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9671. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9672. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9673. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9674. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9675. static readonly STEP_POINTERMOVE_SPRITE: number;
  9676. static readonly STEP_POINTERDOWN_SPRITE: number;
  9677. static readonly STEP_POINTERUP_SPRITE: number;
  9678. }
  9679. /**
  9680. * This represents a scene component.
  9681. *
  9682. * This is used to decouple the dependency the scene is having on the different workloads like
  9683. * layers, post processes...
  9684. */
  9685. export interface ISceneComponent {
  9686. /**
  9687. * The name of the component. Each component must have a unique name.
  9688. */
  9689. name: string;
  9690. /**
  9691. * The scene the component belongs to.
  9692. */
  9693. scene: Scene;
  9694. /**
  9695. * Register the component to one instance of a scene.
  9696. */
  9697. register(): void;
  9698. /**
  9699. * Rebuilds the elements related to this component in case of
  9700. * context lost for instance.
  9701. */
  9702. rebuild(): void;
  9703. /**
  9704. * Disposes the component and the associated ressources.
  9705. */
  9706. dispose(): void;
  9707. }
  9708. /**
  9709. * This represents a SERIALIZABLE scene component.
  9710. *
  9711. * This extends Scene Component to add Serialization methods on top.
  9712. */
  9713. export interface ISceneSerializableComponent extends ISceneComponent {
  9714. /**
  9715. * Adds all the elements from the container to the scene
  9716. * @param container the container holding the elements
  9717. */
  9718. addFromContainer(container: AbstractScene): void;
  9719. /**
  9720. * Removes all the elements in the container from the scene
  9721. * @param container contains the elements to remove
  9722. * @param dispose if the removed element should be disposed (default: false)
  9723. */
  9724. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9725. /**
  9726. * Serializes the component data to the specified json object
  9727. * @param serializationObject The object to serialize to
  9728. */
  9729. serialize(serializationObject: any): void;
  9730. }
  9731. /**
  9732. * Strong typing of a Mesh related stage step action
  9733. */
  9734. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9735. /**
  9736. * Strong typing of a Evaluate Sub Mesh related stage step action
  9737. */
  9738. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9739. /**
  9740. * Strong typing of a Active Mesh related stage step action
  9741. */
  9742. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9743. /**
  9744. * Strong typing of a Camera related stage step action
  9745. */
  9746. export type CameraStageAction = (camera: Camera) => void;
  9747. /**
  9748. * Strong typing of a Camera Frame buffer related stage step action
  9749. */
  9750. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9751. /**
  9752. * Strong typing of a Render Target related stage step action
  9753. */
  9754. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9755. /**
  9756. * Strong typing of a RenderingGroup related stage step action
  9757. */
  9758. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9759. /**
  9760. * Strong typing of a Mesh Render related stage step action
  9761. */
  9762. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9763. /**
  9764. * Strong typing of a simple stage step action
  9765. */
  9766. export type SimpleStageAction = () => void;
  9767. /**
  9768. * Strong typing of a render target action.
  9769. */
  9770. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9771. /**
  9772. * Strong typing of a pointer move action.
  9773. */
  9774. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9775. /**
  9776. * Strong typing of a pointer up/down action.
  9777. */
  9778. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9779. /**
  9780. * Representation of a stage in the scene (Basically a list of ordered steps)
  9781. * @hidden
  9782. */
  9783. export class Stage<T extends Function> extends Array<{
  9784. index: number;
  9785. component: ISceneComponent;
  9786. action: T;
  9787. }> {
  9788. /**
  9789. * Hide ctor from the rest of the world.
  9790. * @param items The items to add.
  9791. */
  9792. private constructor();
  9793. /**
  9794. * Creates a new Stage.
  9795. * @returns A new instance of a Stage
  9796. */
  9797. static Create<T extends Function>(): Stage<T>;
  9798. /**
  9799. * Registers a step in an ordered way in the targeted stage.
  9800. * @param index Defines the position to register the step in
  9801. * @param component Defines the component attached to the step
  9802. * @param action Defines the action to launch during the step
  9803. */
  9804. registerStep(index: number, component: ISceneComponent, action: T): void;
  9805. /**
  9806. * Clears all the steps from the stage.
  9807. */
  9808. clear(): void;
  9809. }
  9810. }
  9811. declare module BABYLON {
  9812. interface Scene {
  9813. /** @hidden */
  9814. _pointerOverSprite: Nullable<Sprite>;
  9815. /** @hidden */
  9816. _pickedDownSprite: Nullable<Sprite>;
  9817. /** @hidden */
  9818. _tempSpritePickingRay: Nullable<Ray>;
  9819. /**
  9820. * All of the sprite managers added to this scene
  9821. * @see http://doc.babylonjs.com/babylon101/sprites
  9822. */
  9823. spriteManagers: Array<ISpriteManager>;
  9824. /**
  9825. * An event triggered when sprites rendering is about to start
  9826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9827. */
  9828. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9829. /**
  9830. * An event triggered when sprites rendering is done
  9831. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9832. */
  9833. onAfterSpritesRenderingObservable: Observable<Scene>;
  9834. /** @hidden */
  9835. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9836. /** Launch a ray to try to pick a sprite in the scene
  9837. * @param x position on screen
  9838. * @param y position on screen
  9839. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9840. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9841. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9842. * @returns a PickingInfo
  9843. */
  9844. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9845. /** Use the given ray to pick a sprite in the scene
  9846. * @param ray The ray (in world space) to use to pick meshes
  9847. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9848. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9849. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo
  9851. */
  9852. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9853. /** @hidden */
  9854. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9855. /** Launch a ray to try to pick sprites in the scene
  9856. * @param x position on screen
  9857. * @param y position on screen
  9858. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9859. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9860. * @returns a PickingInfo array
  9861. */
  9862. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9863. /** Use the given ray to pick sprites in the scene
  9864. * @param ray The ray (in world space) to use to pick meshes
  9865. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9866. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9867. * @returns a PickingInfo array
  9868. */
  9869. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9870. /**
  9871. * Force the sprite under the pointer
  9872. * @param sprite defines the sprite to use
  9873. */
  9874. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9875. /**
  9876. * Gets the sprite under the pointer
  9877. * @returns a Sprite or null if no sprite is under the pointer
  9878. */
  9879. getPointerOverSprite(): Nullable<Sprite>;
  9880. }
  9881. /**
  9882. * Defines the sprite scene component responsible to manage sprites
  9883. * in a given scene.
  9884. */
  9885. export class SpriteSceneComponent implements ISceneComponent {
  9886. /**
  9887. * The component name helpfull to identify the component in the list of scene components.
  9888. */
  9889. readonly name: string;
  9890. /**
  9891. * The scene the component belongs to.
  9892. */
  9893. scene: Scene;
  9894. /** @hidden */
  9895. private _spritePredicate;
  9896. /**
  9897. * Creates a new instance of the component for the given scene
  9898. * @param scene Defines the scene to register the component in
  9899. */
  9900. constructor(scene: Scene);
  9901. /**
  9902. * Registers the component in a given scene
  9903. */
  9904. register(): void;
  9905. /**
  9906. * Rebuilds the elements related to this component in case of
  9907. * context lost for instance.
  9908. */
  9909. rebuild(): void;
  9910. /**
  9911. * Disposes the component and the associated ressources.
  9912. */
  9913. dispose(): void;
  9914. private _pickSpriteButKeepRay;
  9915. private _pointerMove;
  9916. private _pointerDown;
  9917. private _pointerUp;
  9918. }
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var fogFragmentDeclaration: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /** @hidden */
  9929. export var fogFragment: {
  9930. name: string;
  9931. shader: string;
  9932. };
  9933. }
  9934. declare module BABYLON {
  9935. /** @hidden */
  9936. export var spritesPixelShader: {
  9937. name: string;
  9938. shader: string;
  9939. };
  9940. }
  9941. declare module BABYLON {
  9942. /** @hidden */
  9943. export var fogVertexDeclaration: {
  9944. name: string;
  9945. shader: string;
  9946. };
  9947. }
  9948. declare module BABYLON {
  9949. /** @hidden */
  9950. export var spritesVertexShader: {
  9951. name: string;
  9952. shader: string;
  9953. };
  9954. }
  9955. declare module BABYLON {
  9956. /**
  9957. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9958. */
  9959. export interface ISpriteManager extends IDisposable {
  9960. /**
  9961. * Restricts the camera to viewing objects with the same layerMask.
  9962. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9963. */
  9964. layerMask: number;
  9965. /**
  9966. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9967. */
  9968. isPickable: boolean;
  9969. /**
  9970. * Specifies the rendering group id for this mesh (0 by default)
  9971. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9972. */
  9973. renderingGroupId: number;
  9974. /**
  9975. * Defines the list of sprites managed by the manager.
  9976. */
  9977. sprites: Array<Sprite>;
  9978. /**
  9979. * Tests the intersection of a sprite with a specific ray.
  9980. * @param ray The ray we are sending to test the collision
  9981. * @param camera The camera space we are sending rays in
  9982. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9983. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9984. * @returns picking info or null.
  9985. */
  9986. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9987. /**
  9988. * Intersects the sprites with a ray
  9989. * @param ray defines the ray to intersect with
  9990. * @param camera defines the current active camera
  9991. * @param predicate defines a predicate used to select candidate sprites
  9992. * @returns null if no hit or a PickingInfo array
  9993. */
  9994. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9995. /**
  9996. * Renders the list of sprites on screen.
  9997. */
  9998. render(): void;
  9999. }
  10000. /**
  10001. * Class used to manage multiple sprites on the same spritesheet
  10002. * @see http://doc.babylonjs.com/babylon101/sprites
  10003. */
  10004. export class SpriteManager implements ISpriteManager {
  10005. /** defines the manager's name */
  10006. name: string;
  10007. /** Gets the list of sprites */
  10008. sprites: Sprite[];
  10009. /** Gets or sets the rendering group id (0 by default) */
  10010. renderingGroupId: number;
  10011. /** Gets or sets camera layer mask */
  10012. layerMask: number;
  10013. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10014. fogEnabled: boolean;
  10015. /** Gets or sets a boolean indicating if the sprites are pickable */
  10016. isPickable: boolean;
  10017. /** Defines the default width of a cell in the spritesheet */
  10018. cellWidth: number;
  10019. /** Defines the default height of a cell in the spritesheet */
  10020. cellHeight: number;
  10021. /** Associative array from JSON sprite data file */
  10022. private _cellData;
  10023. /** Array of sprite names from JSON sprite data file */
  10024. private _spriteMap;
  10025. /** True when packed cell data from JSON file is ready*/
  10026. private _packedAndReady;
  10027. private _textureContent;
  10028. /**
  10029. * An event triggered when the manager is disposed.
  10030. */
  10031. onDisposeObservable: Observable<SpriteManager>;
  10032. private _onDisposeObserver;
  10033. /**
  10034. * Callback called when the manager is disposed
  10035. */
  10036. set onDispose(callback: () => void);
  10037. private _capacity;
  10038. private _fromPacked;
  10039. private _spriteTexture;
  10040. private _epsilon;
  10041. private _scene;
  10042. private _vertexData;
  10043. private _buffer;
  10044. private _vertexBuffers;
  10045. private _indexBuffer;
  10046. private _effectBase;
  10047. private _effectFog;
  10048. /**
  10049. * Gets or sets the spritesheet texture
  10050. */
  10051. get texture(): Texture;
  10052. set texture(value: Texture);
  10053. private _blendMode;
  10054. /**
  10055. * Blend mode use to render the particle, it can be any of
  10056. * the static Constants.ALPHA_x properties provided in this class.
  10057. * Default value is Constants.ALPHA_COMBINE
  10058. */
  10059. get blendMode(): number;
  10060. set blendMode(blendMode: number);
  10061. /** Disables writing to the depth buffer when rendering the sprites.
  10062. * It can be handy to disable depth writing when using textures without alpha channel
  10063. * and setting some specific blend modes.
  10064. */
  10065. disableDepthWrite: boolean;
  10066. /**
  10067. * Creates a new sprite manager
  10068. * @param name defines the manager's name
  10069. * @param imgUrl defines the sprite sheet url
  10070. * @param capacity defines the maximum allowed number of sprites
  10071. * @param cellSize defines the size of a sprite cell
  10072. * @param scene defines the hosting scene
  10073. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10074. * @param samplingMode defines the smapling mode to use with spritesheet
  10075. * @param fromPacked set to false; do not alter
  10076. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10077. */
  10078. constructor(
  10079. /** defines the manager's name */
  10080. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10081. private _makePacked;
  10082. private _appendSpriteVertex;
  10083. private _checkTextureAlpha;
  10084. /**
  10085. * Intersects the sprites with a ray
  10086. * @param ray defines the ray to intersect with
  10087. * @param camera defines the current active camera
  10088. * @param predicate defines a predicate used to select candidate sprites
  10089. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10090. * @returns null if no hit or a PickingInfo
  10091. */
  10092. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10093. /**
  10094. * Intersects the sprites with a ray
  10095. * @param ray defines the ray to intersect with
  10096. * @param camera defines the current active camera
  10097. * @param predicate defines a predicate used to select candidate sprites
  10098. * @returns null if no hit or a PickingInfo array
  10099. */
  10100. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10101. /**
  10102. * Render all child sprites
  10103. */
  10104. render(): void;
  10105. /**
  10106. * Release associated resources
  10107. */
  10108. dispose(): void;
  10109. }
  10110. }
  10111. declare module BABYLON {
  10112. /** Interface used by value gradients (color, factor, ...) */
  10113. export interface IValueGradient {
  10114. /**
  10115. * Gets or sets the gradient value (between 0 and 1)
  10116. */
  10117. gradient: number;
  10118. }
  10119. /** Class used to store color4 gradient */
  10120. export class ColorGradient implements IValueGradient {
  10121. /**
  10122. * Gets or sets the gradient value (between 0 and 1)
  10123. */
  10124. gradient: number;
  10125. /**
  10126. * Gets or sets first associated color
  10127. */
  10128. color1: Color4;
  10129. /**
  10130. * Gets or sets second associated color
  10131. */
  10132. color2?: Color4 | undefined;
  10133. /**
  10134. * Creates a new color4 gradient
  10135. * @param gradient gets or sets the gradient value (between 0 and 1)
  10136. * @param color1 gets or sets first associated color
  10137. * @param color2 gets or sets first second color
  10138. */
  10139. constructor(
  10140. /**
  10141. * Gets or sets the gradient value (between 0 and 1)
  10142. */
  10143. gradient: number,
  10144. /**
  10145. * Gets or sets first associated color
  10146. */
  10147. color1: Color4,
  10148. /**
  10149. * Gets or sets second associated color
  10150. */
  10151. color2?: Color4 | undefined);
  10152. /**
  10153. * Will get a color picked randomly between color1 and color2.
  10154. * If color2 is undefined then color1 will be used
  10155. * @param result defines the target Color4 to store the result in
  10156. */
  10157. getColorToRef(result: Color4): void;
  10158. }
  10159. /** Class used to store color 3 gradient */
  10160. export class Color3Gradient implements IValueGradient {
  10161. /**
  10162. * Gets or sets the gradient value (between 0 and 1)
  10163. */
  10164. gradient: number;
  10165. /**
  10166. * Gets or sets the associated color
  10167. */
  10168. color: Color3;
  10169. /**
  10170. * Creates a new color3 gradient
  10171. * @param gradient gets or sets the gradient value (between 0 and 1)
  10172. * @param color gets or sets associated color
  10173. */
  10174. constructor(
  10175. /**
  10176. * Gets or sets the gradient value (between 0 and 1)
  10177. */
  10178. gradient: number,
  10179. /**
  10180. * Gets or sets the associated color
  10181. */
  10182. color: Color3);
  10183. }
  10184. /** Class used to store factor gradient */
  10185. export class FactorGradient implements IValueGradient {
  10186. /**
  10187. * Gets or sets the gradient value (between 0 and 1)
  10188. */
  10189. gradient: number;
  10190. /**
  10191. * Gets or sets first associated factor
  10192. */
  10193. factor1: number;
  10194. /**
  10195. * Gets or sets second associated factor
  10196. */
  10197. factor2?: number | undefined;
  10198. /**
  10199. * Creates a new factor gradient
  10200. * @param gradient gets or sets the gradient value (between 0 and 1)
  10201. * @param factor1 gets or sets first associated factor
  10202. * @param factor2 gets or sets second associated factor
  10203. */
  10204. constructor(
  10205. /**
  10206. * Gets or sets the gradient value (between 0 and 1)
  10207. */
  10208. gradient: number,
  10209. /**
  10210. * Gets or sets first associated factor
  10211. */
  10212. factor1: number,
  10213. /**
  10214. * Gets or sets second associated factor
  10215. */
  10216. factor2?: number | undefined);
  10217. /**
  10218. * Will get a number picked randomly between factor1 and factor2.
  10219. * If factor2 is undefined then factor1 will be used
  10220. * @returns the picked number
  10221. */
  10222. getFactor(): number;
  10223. }
  10224. /**
  10225. * Helper used to simplify some generic gradient tasks
  10226. */
  10227. export class GradientHelper {
  10228. /**
  10229. * Gets the current gradient from an array of IValueGradient
  10230. * @param ratio defines the current ratio to get
  10231. * @param gradients defines the array of IValueGradient
  10232. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10233. */
  10234. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10235. }
  10236. }
  10237. declare module BABYLON {
  10238. /**
  10239. * Interface for the size containing width and height
  10240. */
  10241. export interface ISize {
  10242. /**
  10243. * Width
  10244. */
  10245. width: number;
  10246. /**
  10247. * Heighht
  10248. */
  10249. height: number;
  10250. }
  10251. /**
  10252. * Size containing widht and height
  10253. */
  10254. export class Size implements ISize {
  10255. /**
  10256. * Width
  10257. */
  10258. width: number;
  10259. /**
  10260. * Height
  10261. */
  10262. height: number;
  10263. /**
  10264. * Creates a Size object from the given width and height (floats).
  10265. * @param width width of the new size
  10266. * @param height height of the new size
  10267. */
  10268. constructor(width: number, height: number);
  10269. /**
  10270. * Returns a string with the Size width and height
  10271. * @returns a string with the Size width and height
  10272. */
  10273. toString(): string;
  10274. /**
  10275. * "Size"
  10276. * @returns the string "Size"
  10277. */
  10278. getClassName(): string;
  10279. /**
  10280. * Returns the Size hash code.
  10281. * @returns a hash code for a unique width and height
  10282. */
  10283. getHashCode(): number;
  10284. /**
  10285. * Updates the current size from the given one.
  10286. * @param src the given size
  10287. */
  10288. copyFrom(src: Size): void;
  10289. /**
  10290. * Updates in place the current Size from the given floats.
  10291. * @param width width of the new size
  10292. * @param height height of the new size
  10293. * @returns the updated Size.
  10294. */
  10295. copyFromFloats(width: number, height: number): Size;
  10296. /**
  10297. * Updates in place the current Size from the given floats.
  10298. * @param width width to set
  10299. * @param height height to set
  10300. * @returns the updated Size.
  10301. */
  10302. set(width: number, height: number): Size;
  10303. /**
  10304. * Multiplies the width and height by numbers
  10305. * @param w factor to multiple the width by
  10306. * @param h factor to multiple the height by
  10307. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10308. */
  10309. multiplyByFloats(w: number, h: number): Size;
  10310. /**
  10311. * Clones the size
  10312. * @returns a new Size copied from the given one.
  10313. */
  10314. clone(): Size;
  10315. /**
  10316. * True if the current Size and the given one width and height are strictly equal.
  10317. * @param other the other size to compare against
  10318. * @returns True if the current Size and the given one width and height are strictly equal.
  10319. */
  10320. equals(other: Size): boolean;
  10321. /**
  10322. * The surface of the Size : width * height (float).
  10323. */
  10324. get surface(): number;
  10325. /**
  10326. * Create a new size of zero
  10327. * @returns a new Size set to (0.0, 0.0)
  10328. */
  10329. static Zero(): Size;
  10330. /**
  10331. * Sums the width and height of two sizes
  10332. * @param otherSize size to add to this size
  10333. * @returns a new Size set as the addition result of the current Size and the given one.
  10334. */
  10335. add(otherSize: Size): Size;
  10336. /**
  10337. * Subtracts the width and height of two
  10338. * @param otherSize size to subtract to this size
  10339. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10340. */
  10341. subtract(otherSize: Size): Size;
  10342. /**
  10343. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10344. * @param start starting size to lerp between
  10345. * @param end end size to lerp between
  10346. * @param amount amount to lerp between the start and end values
  10347. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10348. */
  10349. static Lerp(start: Size, end: Size, amount: number): Size;
  10350. }
  10351. }
  10352. declare module BABYLON {
  10353. interface ThinEngine {
  10354. /**
  10355. * Creates a dynamic texture
  10356. * @param width defines the width of the texture
  10357. * @param height defines the height of the texture
  10358. * @param generateMipMaps defines if the engine should generate the mip levels
  10359. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10360. * @returns the dynamic texture inside an InternalTexture
  10361. */
  10362. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10363. /**
  10364. * Update the content of a dynamic texture
  10365. * @param texture defines the texture to update
  10366. * @param canvas defines the canvas containing the source
  10367. * @param invertY defines if data must be stored with Y axis inverted
  10368. * @param premulAlpha defines if alpha is stored as premultiplied
  10369. * @param format defines the format of the data
  10370. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10371. */
  10372. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10373. }
  10374. }
  10375. declare module BABYLON {
  10376. /**
  10377. * Helper class used to generate a canvas to manipulate images
  10378. */
  10379. export class CanvasGenerator {
  10380. /**
  10381. * Create a new canvas (or offscreen canvas depending on the context)
  10382. * @param width defines the expected width
  10383. * @param height defines the expected height
  10384. * @return a new canvas or offscreen canvas
  10385. */
  10386. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10387. }
  10388. }
  10389. declare module BABYLON {
  10390. /**
  10391. * A class extending Texture allowing drawing on a texture
  10392. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10393. */
  10394. export class DynamicTexture extends Texture {
  10395. private _generateMipMaps;
  10396. private _canvas;
  10397. private _context;
  10398. private _engine;
  10399. /**
  10400. * Creates a DynamicTexture
  10401. * @param name defines the name of the texture
  10402. * @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
  10403. * @param scene defines the scene where you want the texture
  10404. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10405. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10406. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10407. */
  10408. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10409. /**
  10410. * Get the current class name of the texture useful for serialization or dynamic coding.
  10411. * @returns "DynamicTexture"
  10412. */
  10413. getClassName(): string;
  10414. /**
  10415. * Gets the current state of canRescale
  10416. */
  10417. get canRescale(): boolean;
  10418. private _recreate;
  10419. /**
  10420. * Scales the texture
  10421. * @param ratio the scale factor to apply to both width and height
  10422. */
  10423. scale(ratio: number): void;
  10424. /**
  10425. * Resizes the texture
  10426. * @param width the new width
  10427. * @param height the new height
  10428. */
  10429. scaleTo(width: number, height: number): void;
  10430. /**
  10431. * Gets the context of the canvas used by the texture
  10432. * @returns the canvas context of the dynamic texture
  10433. */
  10434. getContext(): CanvasRenderingContext2D;
  10435. /**
  10436. * Clears the texture
  10437. */
  10438. clear(): void;
  10439. /**
  10440. * Updates the texture
  10441. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10442. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10443. */
  10444. update(invertY?: boolean, premulAlpha?: boolean): void;
  10445. /**
  10446. * Draws text onto the texture
  10447. * @param text defines the text to be drawn
  10448. * @param x defines the placement of the text from the left
  10449. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10450. * @param font defines the font to be used with font-style, font-size, font-name
  10451. * @param color defines the color used for the text
  10452. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10453. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10454. * @param update defines whether texture is immediately update (default is true)
  10455. */
  10456. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10457. /**
  10458. * Clones the texture
  10459. * @returns the clone of the texture.
  10460. */
  10461. clone(): DynamicTexture;
  10462. /**
  10463. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10464. * @returns a serialized dynamic texture object
  10465. */
  10466. serialize(): any;
  10467. /** @hidden */
  10468. _rebuild(): void;
  10469. }
  10470. }
  10471. declare module BABYLON {
  10472. interface Engine {
  10473. /**
  10474. * Creates a raw texture
  10475. * @param data defines the data to store in the texture
  10476. * @param width defines the width of the texture
  10477. * @param height defines the height of the texture
  10478. * @param format defines the format of the data
  10479. * @param generateMipMaps defines if the engine should generate the mip levels
  10480. * @param invertY defines if data must be stored with Y axis inverted
  10481. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10482. * @param compression defines the compression used (null by default)
  10483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10484. * @returns the raw texture inside an InternalTexture
  10485. */
  10486. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10487. /**
  10488. * Update a raw texture
  10489. * @param texture defines the texture to update
  10490. * @param data defines the data to store in the texture
  10491. * @param format defines the format of the data
  10492. * @param invertY defines if data must be stored with Y axis inverted
  10493. */
  10494. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10495. /**
  10496. * Update a raw texture
  10497. * @param texture defines the texture to update
  10498. * @param data defines the data to store in the texture
  10499. * @param format defines the format of the data
  10500. * @param invertY defines if data must be stored with Y axis inverted
  10501. * @param compression defines the compression used (null by default)
  10502. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10503. */
  10504. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10505. /**
  10506. * Creates a new raw cube texture
  10507. * @param data defines the array of data to use to create each face
  10508. * @param size defines the size of the textures
  10509. * @param format defines the format of the data
  10510. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10511. * @param generateMipMaps defines if the engine should generate the mip levels
  10512. * @param invertY defines if data must be stored with Y axis inverted
  10513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10514. * @param compression defines the compression used (null by default)
  10515. * @returns the cube texture as an InternalTexture
  10516. */
  10517. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10518. /**
  10519. * Update a raw cube texture
  10520. * @param texture defines the texture to udpdate
  10521. * @param data defines the data to store
  10522. * @param format defines the data format
  10523. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10524. * @param invertY defines if data must be stored with Y axis inverted
  10525. */
  10526. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10527. /**
  10528. * Update a raw cube texture
  10529. * @param texture defines the texture to udpdate
  10530. * @param data defines the data to store
  10531. * @param format defines the data format
  10532. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10533. * @param invertY defines if data must be stored with Y axis inverted
  10534. * @param compression defines the compression used (null by default)
  10535. */
  10536. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10537. /**
  10538. * Update a raw cube texture
  10539. * @param texture defines the texture to udpdate
  10540. * @param data defines the data to store
  10541. * @param format defines the data format
  10542. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10543. * @param invertY defines if data must be stored with Y axis inverted
  10544. * @param compression defines the compression used (null by default)
  10545. * @param level defines which level of the texture to update
  10546. */
  10547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10548. /**
  10549. * Creates a new raw cube texture from a specified url
  10550. * @param url defines the url where the data is located
  10551. * @param scene defines the current scene
  10552. * @param size defines the size of the textures
  10553. * @param format defines the format of the data
  10554. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10555. * @param noMipmap defines if the engine should avoid generating the mip levels
  10556. * @param callback defines a callback used to extract texture data from loaded data
  10557. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10558. * @param onLoad defines a callback called when texture is loaded
  10559. * @param onError defines a callback called if there is an error
  10560. * @returns the cube texture as an InternalTexture
  10561. */
  10562. 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;
  10563. /**
  10564. * Creates a new raw cube texture from a specified url
  10565. * @param url defines the url where the data is located
  10566. * @param scene defines the current scene
  10567. * @param size defines the size of the textures
  10568. * @param format defines the format of the data
  10569. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10570. * @param noMipmap defines if the engine should avoid generating the mip levels
  10571. * @param callback defines a callback used to extract texture data from loaded data
  10572. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10573. * @param onLoad defines a callback called when texture is loaded
  10574. * @param onError defines a callback called if there is an error
  10575. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10576. * @param invertY defines if data must be stored with Y axis inverted
  10577. * @returns the cube texture as an InternalTexture
  10578. */
  10579. 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;
  10580. /**
  10581. * Creates a new raw 3D texture
  10582. * @param data defines the data used to create the texture
  10583. * @param width defines the width of the texture
  10584. * @param height defines the height of the texture
  10585. * @param depth defines the depth of the texture
  10586. * @param format defines the format of the texture
  10587. * @param generateMipMaps defines if the engine must generate mip levels
  10588. * @param invertY defines if data must be stored with Y axis inverted
  10589. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10590. * @param compression defines the compressed used (can be null)
  10591. * @param textureType defines the compressed used (can be null)
  10592. * @returns a new raw 3D texture (stored in an InternalTexture)
  10593. */
  10594. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10595. /**
  10596. * Update a raw 3D texture
  10597. * @param texture defines the texture to update
  10598. * @param data defines the data to store
  10599. * @param format defines the data format
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. */
  10602. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10603. /**
  10604. * Update a raw 3D texture
  10605. * @param texture defines the texture to update
  10606. * @param data defines the data to store
  10607. * @param format defines the data format
  10608. * @param invertY defines if data must be stored with Y axis inverted
  10609. * @param compression defines the used compression (can be null)
  10610. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10611. */
  10612. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10613. /**
  10614. * Creates a new raw 2D array texture
  10615. * @param data defines the data used to create the texture
  10616. * @param width defines the width of the texture
  10617. * @param height defines the height of the texture
  10618. * @param depth defines the number of layers of the texture
  10619. * @param format defines the format of the texture
  10620. * @param generateMipMaps defines if the engine must generate mip levels
  10621. * @param invertY defines if data must be stored with Y axis inverted
  10622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10623. * @param compression defines the compressed used (can be null)
  10624. * @param textureType defines the compressed used (can be null)
  10625. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10626. */
  10627. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10628. /**
  10629. * Update a raw 2D array texture
  10630. * @param texture defines the texture to update
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param invertY defines if data must be stored with Y axis inverted
  10634. */
  10635. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10636. /**
  10637. * Update a raw 2D array texture
  10638. * @param texture defines the texture to update
  10639. * @param data defines the data to store
  10640. * @param format defines the data format
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param compression defines the used compression (can be null)
  10643. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10644. */
  10645. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10646. }
  10647. }
  10648. declare module BABYLON {
  10649. /**
  10650. * Raw texture can help creating a texture directly from an array of data.
  10651. * This can be super useful if you either get the data from an uncompressed source or
  10652. * if you wish to create your texture pixel by pixel.
  10653. */
  10654. export class RawTexture extends Texture {
  10655. /**
  10656. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10657. */
  10658. format: number;
  10659. private _engine;
  10660. /**
  10661. * Instantiates a new RawTexture.
  10662. * Raw texture can help creating a texture directly from an array of data.
  10663. * This can be super useful if you either get the data from an uncompressed source or
  10664. * if you wish to create your texture pixel by pixel.
  10665. * @param data define the array of data to use to create the texture
  10666. * @param width define the width of the texture
  10667. * @param height define the height of the texture
  10668. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10669. * @param scene define the scene the texture belongs to
  10670. * @param generateMipMaps define whether mip maps should be generated or not
  10671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10673. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10674. */
  10675. constructor(data: ArrayBufferView, width: number, height: number,
  10676. /**
  10677. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10678. */
  10679. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10680. /**
  10681. * Updates the texture underlying data.
  10682. * @param data Define the new data of the texture
  10683. */
  10684. update(data: ArrayBufferView): void;
  10685. /**
  10686. * Creates a luminance texture from some data.
  10687. * @param data Define the texture data
  10688. * @param width Define the width of the texture
  10689. * @param height Define the height of the texture
  10690. * @param scene Define the scene the texture belongs to
  10691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10694. * @returns the luminance texture
  10695. */
  10696. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10697. /**
  10698. * Creates a luminance alpha texture from some data.
  10699. * @param data Define the texture data
  10700. * @param width Define the width of the texture
  10701. * @param height Define the height of the texture
  10702. * @param scene Define the scene the texture belongs to
  10703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10706. * @returns the luminance alpha texture
  10707. */
  10708. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10709. /**
  10710. * Creates an alpha texture from some data.
  10711. * @param data Define the texture data
  10712. * @param width Define the width of the texture
  10713. * @param height Define the height of the texture
  10714. * @param scene Define the scene the texture belongs to
  10715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10718. * @returns the alpha texture
  10719. */
  10720. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10721. /**
  10722. * Creates a RGB texture from some data.
  10723. * @param data Define the texture data
  10724. * @param width Define the width of the texture
  10725. * @param height Define the height of the texture
  10726. * @param scene Define the scene the texture belongs to
  10727. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10728. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10729. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10730. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10731. * @returns the RGB alpha texture
  10732. */
  10733. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10734. /**
  10735. * Creates a RGBA texture from some data.
  10736. * @param data Define the texture data
  10737. * @param width Define the width of the texture
  10738. * @param height Define the height of the texture
  10739. * @param scene Define the scene the texture belongs to
  10740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10744. * @returns the RGBA texture
  10745. */
  10746. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10747. /**
  10748. * Creates a R texture from some data.
  10749. * @param data Define the texture data
  10750. * @param width Define the width of the texture
  10751. * @param height Define the height of the texture
  10752. * @param scene Define the scene the texture belongs to
  10753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10756. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10757. * @returns the R texture
  10758. */
  10759. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10760. }
  10761. }
  10762. declare module BABYLON {
  10763. interface AbstractScene {
  10764. /**
  10765. * The list of procedural textures added to the scene
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10767. */
  10768. proceduralTextures: Array<ProceduralTexture>;
  10769. }
  10770. /**
  10771. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10772. * in a given scene.
  10773. */
  10774. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10775. /**
  10776. * The component name helpfull to identify the component in the list of scene components.
  10777. */
  10778. readonly name: string;
  10779. /**
  10780. * The scene the component belongs to.
  10781. */
  10782. scene: Scene;
  10783. /**
  10784. * Creates a new instance of the component for the given scene
  10785. * @param scene Defines the scene to register the component in
  10786. */
  10787. constructor(scene: Scene);
  10788. /**
  10789. * Registers the component in a given scene
  10790. */
  10791. register(): void;
  10792. /**
  10793. * Rebuilds the elements related to this component in case of
  10794. * context lost for instance.
  10795. */
  10796. rebuild(): void;
  10797. /**
  10798. * Disposes the component and the associated ressources.
  10799. */
  10800. dispose(): void;
  10801. private _beforeClear;
  10802. }
  10803. }
  10804. declare module BABYLON {
  10805. interface ThinEngine {
  10806. /**
  10807. * Creates a new render target cube texture
  10808. * @param size defines the size of the texture
  10809. * @param options defines the options used to create the texture
  10810. * @returns a new render target cube texture stored in an InternalTexture
  10811. */
  10812. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10813. }
  10814. }
  10815. declare module BABYLON {
  10816. /** @hidden */
  10817. export var proceduralVertexShader: {
  10818. name: string;
  10819. shader: string;
  10820. };
  10821. }
  10822. declare module BABYLON {
  10823. /**
  10824. * 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.
  10825. * This is the base class of any Procedural texture and contains most of the shareable code.
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10827. */
  10828. export class ProceduralTexture extends Texture {
  10829. isCube: boolean;
  10830. /**
  10831. * Define if the texture is enabled or not (disabled texture will not render)
  10832. */
  10833. isEnabled: boolean;
  10834. /**
  10835. * Define if the texture must be cleared before rendering (default is true)
  10836. */
  10837. autoClear: boolean;
  10838. /**
  10839. * Callback called when the texture is generated
  10840. */
  10841. onGenerated: () => void;
  10842. /**
  10843. * Event raised when the texture is generated
  10844. */
  10845. onGeneratedObservable: Observable<ProceduralTexture>;
  10846. /** @hidden */
  10847. _generateMipMaps: boolean;
  10848. /** @hidden **/
  10849. _effect: Effect;
  10850. /** @hidden */
  10851. _textures: {
  10852. [key: string]: Texture;
  10853. };
  10854. /** @hidden */
  10855. protected _fallbackTexture: Nullable<Texture>;
  10856. private _size;
  10857. private _currentRefreshId;
  10858. private _frameId;
  10859. private _refreshRate;
  10860. private _vertexBuffers;
  10861. private _indexBuffer;
  10862. private _uniforms;
  10863. private _samplers;
  10864. private _fragment;
  10865. private _floats;
  10866. private _ints;
  10867. private _floatsArrays;
  10868. private _colors3;
  10869. private _colors4;
  10870. private _vectors2;
  10871. private _vectors3;
  10872. private _matrices;
  10873. private _fallbackTextureUsed;
  10874. private _engine;
  10875. private _cachedDefines;
  10876. private _contentUpdateId;
  10877. private _contentData;
  10878. /**
  10879. * Instantiates a new procedural texture.
  10880. * 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.
  10881. * This is the base class of any Procedural texture and contains most of the shareable code.
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10883. * @param name Define the name of the texture
  10884. * @param size Define the size of the texture to create
  10885. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10886. * @param scene Define the scene the texture belongs to
  10887. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10888. * @param generateMipMaps Define if the texture should creates mip maps or not
  10889. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10890. */
  10891. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10892. /**
  10893. * The effect that is created when initializing the post process.
  10894. * @returns The created effect corresponding the the postprocess.
  10895. */
  10896. getEffect(): Effect;
  10897. /**
  10898. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10899. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10900. */
  10901. getContent(): Nullable<ArrayBufferView>;
  10902. private _createIndexBuffer;
  10903. /** @hidden */
  10904. _rebuild(): void;
  10905. /**
  10906. * Resets the texture in order to recreate its associated resources.
  10907. * This can be called in case of context loss
  10908. */
  10909. reset(): void;
  10910. protected _getDefines(): string;
  10911. /**
  10912. * Is the texture ready to be used ? (rendered at least once)
  10913. * @returns true if ready, otherwise, false.
  10914. */
  10915. isReady(): boolean;
  10916. /**
  10917. * Resets the refresh counter of the texture and start bak from scratch.
  10918. * Could be useful to regenerate the texture if it is setup to render only once.
  10919. */
  10920. resetRefreshCounter(): void;
  10921. /**
  10922. * Set the fragment shader to use in order to render the texture.
  10923. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10924. */
  10925. setFragment(fragment: any): void;
  10926. /**
  10927. * Define the refresh rate of the texture or the rendering frequency.
  10928. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10929. */
  10930. get refreshRate(): number;
  10931. set refreshRate(value: number);
  10932. /** @hidden */
  10933. _shouldRender(): boolean;
  10934. /**
  10935. * Get the size the texture is rendering at.
  10936. * @returns the size (texture is always squared)
  10937. */
  10938. getRenderSize(): number;
  10939. /**
  10940. * Resize the texture to new value.
  10941. * @param size Define the new size the texture should have
  10942. * @param generateMipMaps Define whether the new texture should create mip maps
  10943. */
  10944. resize(size: number, generateMipMaps: boolean): void;
  10945. private _checkUniform;
  10946. /**
  10947. * Set a texture in the shader program used to render.
  10948. * @param name Define the name of the uniform samplers as defined in the shader
  10949. * @param texture Define the texture to bind to this sampler
  10950. * @return the texture itself allowing "fluent" like uniform updates
  10951. */
  10952. setTexture(name: string, texture: Texture): ProceduralTexture;
  10953. /**
  10954. * Set a float 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. setFloat(name: string, value: number): ProceduralTexture;
  10960. /**
  10961. * Set a int 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. setInt(name: string, value: number): ProceduralTexture;
  10967. /**
  10968. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ProceduralTexture;
  10974. /**
  10975. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  10981. /**
  10982. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  10988. /**
  10989. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  10995. /**
  10996. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  11002. /**
  11003. * Set a mat4 in the shader from a MAtrix.
  11004. * @param name Define the name of the uniform as defined in the shader
  11005. * @param value Define the value to give to the uniform
  11006. * @return the texture itself allowing "fluent" like uniform updates
  11007. */
  11008. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11009. /**
  11010. * Render the texture to its associated render target.
  11011. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11012. */
  11013. render(useCameraPostProcess?: boolean): void;
  11014. /**
  11015. * Clone the texture.
  11016. * @returns the cloned texture
  11017. */
  11018. clone(): ProceduralTexture;
  11019. /**
  11020. * Dispose the texture and release its asoociated resources.
  11021. */
  11022. dispose(): void;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * This represents the base class for particle system in Babylon.
  11028. * 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.
  11029. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11030. * @example https://doc.babylonjs.com/babylon101/particles
  11031. */
  11032. export class BaseParticleSystem {
  11033. /**
  11034. * Source color is added to the destination color without alpha affecting the result
  11035. */
  11036. static BLENDMODE_ONEONE: number;
  11037. /**
  11038. * Blend current color and particle color using particle’s alpha
  11039. */
  11040. static BLENDMODE_STANDARD: number;
  11041. /**
  11042. * Add current color and particle color multiplied by particle’s alpha
  11043. */
  11044. static BLENDMODE_ADD: number;
  11045. /**
  11046. * Multiply current color with particle color
  11047. */
  11048. static BLENDMODE_MULTIPLY: number;
  11049. /**
  11050. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11051. */
  11052. static BLENDMODE_MULTIPLYADD: number;
  11053. /**
  11054. * List of animations used by the particle system.
  11055. */
  11056. animations: Animation[];
  11057. /**
  11058. * Gets or sets the unique id of the particle system
  11059. */
  11060. uniqueId: number;
  11061. /**
  11062. * The id of the Particle system.
  11063. */
  11064. id: string;
  11065. /**
  11066. * The friendly name of the Particle system.
  11067. */
  11068. name: string;
  11069. /**
  11070. * Snippet ID if the particle system was created from the snippet server
  11071. */
  11072. snippetId: string;
  11073. /**
  11074. * The rendering group used by the Particle system to chose when to render.
  11075. */
  11076. renderingGroupId: number;
  11077. /**
  11078. * The emitter represents the Mesh or position we are attaching the particle system to.
  11079. */
  11080. emitter: Nullable<AbstractMesh | Vector3>;
  11081. /**
  11082. * The maximum number of particles to emit per frame
  11083. */
  11084. emitRate: number;
  11085. /**
  11086. * If you want to launch only a few particles at once, that can be done, as well.
  11087. */
  11088. manualEmitCount: number;
  11089. /**
  11090. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11091. */
  11092. updateSpeed: number;
  11093. /**
  11094. * The amount of time the particle system is running (depends of the overall update speed).
  11095. */
  11096. targetStopDuration: number;
  11097. /**
  11098. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11099. */
  11100. disposeOnStop: boolean;
  11101. /**
  11102. * Minimum power of emitting particles.
  11103. */
  11104. minEmitPower: number;
  11105. /**
  11106. * Maximum power of emitting particles.
  11107. */
  11108. maxEmitPower: number;
  11109. /**
  11110. * Minimum life time of emitting particles.
  11111. */
  11112. minLifeTime: number;
  11113. /**
  11114. * Maximum life time of emitting particles.
  11115. */
  11116. maxLifeTime: number;
  11117. /**
  11118. * Minimum Size of emitting particles.
  11119. */
  11120. minSize: number;
  11121. /**
  11122. * Maximum Size of emitting particles.
  11123. */
  11124. maxSize: number;
  11125. /**
  11126. * Minimum scale of emitting particles on X axis.
  11127. */
  11128. minScaleX: number;
  11129. /**
  11130. * Maximum scale of emitting particles on X axis.
  11131. */
  11132. maxScaleX: number;
  11133. /**
  11134. * Minimum scale of emitting particles on Y axis.
  11135. */
  11136. minScaleY: number;
  11137. /**
  11138. * Maximum scale of emitting particles on Y axis.
  11139. */
  11140. maxScaleY: number;
  11141. /**
  11142. * Gets or sets the minimal initial rotation in radians.
  11143. */
  11144. minInitialRotation: number;
  11145. /**
  11146. * Gets or sets the maximal initial rotation in radians.
  11147. */
  11148. maxInitialRotation: number;
  11149. /**
  11150. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11151. */
  11152. minAngularSpeed: number;
  11153. /**
  11154. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11155. */
  11156. maxAngularSpeed: number;
  11157. /**
  11158. * The texture used to render each particle. (this can be a spritesheet)
  11159. */
  11160. particleTexture: Nullable<Texture>;
  11161. /**
  11162. * The layer mask we are rendering the particles through.
  11163. */
  11164. layerMask: number;
  11165. /**
  11166. * This can help using your own shader to render the particle system.
  11167. * The according effect will be created
  11168. */
  11169. customShader: any;
  11170. /**
  11171. * By default particle system starts as soon as they are created. This prevents the
  11172. * automatic start to happen and let you decide when to start emitting particles.
  11173. */
  11174. preventAutoStart: boolean;
  11175. private _noiseTexture;
  11176. /**
  11177. * Gets or sets a texture used to add random noise to particle positions
  11178. */
  11179. get noiseTexture(): Nullable<ProceduralTexture>;
  11180. set noiseTexture(value: Nullable<ProceduralTexture>);
  11181. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11182. noiseStrength: Vector3;
  11183. /**
  11184. * Callback triggered when the particle animation is ending.
  11185. */
  11186. onAnimationEnd: Nullable<() => void>;
  11187. /**
  11188. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11189. */
  11190. blendMode: number;
  11191. /**
  11192. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11193. * to override the particles.
  11194. */
  11195. forceDepthWrite: boolean;
  11196. /** 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 */
  11197. preWarmCycles: number;
  11198. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11199. preWarmStepOffset: number;
  11200. /**
  11201. * 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)
  11202. */
  11203. spriteCellChangeSpeed: number;
  11204. /**
  11205. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11206. */
  11207. startSpriteCellID: number;
  11208. /**
  11209. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11210. */
  11211. endSpriteCellID: number;
  11212. /**
  11213. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11214. */
  11215. spriteCellWidth: number;
  11216. /**
  11217. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11218. */
  11219. spriteCellHeight: number;
  11220. /**
  11221. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11222. */
  11223. spriteRandomStartCell: boolean;
  11224. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11225. translationPivot: Vector2;
  11226. /** @hidden */
  11227. protected _isAnimationSheetEnabled: boolean;
  11228. /**
  11229. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11230. */
  11231. beginAnimationOnStart: boolean;
  11232. /**
  11233. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11234. */
  11235. beginAnimationFrom: number;
  11236. /**
  11237. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11238. */
  11239. beginAnimationTo: number;
  11240. /**
  11241. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11242. */
  11243. beginAnimationLoop: boolean;
  11244. /**
  11245. * Gets or sets a world offset applied to all particles
  11246. */
  11247. worldOffset: Vector3;
  11248. /**
  11249. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11250. */
  11251. get isAnimationSheetEnabled(): boolean;
  11252. set isAnimationSheetEnabled(value: boolean);
  11253. /**
  11254. * Get hosting scene
  11255. * @returns the scene
  11256. */
  11257. getScene(): Scene;
  11258. /**
  11259. * You can use gravity if you want to give an orientation to your particles.
  11260. */
  11261. gravity: Vector3;
  11262. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11263. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11264. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11265. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11266. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11267. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11268. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11269. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11270. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11271. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11272. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11273. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11274. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11275. /**
  11276. * Defines the delay in milliseconds before starting the system (0 by default)
  11277. */
  11278. startDelay: number;
  11279. /**
  11280. * Gets the current list of drag gradients.
  11281. * You must use addDragGradient and removeDragGradient to udpate this list
  11282. * @returns the list of drag gradients
  11283. */
  11284. getDragGradients(): Nullable<Array<FactorGradient>>;
  11285. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11286. limitVelocityDamping: number;
  11287. /**
  11288. * Gets the current list of limit velocity gradients.
  11289. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11290. * @returns the list of limit velocity gradients
  11291. */
  11292. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11293. /**
  11294. * Gets the current list of color gradients.
  11295. * You must use addColorGradient and removeColorGradient to udpate this list
  11296. * @returns the list of color gradients
  11297. */
  11298. getColorGradients(): Nullable<Array<ColorGradient>>;
  11299. /**
  11300. * Gets the current list of size gradients.
  11301. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11302. * @returns the list of size gradients
  11303. */
  11304. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11305. /**
  11306. * Gets the current list of color remap gradients.
  11307. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11308. * @returns the list of color remap gradients
  11309. */
  11310. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11311. /**
  11312. * Gets the current list of alpha remap gradients.
  11313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11314. * @returns the list of alpha remap gradients
  11315. */
  11316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11317. /**
  11318. * Gets the current list of life time gradients.
  11319. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11320. * @returns the list of life time gradients
  11321. */
  11322. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11323. /**
  11324. * Gets the current list of angular speed gradients.
  11325. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11326. * @returns the list of angular speed gradients
  11327. */
  11328. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11329. /**
  11330. * Gets the current list of velocity gradients.
  11331. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11332. * @returns the list of velocity gradients
  11333. */
  11334. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11335. /**
  11336. * Gets the current list of start size gradients.
  11337. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11338. * @returns the list of start size gradients
  11339. */
  11340. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11341. /**
  11342. * Gets the current list of emit rate gradients.
  11343. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11344. * @returns the list of emit rate gradients
  11345. */
  11346. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11347. /**
  11348. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11349. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11350. */
  11351. get direction1(): Vector3;
  11352. set direction1(value: Vector3);
  11353. /**
  11354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11356. */
  11357. get direction2(): Vector3;
  11358. set direction2(value: Vector3);
  11359. /**
  11360. * 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.
  11361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11362. */
  11363. get minEmitBox(): Vector3;
  11364. set minEmitBox(value: Vector3);
  11365. /**
  11366. * 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.
  11367. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11368. */
  11369. get maxEmitBox(): Vector3;
  11370. set maxEmitBox(value: Vector3);
  11371. /**
  11372. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11373. */
  11374. color1: Color4;
  11375. /**
  11376. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11377. */
  11378. color2: Color4;
  11379. /**
  11380. * Color the particle will have at the end of its lifetime
  11381. */
  11382. colorDead: Color4;
  11383. /**
  11384. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11385. */
  11386. textureMask: Color4;
  11387. /**
  11388. * The particle emitter type defines the emitter used by the particle system.
  11389. * It can be for example box, sphere, or cone...
  11390. */
  11391. particleEmitterType: IParticleEmitterType;
  11392. /** @hidden */
  11393. _isSubEmitter: boolean;
  11394. /**
  11395. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11396. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11397. */
  11398. billboardMode: number;
  11399. protected _isBillboardBased: boolean;
  11400. /**
  11401. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11402. */
  11403. get isBillboardBased(): boolean;
  11404. set isBillboardBased(value: boolean);
  11405. /**
  11406. * The scene the particle system belongs to.
  11407. */
  11408. protected _scene: Scene;
  11409. /**
  11410. * Local cache of defines for image processing.
  11411. */
  11412. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11413. /**
  11414. * Default configuration related to image processing available in the standard Material.
  11415. */
  11416. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11417. /**
  11418. * Gets the image processing configuration used either in this material.
  11419. */
  11420. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11421. /**
  11422. * Sets the Default image processing configuration used either in the this material.
  11423. *
  11424. * If sets to null, the scene one is in use.
  11425. */
  11426. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11427. /**
  11428. * Attaches a new image processing configuration to the Standard Material.
  11429. * @param configuration
  11430. */
  11431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11432. /** @hidden */
  11433. protected _reset(): void;
  11434. /** @hidden */
  11435. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11436. /**
  11437. * Instantiates a particle system.
  11438. * 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.
  11439. * @param name The name of the particle system
  11440. */
  11441. constructor(name: string);
  11442. /**
  11443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11446. * @returns the emitter
  11447. */
  11448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11449. /**
  11450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11451. * @param radius The radius of the hemisphere to emit from
  11452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11453. * @returns the emitter
  11454. */
  11455. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11456. /**
  11457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11458. * @param radius The radius of the sphere to emit from
  11459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11460. * @returns the emitter
  11461. */
  11462. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11463. /**
  11464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11465. * @param radius The radius of the sphere to emit from
  11466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11468. * @returns the emitter
  11469. */
  11470. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11471. /**
  11472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11473. * @param radius The radius of the emission cylinder
  11474. * @param height The height of the emission cylinder
  11475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11477. * @returns the emitter
  11478. */
  11479. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11480. /**
  11481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11482. * @param radius The radius of the cylinder to emit from
  11483. * @param height The height of the emission cylinder
  11484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11487. * @returns the emitter
  11488. */
  11489. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11490. /**
  11491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11492. * @param radius The radius of the cone to emit from
  11493. * @param angle The base angle of the cone
  11494. * @returns the emitter
  11495. */
  11496. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11497. /**
  11498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11503. * @returns the emitter
  11504. */
  11505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11506. }
  11507. }
  11508. declare module BABYLON {
  11509. /**
  11510. * Type of sub emitter
  11511. */
  11512. export enum SubEmitterType {
  11513. /**
  11514. * Attached to the particle over it's lifetime
  11515. */
  11516. ATTACHED = 0,
  11517. /**
  11518. * Created when the particle dies
  11519. */
  11520. END = 1
  11521. }
  11522. /**
  11523. * Sub emitter class used to emit particles from an existing particle
  11524. */
  11525. export class SubEmitter {
  11526. /**
  11527. * the particle system to be used by the sub emitter
  11528. */
  11529. particleSystem: ParticleSystem;
  11530. /**
  11531. * Type of the submitter (Default: END)
  11532. */
  11533. type: SubEmitterType;
  11534. /**
  11535. * 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)
  11536. * Note: This only is supported when using an emitter of type Mesh
  11537. */
  11538. inheritDirection: boolean;
  11539. /**
  11540. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11541. */
  11542. inheritedVelocityAmount: number;
  11543. /**
  11544. * Creates a sub emitter
  11545. * @param particleSystem the particle system to be used by the sub emitter
  11546. */
  11547. constructor(
  11548. /**
  11549. * the particle system to be used by the sub emitter
  11550. */
  11551. particleSystem: ParticleSystem);
  11552. /**
  11553. * Clones the sub emitter
  11554. * @returns the cloned sub emitter
  11555. */
  11556. clone(): SubEmitter;
  11557. /**
  11558. * Serialize current object to a JSON object
  11559. * @returns the serialized object
  11560. */
  11561. serialize(): any;
  11562. /** @hidden */
  11563. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11564. /**
  11565. * Creates a new SubEmitter from a serialized JSON version
  11566. * @param serializationObject defines the JSON object to read from
  11567. * @param scene defines the hosting scene
  11568. * @param rootUrl defines the rootUrl for data loading
  11569. * @returns a new SubEmitter
  11570. */
  11571. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11572. /** Release associated resources */
  11573. dispose(): void;
  11574. }
  11575. }
  11576. declare module BABYLON {
  11577. /** @hidden */
  11578. export var imageProcessingDeclaration: {
  11579. name: string;
  11580. shader: string;
  11581. };
  11582. }
  11583. declare module BABYLON {
  11584. /** @hidden */
  11585. export var imageProcessingFunctions: {
  11586. name: string;
  11587. shader: string;
  11588. };
  11589. }
  11590. declare module BABYLON {
  11591. /** @hidden */
  11592. export var particlesPixelShader: {
  11593. name: string;
  11594. shader: string;
  11595. };
  11596. }
  11597. declare module BABYLON {
  11598. /** @hidden */
  11599. export var particlesVertexShader: {
  11600. name: string;
  11601. shader: string;
  11602. };
  11603. }
  11604. declare module BABYLON {
  11605. /**
  11606. * This represents a particle system in Babylon.
  11607. * 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.
  11608. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11609. * @example https://doc.babylonjs.com/babylon101/particles
  11610. */
  11611. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11612. /**
  11613. * Billboard mode will only apply to Y axis
  11614. */
  11615. static readonly BILLBOARDMODE_Y: number;
  11616. /**
  11617. * Billboard mode will apply to all axes
  11618. */
  11619. static readonly BILLBOARDMODE_ALL: number;
  11620. /**
  11621. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11622. */
  11623. static readonly BILLBOARDMODE_STRETCHED: number;
  11624. /**
  11625. * This function can be defined to provide custom update for active particles.
  11626. * This function will be called instead of regular update (age, position, color, etc.).
  11627. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11628. */
  11629. updateFunction: (particles: Particle[]) => void;
  11630. private _emitterWorldMatrix;
  11631. /**
  11632. * This function can be defined to specify initial direction for every new particle.
  11633. * It by default use the emitterType defined function
  11634. */
  11635. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11636. /**
  11637. * This function can be defined to specify initial position for every new particle.
  11638. * It by default use the emitterType defined function
  11639. */
  11640. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11641. /**
  11642. * @hidden
  11643. */
  11644. _inheritedVelocityOffset: Vector3;
  11645. /**
  11646. * An event triggered when the system is disposed
  11647. */
  11648. onDisposeObservable: Observable<ParticleSystem>;
  11649. private _onDisposeObserver;
  11650. /**
  11651. * Sets a callback that will be triggered when the system is disposed
  11652. */
  11653. set onDispose(callback: () => void);
  11654. private _particles;
  11655. private _epsilon;
  11656. private _capacity;
  11657. private _stockParticles;
  11658. private _newPartsExcess;
  11659. private _vertexData;
  11660. private _vertexBuffer;
  11661. private _vertexBuffers;
  11662. private _spriteBuffer;
  11663. private _indexBuffer;
  11664. private _effect;
  11665. private _customEffect;
  11666. private _cachedDefines;
  11667. private _scaledColorStep;
  11668. private _colorDiff;
  11669. private _scaledDirection;
  11670. private _scaledGravity;
  11671. private _currentRenderId;
  11672. private _alive;
  11673. private _useInstancing;
  11674. private _started;
  11675. private _stopped;
  11676. private _actualFrame;
  11677. private _scaledUpdateSpeed;
  11678. private _vertexBufferSize;
  11679. /** @hidden */
  11680. _currentEmitRateGradient: Nullable<FactorGradient>;
  11681. /** @hidden */
  11682. _currentEmitRate1: number;
  11683. /** @hidden */
  11684. _currentEmitRate2: number;
  11685. /** @hidden */
  11686. _currentStartSizeGradient: Nullable<FactorGradient>;
  11687. /** @hidden */
  11688. _currentStartSize1: number;
  11689. /** @hidden */
  11690. _currentStartSize2: number;
  11691. private readonly _rawTextureWidth;
  11692. private _rampGradientsTexture;
  11693. private _useRampGradients;
  11694. /** Gets or sets a boolean indicating that ramp gradients must be used
  11695. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11696. */
  11697. get useRampGradients(): boolean;
  11698. set useRampGradients(value: boolean);
  11699. /**
  11700. * 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.
  11701. * 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: [])
  11702. */
  11703. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11704. private _subEmitters;
  11705. /**
  11706. * @hidden
  11707. * If the particle systems emitter should be disposed when the particle system is disposed
  11708. */
  11709. _disposeEmitterOnDispose: boolean;
  11710. /**
  11711. * The current active Sub-systems, this property is used by the root particle system only.
  11712. */
  11713. activeSubSystems: Array<ParticleSystem>;
  11714. /**
  11715. * Specifies if the particles are updated in emitter local space or world space
  11716. */
  11717. isLocal: boolean;
  11718. private _rootParticleSystem;
  11719. /**
  11720. * Gets the current list of active particles
  11721. */
  11722. get particles(): Particle[];
  11723. /**
  11724. * Gets the number of particles active at the same time.
  11725. * @returns The number of active particles.
  11726. */
  11727. getActiveCount(): number;
  11728. /**
  11729. * Returns the string "ParticleSystem"
  11730. * @returns a string containing the class name
  11731. */
  11732. getClassName(): string;
  11733. /**
  11734. * Gets a boolean indicating that the system is stopping
  11735. * @returns true if the system is currently stopping
  11736. */
  11737. isStopping(): boolean;
  11738. /**
  11739. * Instantiates a particle system.
  11740. * 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.
  11741. * @param name The name of the particle system
  11742. * @param capacity The max number of particles alive at the same time
  11743. * @param scene The scene the particle system belongs to
  11744. * @param customEffect a custom effect used to change the way particles are rendered by default
  11745. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11746. * @param epsilon Offset used to render the particles
  11747. */
  11748. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11749. private _addFactorGradient;
  11750. private _removeFactorGradient;
  11751. /**
  11752. * Adds a new life time gradient
  11753. * @param gradient defines the gradient to use (between 0 and 1)
  11754. * @param factor defines the life time factor to affect to the specified gradient
  11755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11756. * @returns the current particle system
  11757. */
  11758. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11759. /**
  11760. * Remove a specific life time gradient
  11761. * @param gradient defines the gradient to remove
  11762. * @returns the current particle system
  11763. */
  11764. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11765. /**
  11766. * Adds a new size gradient
  11767. * @param gradient defines the gradient to use (between 0 and 1)
  11768. * @param factor defines the size factor to affect to the specified gradient
  11769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11770. * @returns the current particle system
  11771. */
  11772. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11773. /**
  11774. * Remove a specific size gradient
  11775. * @param gradient defines the gradient to remove
  11776. * @returns the current particle system
  11777. */
  11778. removeSizeGradient(gradient: number): IParticleSystem;
  11779. /**
  11780. * Adds a new color remap gradient
  11781. * @param gradient defines the gradient to use (between 0 and 1)
  11782. * @param min defines the color remap minimal range
  11783. * @param max defines the color remap maximal range
  11784. * @returns the current particle system
  11785. */
  11786. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11787. /**
  11788. * Remove a specific color remap gradient
  11789. * @param gradient defines the gradient to remove
  11790. * @returns the current particle system
  11791. */
  11792. removeColorRemapGradient(gradient: number): IParticleSystem;
  11793. /**
  11794. * Adds a new alpha remap gradient
  11795. * @param gradient defines the gradient to use (between 0 and 1)
  11796. * @param min defines the alpha remap minimal range
  11797. * @param max defines the alpha remap maximal range
  11798. * @returns the current particle system
  11799. */
  11800. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11801. /**
  11802. * Remove a specific alpha remap gradient
  11803. * @param gradient defines the gradient to remove
  11804. * @returns the current particle system
  11805. */
  11806. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11807. /**
  11808. * Adds a new angular speed gradient
  11809. * @param gradient defines the gradient to use (between 0 and 1)
  11810. * @param factor defines the angular speed to affect to the specified gradient
  11811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11812. * @returns the current particle system
  11813. */
  11814. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11815. /**
  11816. * Remove a specific angular speed gradient
  11817. * @param gradient defines the gradient to remove
  11818. * @returns the current particle system
  11819. */
  11820. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11821. /**
  11822. * Adds a new velocity gradient
  11823. * @param gradient defines the gradient to use (between 0 and 1)
  11824. * @param factor defines the velocity to affect to the specified gradient
  11825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11826. * @returns the current particle system
  11827. */
  11828. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11829. /**
  11830. * Remove a specific velocity gradient
  11831. * @param gradient defines the gradient to remove
  11832. * @returns the current particle system
  11833. */
  11834. removeVelocityGradient(gradient: number): IParticleSystem;
  11835. /**
  11836. * Adds a new limit velocity gradient
  11837. * @param gradient defines the gradient to use (between 0 and 1)
  11838. * @param factor defines the limit velocity value to affect to the specified gradient
  11839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11840. * @returns the current particle system
  11841. */
  11842. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11843. /**
  11844. * Remove a specific limit velocity gradient
  11845. * @param gradient defines the gradient to remove
  11846. * @returns the current particle system
  11847. */
  11848. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11849. /**
  11850. * Adds a new drag gradient
  11851. * @param gradient defines the gradient to use (between 0 and 1)
  11852. * @param factor defines the drag value to affect to the specified gradient
  11853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11854. * @returns the current particle system
  11855. */
  11856. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11857. /**
  11858. * Remove a specific drag gradient
  11859. * @param gradient defines the gradient to remove
  11860. * @returns the current particle system
  11861. */
  11862. removeDragGradient(gradient: number): IParticleSystem;
  11863. /**
  11864. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11865. * @param gradient defines the gradient to use (between 0 and 1)
  11866. * @param factor defines the emit rate value to affect to the specified gradient
  11867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11868. * @returns the current particle system
  11869. */
  11870. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11871. /**
  11872. * Remove a specific emit rate gradient
  11873. * @param gradient defines the gradient to remove
  11874. * @returns the current particle system
  11875. */
  11876. removeEmitRateGradient(gradient: number): IParticleSystem;
  11877. /**
  11878. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11879. * @param gradient defines the gradient to use (between 0 and 1)
  11880. * @param factor defines the start size value to affect to the specified gradient
  11881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11882. * @returns the current particle system
  11883. */
  11884. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11885. /**
  11886. * Remove a specific start size gradient
  11887. * @param gradient defines the gradient to remove
  11888. * @returns the current particle system
  11889. */
  11890. removeStartSizeGradient(gradient: number): IParticleSystem;
  11891. private _createRampGradientTexture;
  11892. /**
  11893. * Gets the current list of ramp gradients.
  11894. * You must use addRampGradient and removeRampGradient to udpate this list
  11895. * @returns the list of ramp gradients
  11896. */
  11897. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11898. /** Force the system to rebuild all gradients that need to be resync */
  11899. forceRefreshGradients(): void;
  11900. private _syncRampGradientTexture;
  11901. /**
  11902. * Adds a new ramp gradient used to remap particle colors
  11903. * @param gradient defines the gradient to use (between 0 and 1)
  11904. * @param color defines the color to affect to the specified gradient
  11905. * @returns the current particle system
  11906. */
  11907. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11908. /**
  11909. * Remove a specific ramp gradient
  11910. * @param gradient defines the gradient to remove
  11911. * @returns the current particle system
  11912. */
  11913. removeRampGradient(gradient: number): ParticleSystem;
  11914. /**
  11915. * Adds a new color gradient
  11916. * @param gradient defines the gradient to use (between 0 and 1)
  11917. * @param color1 defines the color to affect to the specified gradient
  11918. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11919. * @returns this particle system
  11920. */
  11921. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11922. /**
  11923. * Remove a specific color gradient
  11924. * @param gradient defines the gradient to remove
  11925. * @returns this particle system
  11926. */
  11927. removeColorGradient(gradient: number): IParticleSystem;
  11928. private _fetchR;
  11929. protected _reset(): void;
  11930. private _resetEffect;
  11931. private _createVertexBuffers;
  11932. private _createIndexBuffer;
  11933. /**
  11934. * Gets the maximum number of particles active at the same time.
  11935. * @returns The max number of active particles.
  11936. */
  11937. getCapacity(): number;
  11938. /**
  11939. * Gets whether there are still active particles in the system.
  11940. * @returns True if it is alive, otherwise false.
  11941. */
  11942. isAlive(): boolean;
  11943. /**
  11944. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11945. * @returns True if it has been started, otherwise false.
  11946. */
  11947. isStarted(): boolean;
  11948. private _prepareSubEmitterInternalArray;
  11949. /**
  11950. * Starts the particle system and begins to emit
  11951. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11952. */
  11953. start(delay?: number): void;
  11954. /**
  11955. * Stops the particle system.
  11956. * @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.
  11957. */
  11958. stop(stopSubEmitters?: boolean): void;
  11959. /**
  11960. * Remove all active particles
  11961. */
  11962. reset(): void;
  11963. /**
  11964. * @hidden (for internal use only)
  11965. */
  11966. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11967. /**
  11968. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11969. * Its lifetime will start back at 0.
  11970. */
  11971. recycleParticle: (particle: Particle) => void;
  11972. private _stopSubEmitters;
  11973. private _createParticle;
  11974. private _removeFromRoot;
  11975. private _emitFromParticle;
  11976. private _update;
  11977. /** @hidden */
  11978. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11979. /** @hidden */
  11980. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11981. /** @hidden */
  11982. private _getEffect;
  11983. /**
  11984. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11985. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11986. */
  11987. animate(preWarmOnly?: boolean): void;
  11988. private _appendParticleVertices;
  11989. /**
  11990. * Rebuilds the particle system.
  11991. */
  11992. rebuild(): void;
  11993. /**
  11994. * Is this system ready to be used/rendered
  11995. * @return true if the system is ready
  11996. */
  11997. isReady(): boolean;
  11998. private _render;
  11999. /**
  12000. * Renders the particle system in its current state.
  12001. * @returns the current number of particles
  12002. */
  12003. render(): number;
  12004. /**
  12005. * Disposes the particle system and free the associated resources
  12006. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12007. */
  12008. dispose(disposeTexture?: boolean): void;
  12009. /**
  12010. * Clones the particle system.
  12011. * @param name The name of the cloned object
  12012. * @param newEmitter The new emitter to use
  12013. * @returns the cloned particle system
  12014. */
  12015. clone(name: string, newEmitter: any): ParticleSystem;
  12016. /**
  12017. * Serializes the particle system to a JSON object
  12018. * @param serializeTexture defines if the texture must be serialized as well
  12019. * @returns the JSON object
  12020. */
  12021. serialize(serializeTexture?: boolean): any;
  12022. /** @hidden */
  12023. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12024. /** @hidden */
  12025. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12026. /**
  12027. * Parses a JSON object to create a particle system.
  12028. * @param parsedParticleSystem The JSON object to parse
  12029. * @param scene The scene to create the particle system in
  12030. * @param rootUrl The root url to use to load external dependencies like texture
  12031. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12032. * @returns the Parsed particle system
  12033. */
  12034. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12035. }
  12036. }
  12037. declare module BABYLON {
  12038. /**
  12039. * A particle represents one of the element emitted by a particle system.
  12040. * This is mainly define by its coordinates, direction, velocity and age.
  12041. */
  12042. export class Particle {
  12043. /**
  12044. * The particle system the particle belongs to.
  12045. */
  12046. particleSystem: ParticleSystem;
  12047. private static _Count;
  12048. /**
  12049. * Unique ID of the particle
  12050. */
  12051. id: number;
  12052. /**
  12053. * The world position of the particle in the scene.
  12054. */
  12055. position: Vector3;
  12056. /**
  12057. * The world direction of the particle in the scene.
  12058. */
  12059. direction: Vector3;
  12060. /**
  12061. * The color of the particle.
  12062. */
  12063. color: Color4;
  12064. /**
  12065. * The color change of the particle per step.
  12066. */
  12067. colorStep: Color4;
  12068. /**
  12069. * Defines how long will the life of the particle be.
  12070. */
  12071. lifeTime: number;
  12072. /**
  12073. * The current age of the particle.
  12074. */
  12075. age: number;
  12076. /**
  12077. * The current size of the particle.
  12078. */
  12079. size: number;
  12080. /**
  12081. * The current scale of the particle.
  12082. */
  12083. scale: Vector2;
  12084. /**
  12085. * The current angle of the particle.
  12086. */
  12087. angle: number;
  12088. /**
  12089. * Defines how fast is the angle changing.
  12090. */
  12091. angularSpeed: number;
  12092. /**
  12093. * Defines the cell index used by the particle to be rendered from a sprite.
  12094. */
  12095. cellIndex: number;
  12096. /**
  12097. * The information required to support color remapping
  12098. */
  12099. remapData: Vector4;
  12100. /** @hidden */
  12101. _randomCellOffset?: number;
  12102. /** @hidden */
  12103. _initialDirection: Nullable<Vector3>;
  12104. /** @hidden */
  12105. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12106. /** @hidden */
  12107. _initialStartSpriteCellID: number;
  12108. /** @hidden */
  12109. _initialEndSpriteCellID: number;
  12110. /** @hidden */
  12111. _currentColorGradient: Nullable<ColorGradient>;
  12112. /** @hidden */
  12113. _currentColor1: Color4;
  12114. /** @hidden */
  12115. _currentColor2: Color4;
  12116. /** @hidden */
  12117. _currentSizeGradient: Nullable<FactorGradient>;
  12118. /** @hidden */
  12119. _currentSize1: number;
  12120. /** @hidden */
  12121. _currentSize2: number;
  12122. /** @hidden */
  12123. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12124. /** @hidden */
  12125. _currentAngularSpeed1: number;
  12126. /** @hidden */
  12127. _currentAngularSpeed2: number;
  12128. /** @hidden */
  12129. _currentVelocityGradient: Nullable<FactorGradient>;
  12130. /** @hidden */
  12131. _currentVelocity1: number;
  12132. /** @hidden */
  12133. _currentVelocity2: number;
  12134. /** @hidden */
  12135. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12136. /** @hidden */
  12137. _currentLimitVelocity1: number;
  12138. /** @hidden */
  12139. _currentLimitVelocity2: number;
  12140. /** @hidden */
  12141. _currentDragGradient: Nullable<FactorGradient>;
  12142. /** @hidden */
  12143. _currentDrag1: number;
  12144. /** @hidden */
  12145. _currentDrag2: number;
  12146. /** @hidden */
  12147. _randomNoiseCoordinates1: Vector3;
  12148. /** @hidden */
  12149. _randomNoiseCoordinates2: Vector3;
  12150. /** @hidden */
  12151. _localPosition?: Vector3;
  12152. /**
  12153. * Creates a new instance Particle
  12154. * @param particleSystem the particle system the particle belongs to
  12155. */
  12156. constructor(
  12157. /**
  12158. * The particle system the particle belongs to.
  12159. */
  12160. particleSystem: ParticleSystem);
  12161. private updateCellInfoFromSystem;
  12162. /**
  12163. * Defines how the sprite cell index is updated for the particle
  12164. */
  12165. updateCellIndex(): void;
  12166. /** @hidden */
  12167. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12168. /** @hidden */
  12169. _inheritParticleInfoToSubEmitters(): void;
  12170. /** @hidden */
  12171. _reset(): void;
  12172. /**
  12173. * Copy the properties of particle to another one.
  12174. * @param other the particle to copy the information to.
  12175. */
  12176. copyTo(other: Particle): void;
  12177. }
  12178. }
  12179. declare module BABYLON {
  12180. /**
  12181. * Particle emitter represents a volume emitting particles.
  12182. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12183. */
  12184. export interface IParticleEmitterType {
  12185. /**
  12186. * Called by the particle System when the direction is computed for the created particle.
  12187. * @param worldMatrix is the world matrix of the particle system
  12188. * @param directionToUpdate is the direction vector to update with the result
  12189. * @param particle is the particle we are computed the direction for
  12190. * @param isLocal defines if the direction should be set in local space
  12191. */
  12192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12193. /**
  12194. * Called by the particle System when the position is computed for the created particle.
  12195. * @param worldMatrix is the world matrix of the particle system
  12196. * @param positionToUpdate is the position vector to update with the result
  12197. * @param particle is the particle we are computed the position for
  12198. * @param isLocal defines if the position should be set in local space
  12199. */
  12200. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12201. /**
  12202. * Clones the current emitter and returns a copy of it
  12203. * @returns the new emitter
  12204. */
  12205. clone(): IParticleEmitterType;
  12206. /**
  12207. * Called by the GPUParticleSystem to setup the update shader
  12208. * @param effect defines the update shader
  12209. */
  12210. applyToShader(effect: Effect): void;
  12211. /**
  12212. * Returns a string to use to update the GPU particles update shader
  12213. * @returns the effect defines string
  12214. */
  12215. getEffectDefines(): string;
  12216. /**
  12217. * Returns a string representing the class name
  12218. * @returns a string containing the class name
  12219. */
  12220. getClassName(): string;
  12221. /**
  12222. * Serializes the particle system to a JSON object.
  12223. * @returns the JSON object
  12224. */
  12225. serialize(): any;
  12226. /**
  12227. * Parse properties from a JSON object
  12228. * @param serializationObject defines the JSON object
  12229. * @param scene defines the hosting scene
  12230. */
  12231. parse(serializationObject: any, scene: Scene): void;
  12232. }
  12233. }
  12234. declare module BABYLON {
  12235. /**
  12236. * Particle emitter emitting particles from the inside of a box.
  12237. * It emits the particles randomly between 2 given directions.
  12238. */
  12239. export class BoxParticleEmitter implements IParticleEmitterType {
  12240. /**
  12241. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12242. */
  12243. direction1: Vector3;
  12244. /**
  12245. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12246. */
  12247. direction2: Vector3;
  12248. /**
  12249. * 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.
  12250. */
  12251. minEmitBox: Vector3;
  12252. /**
  12253. * 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.
  12254. */
  12255. maxEmitBox: Vector3;
  12256. /**
  12257. * Creates a new instance BoxParticleEmitter
  12258. */
  12259. constructor();
  12260. /**
  12261. * Called by the particle System when the direction is computed for the created particle.
  12262. * @param worldMatrix is the world matrix of the particle system
  12263. * @param directionToUpdate is the direction vector to update with the result
  12264. * @param particle is the particle we are computed the direction for
  12265. * @param isLocal defines if the direction should be set in local space
  12266. */
  12267. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12268. /**
  12269. * Called by the particle System when the position is computed for the created particle.
  12270. * @param worldMatrix is the world matrix of the particle system
  12271. * @param positionToUpdate is the position vector to update with the result
  12272. * @param particle is the particle we are computed the position for
  12273. * @param isLocal defines if the position should be set in local space
  12274. */
  12275. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12276. /**
  12277. * Clones the current emitter and returns a copy of it
  12278. * @returns the new emitter
  12279. */
  12280. clone(): BoxParticleEmitter;
  12281. /**
  12282. * Called by the GPUParticleSystem to setup the update shader
  12283. * @param effect defines the update shader
  12284. */
  12285. applyToShader(effect: Effect): void;
  12286. /**
  12287. * Returns a string to use to update the GPU particles update shader
  12288. * @returns a string containng the defines string
  12289. */
  12290. getEffectDefines(): string;
  12291. /**
  12292. * Returns the string "BoxParticleEmitter"
  12293. * @returns a string containing the class name
  12294. */
  12295. getClassName(): string;
  12296. /**
  12297. * Serializes the particle system to a JSON object.
  12298. * @returns the JSON object
  12299. */
  12300. serialize(): any;
  12301. /**
  12302. * Parse properties from a JSON object
  12303. * @param serializationObject defines the JSON object
  12304. */
  12305. parse(serializationObject: any): void;
  12306. }
  12307. }
  12308. declare module BABYLON {
  12309. /**
  12310. * Particle emitter emitting particles from the inside of a cone.
  12311. * It emits the particles alongside the cone volume from the base to the particle.
  12312. * The emission direction might be randomized.
  12313. */
  12314. export class ConeParticleEmitter implements IParticleEmitterType {
  12315. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12316. directionRandomizer: number;
  12317. private _radius;
  12318. private _angle;
  12319. private _height;
  12320. /**
  12321. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12322. */
  12323. radiusRange: number;
  12324. /**
  12325. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12326. */
  12327. heightRange: number;
  12328. /**
  12329. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12330. */
  12331. emitFromSpawnPointOnly: boolean;
  12332. /**
  12333. * Gets or sets the radius of the emission cone
  12334. */
  12335. get radius(): number;
  12336. set radius(value: number);
  12337. /**
  12338. * Gets or sets the angle of the emission cone
  12339. */
  12340. get angle(): number;
  12341. set angle(value: number);
  12342. private _buildHeight;
  12343. /**
  12344. * Creates a new instance ConeParticleEmitter
  12345. * @param radius the radius of the emission cone (1 by default)
  12346. * @param angle the cone base angle (PI by default)
  12347. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12348. */
  12349. constructor(radius?: number, angle?: number,
  12350. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12351. directionRandomizer?: number);
  12352. /**
  12353. * Called by the particle System when the direction is computed for the created particle.
  12354. * @param worldMatrix is the world matrix of the particle system
  12355. * @param directionToUpdate is the direction vector to update with the result
  12356. * @param particle is the particle we are computed the direction for
  12357. * @param isLocal defines if the direction should be set in local space
  12358. */
  12359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12360. /**
  12361. * Called by the particle System when the position is computed for the created particle.
  12362. * @param worldMatrix is the world matrix of the particle system
  12363. * @param positionToUpdate is the position vector to update with the result
  12364. * @param particle is the particle we are computed the position for
  12365. * @param isLocal defines if the position should be set in local space
  12366. */
  12367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12368. /**
  12369. * Clones the current emitter and returns a copy of it
  12370. * @returns the new emitter
  12371. */
  12372. clone(): ConeParticleEmitter;
  12373. /**
  12374. * Called by the GPUParticleSystem to setup the update shader
  12375. * @param effect defines the update shader
  12376. */
  12377. applyToShader(effect: Effect): void;
  12378. /**
  12379. * Returns a string to use to update the GPU particles update shader
  12380. * @returns a string containng the defines string
  12381. */
  12382. getEffectDefines(): string;
  12383. /**
  12384. * Returns the string "ConeParticleEmitter"
  12385. * @returns a string containing the class name
  12386. */
  12387. getClassName(): string;
  12388. /**
  12389. * Serializes the particle system to a JSON object.
  12390. * @returns the JSON object
  12391. */
  12392. serialize(): any;
  12393. /**
  12394. * Parse properties from a JSON object
  12395. * @param serializationObject defines the JSON object
  12396. */
  12397. parse(serializationObject: any): void;
  12398. }
  12399. }
  12400. declare module BABYLON {
  12401. /**
  12402. * Particle emitter emitting particles from the inside of a cylinder.
  12403. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12404. */
  12405. export class CylinderParticleEmitter implements IParticleEmitterType {
  12406. /**
  12407. * The radius of the emission cylinder.
  12408. */
  12409. radius: number;
  12410. /**
  12411. * The height of the emission cylinder.
  12412. */
  12413. height: number;
  12414. /**
  12415. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12416. */
  12417. radiusRange: number;
  12418. /**
  12419. * How much to randomize the particle direction [0-1].
  12420. */
  12421. directionRandomizer: number;
  12422. /**
  12423. * Creates a new instance CylinderParticleEmitter
  12424. * @param radius the radius of the emission cylinder (1 by default)
  12425. * @param height the height of the emission cylinder (1 by default)
  12426. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12427. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12428. */
  12429. constructor(
  12430. /**
  12431. * The radius of the emission cylinder.
  12432. */
  12433. radius?: number,
  12434. /**
  12435. * The height of the emission cylinder.
  12436. */
  12437. height?: number,
  12438. /**
  12439. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12440. */
  12441. radiusRange?: number,
  12442. /**
  12443. * How much to randomize the particle direction [0-1].
  12444. */
  12445. directionRandomizer?: number);
  12446. /**
  12447. * Called by the particle System when the direction is computed for the created particle.
  12448. * @param worldMatrix is the world matrix of the particle system
  12449. * @param directionToUpdate is the direction vector to update with the result
  12450. * @param particle is the particle we are computed the direction for
  12451. * @param isLocal defines if the direction should be set in local space
  12452. */
  12453. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12454. /**
  12455. * Called by the particle System when the position is computed for the created particle.
  12456. * @param worldMatrix is the world matrix of the particle system
  12457. * @param positionToUpdate is the position vector to update with the result
  12458. * @param particle is the particle we are computed the position for
  12459. * @param isLocal defines if the position should be set in local space
  12460. */
  12461. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12462. /**
  12463. * Clones the current emitter and returns a copy of it
  12464. * @returns the new emitter
  12465. */
  12466. clone(): CylinderParticleEmitter;
  12467. /**
  12468. * Called by the GPUParticleSystem to setup the update shader
  12469. * @param effect defines the update shader
  12470. */
  12471. applyToShader(effect: Effect): void;
  12472. /**
  12473. * Returns a string to use to update the GPU particles update shader
  12474. * @returns a string containng the defines string
  12475. */
  12476. getEffectDefines(): string;
  12477. /**
  12478. * Returns the string "CylinderParticleEmitter"
  12479. * @returns a string containing the class name
  12480. */
  12481. getClassName(): string;
  12482. /**
  12483. * Serializes the particle system to a JSON object.
  12484. * @returns the JSON object
  12485. */
  12486. serialize(): any;
  12487. /**
  12488. * Parse properties from a JSON object
  12489. * @param serializationObject defines the JSON object
  12490. */
  12491. parse(serializationObject: any): void;
  12492. }
  12493. /**
  12494. * Particle emitter emitting particles from the inside of a cylinder.
  12495. * It emits the particles randomly between two vectors.
  12496. */
  12497. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12498. /**
  12499. * The min limit of the emission direction.
  12500. */
  12501. direction1: Vector3;
  12502. /**
  12503. * The max limit of the emission direction.
  12504. */
  12505. direction2: Vector3;
  12506. /**
  12507. * Creates a new instance CylinderDirectedParticleEmitter
  12508. * @param radius the radius of the emission cylinder (1 by default)
  12509. * @param height the height of the emission cylinder (1 by default)
  12510. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12511. * @param direction1 the min limit of the emission direction (up vector by default)
  12512. * @param direction2 the max limit of the emission direction (up vector by default)
  12513. */
  12514. constructor(radius?: number, height?: number, radiusRange?: number,
  12515. /**
  12516. * The min limit of the emission direction.
  12517. */
  12518. direction1?: Vector3,
  12519. /**
  12520. * The max limit of the emission direction.
  12521. */
  12522. direction2?: Vector3);
  12523. /**
  12524. * Called by the particle System when the direction is computed for the created particle.
  12525. * @param worldMatrix is the world matrix of the particle system
  12526. * @param directionToUpdate is the direction vector to update with the result
  12527. * @param particle is the particle we are computed the direction for
  12528. */
  12529. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12530. /**
  12531. * Clones the current emitter and returns a copy of it
  12532. * @returns the new emitter
  12533. */
  12534. clone(): CylinderDirectedParticleEmitter;
  12535. /**
  12536. * Called by the GPUParticleSystem to setup the update shader
  12537. * @param effect defines the update shader
  12538. */
  12539. applyToShader(effect: Effect): void;
  12540. /**
  12541. * Returns a string to use to update the GPU particles update shader
  12542. * @returns a string containng the defines string
  12543. */
  12544. getEffectDefines(): string;
  12545. /**
  12546. * Returns the string "CylinderDirectedParticleEmitter"
  12547. * @returns a string containing the class name
  12548. */
  12549. getClassName(): string;
  12550. /**
  12551. * Serializes the particle system to a JSON object.
  12552. * @returns the JSON object
  12553. */
  12554. serialize(): any;
  12555. /**
  12556. * Parse properties from a JSON object
  12557. * @param serializationObject defines the JSON object
  12558. */
  12559. parse(serializationObject: any): void;
  12560. }
  12561. }
  12562. declare module BABYLON {
  12563. /**
  12564. * Particle emitter emitting particles from the inside of a hemisphere.
  12565. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12566. */
  12567. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12568. /**
  12569. * The radius of the emission hemisphere.
  12570. */
  12571. radius: number;
  12572. /**
  12573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12574. */
  12575. radiusRange: number;
  12576. /**
  12577. * How much to randomize the particle direction [0-1].
  12578. */
  12579. directionRandomizer: number;
  12580. /**
  12581. * Creates a new instance HemisphericParticleEmitter
  12582. * @param radius the radius of the emission hemisphere (1 by default)
  12583. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12584. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12585. */
  12586. constructor(
  12587. /**
  12588. * The radius of the emission hemisphere.
  12589. */
  12590. radius?: number,
  12591. /**
  12592. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12593. */
  12594. radiusRange?: number,
  12595. /**
  12596. * How much to randomize the particle direction [0-1].
  12597. */
  12598. directionRandomizer?: number);
  12599. /**
  12600. * Called by the particle System when the direction is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param directionToUpdate is the direction vector to update with the result
  12603. * @param particle is the particle we are computed the direction for
  12604. * @param isLocal defines if the direction should be set in local space
  12605. */
  12606. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12607. /**
  12608. * Called by the particle System when the position is computed for the created particle.
  12609. * @param worldMatrix is the world matrix of the particle system
  12610. * @param positionToUpdate is the position vector to update with the result
  12611. * @param particle is the particle we are computed the position for
  12612. * @param isLocal defines if the position should be set in local space
  12613. */
  12614. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12615. /**
  12616. * Clones the current emitter and returns a copy of it
  12617. * @returns the new emitter
  12618. */
  12619. clone(): HemisphericParticleEmitter;
  12620. /**
  12621. * Called by the GPUParticleSystem to setup the update shader
  12622. * @param effect defines the update shader
  12623. */
  12624. applyToShader(effect: Effect): void;
  12625. /**
  12626. * Returns a string to use to update the GPU particles update shader
  12627. * @returns a string containng the defines string
  12628. */
  12629. getEffectDefines(): string;
  12630. /**
  12631. * Returns the string "HemisphericParticleEmitter"
  12632. * @returns a string containing the class name
  12633. */
  12634. getClassName(): string;
  12635. /**
  12636. * Serializes the particle system to a JSON object.
  12637. * @returns the JSON object
  12638. */
  12639. serialize(): any;
  12640. /**
  12641. * Parse properties from a JSON object
  12642. * @param serializationObject defines the JSON object
  12643. */
  12644. parse(serializationObject: any): void;
  12645. }
  12646. }
  12647. declare module BABYLON {
  12648. /**
  12649. * Particle emitter emitting particles from a point.
  12650. * It emits the particles randomly between 2 given directions.
  12651. */
  12652. export class PointParticleEmitter implements IParticleEmitterType {
  12653. /**
  12654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12655. */
  12656. direction1: Vector3;
  12657. /**
  12658. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12659. */
  12660. direction2: Vector3;
  12661. /**
  12662. * Creates a new instance PointParticleEmitter
  12663. */
  12664. constructor();
  12665. /**
  12666. * Called by the particle System when the direction is computed for the created particle.
  12667. * @param worldMatrix is the world matrix of the particle system
  12668. * @param directionToUpdate is the direction vector to update with the result
  12669. * @param particle is the particle we are computed the direction for
  12670. * @param isLocal defines if the direction should be set in local space
  12671. */
  12672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12673. /**
  12674. * Called by the particle System when the position is computed for the created particle.
  12675. * @param worldMatrix is the world matrix of the particle system
  12676. * @param positionToUpdate is the position vector to update with the result
  12677. * @param particle is the particle we are computed the position for
  12678. * @param isLocal defines if the position should be set in local space
  12679. */
  12680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12681. /**
  12682. * Clones the current emitter and returns a copy of it
  12683. * @returns the new emitter
  12684. */
  12685. clone(): PointParticleEmitter;
  12686. /**
  12687. * Called by the GPUParticleSystem to setup the update shader
  12688. * @param effect defines the update shader
  12689. */
  12690. applyToShader(effect: Effect): void;
  12691. /**
  12692. * Returns a string to use to update the GPU particles update shader
  12693. * @returns a string containng the defines string
  12694. */
  12695. getEffectDefines(): string;
  12696. /**
  12697. * Returns the string "PointParticleEmitter"
  12698. * @returns a string containing the class name
  12699. */
  12700. getClassName(): string;
  12701. /**
  12702. * Serializes the particle system to a JSON object.
  12703. * @returns the JSON object
  12704. */
  12705. serialize(): any;
  12706. /**
  12707. * Parse properties from a JSON object
  12708. * @param serializationObject defines the JSON object
  12709. */
  12710. parse(serializationObject: any): void;
  12711. }
  12712. }
  12713. declare module BABYLON {
  12714. /**
  12715. * Particle emitter emitting particles from the inside of a sphere.
  12716. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12717. */
  12718. export class SphereParticleEmitter implements IParticleEmitterType {
  12719. /**
  12720. * The radius of the emission sphere.
  12721. */
  12722. radius: number;
  12723. /**
  12724. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12725. */
  12726. radiusRange: number;
  12727. /**
  12728. * How much to randomize the particle direction [0-1].
  12729. */
  12730. directionRandomizer: number;
  12731. /**
  12732. * Creates a new instance SphereParticleEmitter
  12733. * @param radius the radius of the emission sphere (1 by default)
  12734. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12735. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12736. */
  12737. constructor(
  12738. /**
  12739. * The radius of the emission sphere.
  12740. */
  12741. radius?: number,
  12742. /**
  12743. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12744. */
  12745. radiusRange?: number,
  12746. /**
  12747. * How much to randomize the particle direction [0-1].
  12748. */
  12749. directionRandomizer?: number);
  12750. /**
  12751. * Called by the particle System when the direction is computed for the created particle.
  12752. * @param worldMatrix is the world matrix of the particle system
  12753. * @param directionToUpdate is the direction vector to update with the result
  12754. * @param particle is the particle we are computed the direction for
  12755. * @param isLocal defines if the direction should be set in local space
  12756. */
  12757. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12758. /**
  12759. * Called by the particle System when the position is computed for the created particle.
  12760. * @param worldMatrix is the world matrix of the particle system
  12761. * @param positionToUpdate is the position vector to update with the result
  12762. * @param particle is the particle we are computed the position for
  12763. * @param isLocal defines if the position should be set in local space
  12764. */
  12765. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12766. /**
  12767. * Clones the current emitter and returns a copy of it
  12768. * @returns the new emitter
  12769. */
  12770. clone(): SphereParticleEmitter;
  12771. /**
  12772. * Called by the GPUParticleSystem to setup the update shader
  12773. * @param effect defines the update shader
  12774. */
  12775. applyToShader(effect: Effect): void;
  12776. /**
  12777. * Returns a string to use to update the GPU particles update shader
  12778. * @returns a string containng the defines string
  12779. */
  12780. getEffectDefines(): string;
  12781. /**
  12782. * Returns the string "SphereParticleEmitter"
  12783. * @returns a string containing the class name
  12784. */
  12785. getClassName(): string;
  12786. /**
  12787. * Serializes the particle system to a JSON object.
  12788. * @returns the JSON object
  12789. */
  12790. serialize(): any;
  12791. /**
  12792. * Parse properties from a JSON object
  12793. * @param serializationObject defines the JSON object
  12794. */
  12795. parse(serializationObject: any): void;
  12796. }
  12797. /**
  12798. * Particle emitter emitting particles from the inside of a sphere.
  12799. * It emits the particles randomly between two vectors.
  12800. */
  12801. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12802. /**
  12803. * The min limit of the emission direction.
  12804. */
  12805. direction1: Vector3;
  12806. /**
  12807. * The max limit of the emission direction.
  12808. */
  12809. direction2: Vector3;
  12810. /**
  12811. * Creates a new instance SphereDirectedParticleEmitter
  12812. * @param radius the radius of the emission sphere (1 by default)
  12813. * @param direction1 the min limit of the emission direction (up vector by default)
  12814. * @param direction2 the max limit of the emission direction (up vector by default)
  12815. */
  12816. constructor(radius?: number,
  12817. /**
  12818. * The min limit of the emission direction.
  12819. */
  12820. direction1?: Vector3,
  12821. /**
  12822. * The max limit of the emission direction.
  12823. */
  12824. direction2?: Vector3);
  12825. /**
  12826. * Called by the particle System when the direction is computed for the created particle.
  12827. * @param worldMatrix is the world matrix of the particle system
  12828. * @param directionToUpdate is the direction vector to update with the result
  12829. * @param particle is the particle we are computed the direction for
  12830. */
  12831. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12832. /**
  12833. * Clones the current emitter and returns a copy of it
  12834. * @returns the new emitter
  12835. */
  12836. clone(): SphereDirectedParticleEmitter;
  12837. /**
  12838. * Called by the GPUParticleSystem to setup the update shader
  12839. * @param effect defines the update shader
  12840. */
  12841. applyToShader(effect: Effect): void;
  12842. /**
  12843. * Returns a string to use to update the GPU particles update shader
  12844. * @returns a string containng the defines string
  12845. */
  12846. getEffectDefines(): string;
  12847. /**
  12848. * Returns the string "SphereDirectedParticleEmitter"
  12849. * @returns a string containing the class name
  12850. */
  12851. getClassName(): string;
  12852. /**
  12853. * Serializes the particle system to a JSON object.
  12854. * @returns the JSON object
  12855. */
  12856. serialize(): any;
  12857. /**
  12858. * Parse properties from a JSON object
  12859. * @param serializationObject defines the JSON object
  12860. */
  12861. parse(serializationObject: any): void;
  12862. }
  12863. }
  12864. declare module BABYLON {
  12865. /**
  12866. * Particle emitter emitting particles from a custom list of positions.
  12867. */
  12868. export class CustomParticleEmitter implements IParticleEmitterType {
  12869. /**
  12870. * Gets or sets the position generator that will create the inital position of each particle.
  12871. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12872. */
  12873. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12874. /**
  12875. * Gets or sets the destination generator that will create the final destination of each particle.
  12876. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12877. */
  12878. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12879. /**
  12880. * Creates a new instance CustomParticleEmitter
  12881. */
  12882. constructor();
  12883. /**
  12884. * Called by the particle System when the direction is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param directionToUpdate is the direction vector to update with the result
  12887. * @param particle is the particle we are computed the direction for
  12888. * @param isLocal defines if the direction should be set in local space
  12889. */
  12890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Called by the particle System when the position is computed for the created particle.
  12893. * @param worldMatrix is the world matrix of the particle system
  12894. * @param positionToUpdate is the position vector to update with the result
  12895. * @param particle is the particle we are computed the position for
  12896. * @param isLocal defines if the position should be set in local space
  12897. */
  12898. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12899. /**
  12900. * Clones the current emitter and returns a copy of it
  12901. * @returns the new emitter
  12902. */
  12903. clone(): CustomParticleEmitter;
  12904. /**
  12905. * Called by the GPUParticleSystem to setup the update shader
  12906. * @param effect defines the update shader
  12907. */
  12908. applyToShader(effect: Effect): void;
  12909. /**
  12910. * Returns a string to use to update the GPU particles update shader
  12911. * @returns a string containng the defines string
  12912. */
  12913. getEffectDefines(): string;
  12914. /**
  12915. * Returns the string "PointParticleEmitter"
  12916. * @returns a string containing the class name
  12917. */
  12918. getClassName(): string;
  12919. /**
  12920. * Serializes the particle system to a JSON object.
  12921. * @returns the JSON object
  12922. */
  12923. serialize(): any;
  12924. /**
  12925. * Parse properties from a JSON object
  12926. * @param serializationObject defines the JSON object
  12927. */
  12928. parse(serializationObject: any): void;
  12929. }
  12930. }
  12931. declare module BABYLON {
  12932. /**
  12933. * Particle emitter emitting particles from the inside of a box.
  12934. * It emits the particles randomly between 2 given directions.
  12935. */
  12936. export class MeshParticleEmitter implements IParticleEmitterType {
  12937. private _indices;
  12938. private _positions;
  12939. private _normals;
  12940. private _storedNormal;
  12941. private _mesh;
  12942. /**
  12943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12944. */
  12945. direction1: Vector3;
  12946. /**
  12947. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12948. */
  12949. direction2: Vector3;
  12950. /**
  12951. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12952. */
  12953. useMeshNormalsForDirection: boolean;
  12954. /** Defines the mesh to use as source */
  12955. get mesh(): Nullable<AbstractMesh>;
  12956. set mesh(value: Nullable<AbstractMesh>);
  12957. /**
  12958. * Creates a new instance MeshParticleEmitter
  12959. * @param mesh defines the mesh to use as source
  12960. */
  12961. constructor(mesh?: Nullable<AbstractMesh>);
  12962. /**
  12963. * Called by the particle System when the direction is computed for the created particle.
  12964. * @param worldMatrix is the world matrix of the particle system
  12965. * @param directionToUpdate is the direction vector to update with the result
  12966. * @param particle is the particle we are computed the direction for
  12967. * @param isLocal defines if the direction should be set in local space
  12968. */
  12969. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12970. /**
  12971. * Called by the particle System when the position is computed for the created particle.
  12972. * @param worldMatrix is the world matrix of the particle system
  12973. * @param positionToUpdate is the position vector to update with the result
  12974. * @param particle is the particle we are computed the position for
  12975. * @param isLocal defines if the position should be set in local space
  12976. */
  12977. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12978. /**
  12979. * Clones the current emitter and returns a copy of it
  12980. * @returns the new emitter
  12981. */
  12982. clone(): MeshParticleEmitter;
  12983. /**
  12984. * Called by the GPUParticleSystem to setup the update shader
  12985. * @param effect defines the update shader
  12986. */
  12987. applyToShader(effect: Effect): void;
  12988. /**
  12989. * Returns a string to use to update the GPU particles update shader
  12990. * @returns a string containng the defines string
  12991. */
  12992. getEffectDefines(): string;
  12993. /**
  12994. * Returns the string "BoxParticleEmitter"
  12995. * @returns a string containing the class name
  12996. */
  12997. getClassName(): string;
  12998. /**
  12999. * Serializes the particle system to a JSON object.
  13000. * @returns the JSON object
  13001. */
  13002. serialize(): any;
  13003. /**
  13004. * Parse properties from a JSON object
  13005. * @param serializationObject defines the JSON object
  13006. * @param scene defines the hosting scene
  13007. */
  13008. parse(serializationObject: any, scene: Scene): void;
  13009. }
  13010. }
  13011. declare module BABYLON {
  13012. /**
  13013. * Interface representing a particle system in Babylon.js.
  13014. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13015. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13016. */
  13017. export interface IParticleSystem {
  13018. /**
  13019. * List of animations used by the particle system.
  13020. */
  13021. animations: Animation[];
  13022. /**
  13023. * The id of the Particle system.
  13024. */
  13025. id: string;
  13026. /**
  13027. * The name of the Particle system.
  13028. */
  13029. name: string;
  13030. /**
  13031. * The emitter represents the Mesh or position we are attaching the particle system to.
  13032. */
  13033. emitter: Nullable<AbstractMesh | Vector3>;
  13034. /**
  13035. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13036. */
  13037. isBillboardBased: boolean;
  13038. /**
  13039. * The rendering group used by the Particle system to chose when to render.
  13040. */
  13041. renderingGroupId: number;
  13042. /**
  13043. * The layer mask we are rendering the particles through.
  13044. */
  13045. layerMask: number;
  13046. /**
  13047. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13048. */
  13049. updateSpeed: number;
  13050. /**
  13051. * The amount of time the particle system is running (depends of the overall update speed).
  13052. */
  13053. targetStopDuration: number;
  13054. /**
  13055. * The texture used to render each particle. (this can be a spritesheet)
  13056. */
  13057. particleTexture: Nullable<Texture>;
  13058. /**
  13059. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13060. */
  13061. blendMode: number;
  13062. /**
  13063. * Minimum life time of emitting particles.
  13064. */
  13065. minLifeTime: number;
  13066. /**
  13067. * Maximum life time of emitting particles.
  13068. */
  13069. maxLifeTime: number;
  13070. /**
  13071. * Minimum Size of emitting particles.
  13072. */
  13073. minSize: number;
  13074. /**
  13075. * Maximum Size of emitting particles.
  13076. */
  13077. maxSize: number;
  13078. /**
  13079. * Minimum scale of emitting particles on X axis.
  13080. */
  13081. minScaleX: number;
  13082. /**
  13083. * Maximum scale of emitting particles on X axis.
  13084. */
  13085. maxScaleX: number;
  13086. /**
  13087. * Minimum scale of emitting particles on Y axis.
  13088. */
  13089. minScaleY: number;
  13090. /**
  13091. * Maximum scale of emitting particles on Y axis.
  13092. */
  13093. maxScaleY: number;
  13094. /**
  13095. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13096. */
  13097. color1: Color4;
  13098. /**
  13099. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13100. */
  13101. color2: Color4;
  13102. /**
  13103. * Color the particle will have at the end of its lifetime.
  13104. */
  13105. colorDead: Color4;
  13106. /**
  13107. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13108. */
  13109. emitRate: number;
  13110. /**
  13111. * You can use gravity if you want to give an orientation to your particles.
  13112. */
  13113. gravity: Vector3;
  13114. /**
  13115. * Minimum power of emitting particles.
  13116. */
  13117. minEmitPower: number;
  13118. /**
  13119. * Maximum power of emitting particles.
  13120. */
  13121. maxEmitPower: number;
  13122. /**
  13123. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13124. */
  13125. minAngularSpeed: number;
  13126. /**
  13127. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13128. */
  13129. maxAngularSpeed: number;
  13130. /**
  13131. * Gets or sets the minimal initial rotation in radians.
  13132. */
  13133. minInitialRotation: number;
  13134. /**
  13135. * Gets or sets the maximal initial rotation in radians.
  13136. */
  13137. maxInitialRotation: number;
  13138. /**
  13139. * The particle emitter type defines the emitter used by the particle system.
  13140. * It can be for example box, sphere, or cone...
  13141. */
  13142. particleEmitterType: Nullable<IParticleEmitterType>;
  13143. /**
  13144. * Defines the delay in milliseconds before starting the system (0 by default)
  13145. */
  13146. startDelay: number;
  13147. /**
  13148. * 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
  13149. */
  13150. preWarmCycles: number;
  13151. /**
  13152. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13153. */
  13154. preWarmStepOffset: number;
  13155. /**
  13156. * 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)
  13157. */
  13158. spriteCellChangeSpeed: number;
  13159. /**
  13160. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13161. */
  13162. startSpriteCellID: number;
  13163. /**
  13164. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13165. */
  13166. endSpriteCellID: number;
  13167. /**
  13168. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13169. */
  13170. spriteCellWidth: number;
  13171. /**
  13172. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13173. */
  13174. spriteCellHeight: number;
  13175. /**
  13176. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13177. */
  13178. spriteRandomStartCell: boolean;
  13179. /**
  13180. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13181. */
  13182. isAnimationSheetEnabled: boolean;
  13183. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13184. translationPivot: Vector2;
  13185. /**
  13186. * Gets or sets a texture used to add random noise to particle positions
  13187. */
  13188. noiseTexture: Nullable<BaseTexture>;
  13189. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13190. noiseStrength: Vector3;
  13191. /**
  13192. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13193. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13194. */
  13195. billboardMode: number;
  13196. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13197. limitVelocityDamping: number;
  13198. /**
  13199. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13200. */
  13201. beginAnimationOnStart: boolean;
  13202. /**
  13203. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13204. */
  13205. beginAnimationFrom: number;
  13206. /**
  13207. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13208. */
  13209. beginAnimationTo: number;
  13210. /**
  13211. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13212. */
  13213. beginAnimationLoop: boolean;
  13214. /**
  13215. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13216. */
  13217. disposeOnStop: boolean;
  13218. /**
  13219. * Specifies if the particles are updated in emitter local space or world space
  13220. */
  13221. isLocal: boolean;
  13222. /** Snippet ID if the particle system was created from the snippet server */
  13223. snippetId: string;
  13224. /**
  13225. * Gets the maximum number of particles active at the same time.
  13226. * @returns The max number of active particles.
  13227. */
  13228. getCapacity(): number;
  13229. /**
  13230. * Gets the number of particles active at the same time.
  13231. * @returns The number of active particles.
  13232. */
  13233. getActiveCount(): number;
  13234. /**
  13235. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13236. * @returns True if it has been started, otherwise false.
  13237. */
  13238. isStarted(): boolean;
  13239. /**
  13240. * Animates the particle system for this frame.
  13241. */
  13242. animate(): void;
  13243. /**
  13244. * Renders the particle system in its current state.
  13245. * @returns the current number of particles
  13246. */
  13247. render(): number;
  13248. /**
  13249. * Dispose the particle system and frees its associated resources.
  13250. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13251. */
  13252. dispose(disposeTexture?: boolean): void;
  13253. /**
  13254. * Clones the particle system.
  13255. * @param name The name of the cloned object
  13256. * @param newEmitter The new emitter to use
  13257. * @returns the cloned particle system
  13258. */
  13259. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13260. /**
  13261. * Serializes the particle system to a JSON object
  13262. * @param serializeTexture defines if the texture must be serialized as well
  13263. * @returns the JSON object
  13264. */
  13265. serialize(serializeTexture: boolean): any;
  13266. /**
  13267. * Rebuild the particle system
  13268. */
  13269. rebuild(): void;
  13270. /** Force the system to rebuild all gradients that need to be resync */
  13271. forceRefreshGradients(): void;
  13272. /**
  13273. * Starts the particle system and begins to emit
  13274. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13275. */
  13276. start(delay?: number): void;
  13277. /**
  13278. * Stops the particle system.
  13279. */
  13280. stop(): void;
  13281. /**
  13282. * Remove all active particles
  13283. */
  13284. reset(): void;
  13285. /**
  13286. * Gets a boolean indicating that the system is stopping
  13287. * @returns true if the system is currently stopping
  13288. */
  13289. isStopping(): boolean;
  13290. /**
  13291. * Is this system ready to be used/rendered
  13292. * @return true if the system is ready
  13293. */
  13294. isReady(): boolean;
  13295. /**
  13296. * Returns the string "ParticleSystem"
  13297. * @returns a string containing the class name
  13298. */
  13299. getClassName(): string;
  13300. /**
  13301. * Adds a new color gradient
  13302. * @param gradient defines the gradient to use (between 0 and 1)
  13303. * @param color1 defines the color to affect to the specified gradient
  13304. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13305. * @returns the current particle system
  13306. */
  13307. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13308. /**
  13309. * Remove a specific color gradient
  13310. * @param gradient defines the gradient to remove
  13311. * @returns the current particle system
  13312. */
  13313. removeColorGradient(gradient: number): IParticleSystem;
  13314. /**
  13315. * Adds a new size gradient
  13316. * @param gradient defines the gradient to use (between 0 and 1)
  13317. * @param factor defines the size factor to affect to the specified gradient
  13318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13319. * @returns the current particle system
  13320. */
  13321. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13322. /**
  13323. * Remove a specific size gradient
  13324. * @param gradient defines the gradient to remove
  13325. * @returns the current particle system
  13326. */
  13327. removeSizeGradient(gradient: number): IParticleSystem;
  13328. /**
  13329. * Gets the current list of color gradients.
  13330. * You must use addColorGradient and removeColorGradient to udpate this list
  13331. * @returns the list of color gradients
  13332. */
  13333. getColorGradients(): Nullable<Array<ColorGradient>>;
  13334. /**
  13335. * Gets the current list of size gradients.
  13336. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13337. * @returns the list of size gradients
  13338. */
  13339. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13340. /**
  13341. * Gets the current list of angular speed gradients.
  13342. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13343. * @returns the list of angular speed gradients
  13344. */
  13345. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13346. /**
  13347. * Adds a new angular speed gradient
  13348. * @param gradient defines the gradient to use (between 0 and 1)
  13349. * @param factor defines the angular speed to affect to the specified gradient
  13350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13351. * @returns the current particle system
  13352. */
  13353. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13354. /**
  13355. * Remove a specific angular speed gradient
  13356. * @param gradient defines the gradient to remove
  13357. * @returns the current particle system
  13358. */
  13359. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13360. /**
  13361. * Gets the current list of velocity gradients.
  13362. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13363. * @returns the list of velocity gradients
  13364. */
  13365. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13366. /**
  13367. * Adds a new velocity gradient
  13368. * @param gradient defines the gradient to use (between 0 and 1)
  13369. * @param factor defines the velocity to affect to the specified gradient
  13370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13371. * @returns the current particle system
  13372. */
  13373. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13374. /**
  13375. * Remove a specific velocity gradient
  13376. * @param gradient defines the gradient to remove
  13377. * @returns the current particle system
  13378. */
  13379. removeVelocityGradient(gradient: number): IParticleSystem;
  13380. /**
  13381. * Gets the current list of limit velocity gradients.
  13382. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13383. * @returns the list of limit velocity gradients
  13384. */
  13385. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13386. /**
  13387. * Adds a new limit velocity gradient
  13388. * @param gradient defines the gradient to use (between 0 and 1)
  13389. * @param factor defines the limit velocity to affect to the specified gradient
  13390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13391. * @returns the current particle system
  13392. */
  13393. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13394. /**
  13395. * Remove a specific limit velocity gradient
  13396. * @param gradient defines the gradient to remove
  13397. * @returns the current particle system
  13398. */
  13399. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13400. /**
  13401. * Adds a new drag gradient
  13402. * @param gradient defines the gradient to use (between 0 and 1)
  13403. * @param factor defines the drag to affect to the specified gradient
  13404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13405. * @returns the current particle system
  13406. */
  13407. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13408. /**
  13409. * Remove a specific drag gradient
  13410. * @param gradient defines the gradient to remove
  13411. * @returns the current particle system
  13412. */
  13413. removeDragGradient(gradient: number): IParticleSystem;
  13414. /**
  13415. * Gets the current list of drag gradients.
  13416. * You must use addDragGradient and removeDragGradient to udpate this list
  13417. * @returns the list of drag gradients
  13418. */
  13419. getDragGradients(): Nullable<Array<FactorGradient>>;
  13420. /**
  13421. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13422. * @param gradient defines the gradient to use (between 0 and 1)
  13423. * @param factor defines the emit rate to affect to the specified gradient
  13424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13425. * @returns the current particle system
  13426. */
  13427. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13428. /**
  13429. * Remove a specific emit rate gradient
  13430. * @param gradient defines the gradient to remove
  13431. * @returns the current particle system
  13432. */
  13433. removeEmitRateGradient(gradient: number): IParticleSystem;
  13434. /**
  13435. * Gets the current list of emit rate gradients.
  13436. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13437. * @returns the list of emit rate gradients
  13438. */
  13439. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13440. /**
  13441. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13442. * @param gradient defines the gradient to use (between 0 and 1)
  13443. * @param factor defines the start size to affect to the specified gradient
  13444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13445. * @returns the current particle system
  13446. */
  13447. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13448. /**
  13449. * Remove a specific start size gradient
  13450. * @param gradient defines the gradient to remove
  13451. * @returns the current particle system
  13452. */
  13453. removeStartSizeGradient(gradient: number): IParticleSystem;
  13454. /**
  13455. * Gets the current list of start size gradients.
  13456. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13457. * @returns the list of start size gradients
  13458. */
  13459. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13460. /**
  13461. * Adds a new life time gradient
  13462. * @param gradient defines the gradient to use (between 0 and 1)
  13463. * @param factor defines the life time factor to affect to the specified gradient
  13464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13465. * @returns the current particle system
  13466. */
  13467. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13468. /**
  13469. * Remove a specific life time gradient
  13470. * @param gradient defines the gradient to remove
  13471. * @returns the current particle system
  13472. */
  13473. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13474. /**
  13475. * Gets the current list of life time gradients.
  13476. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13477. * @returns the list of life time gradients
  13478. */
  13479. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13480. /**
  13481. * Gets the current list of color gradients.
  13482. * You must use addColorGradient and removeColorGradient to udpate this list
  13483. * @returns the list of color gradients
  13484. */
  13485. getColorGradients(): Nullable<Array<ColorGradient>>;
  13486. /**
  13487. * Adds a new ramp gradient used to remap particle colors
  13488. * @param gradient defines the gradient to use (between 0 and 1)
  13489. * @param color defines the color to affect to the specified gradient
  13490. * @returns the current particle system
  13491. */
  13492. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13493. /**
  13494. * Gets the current list of ramp gradients.
  13495. * You must use addRampGradient and removeRampGradient to udpate this list
  13496. * @returns the list of ramp gradients
  13497. */
  13498. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13499. /** Gets or sets a boolean indicating that ramp gradients must be used
  13500. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13501. */
  13502. useRampGradients: boolean;
  13503. /**
  13504. * Adds a new color remap gradient
  13505. * @param gradient defines the gradient to use (between 0 and 1)
  13506. * @param min defines the color remap minimal range
  13507. * @param max defines the color remap maximal range
  13508. * @returns the current particle system
  13509. */
  13510. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13511. /**
  13512. * Gets the current list of color remap gradients.
  13513. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13514. * @returns the list of color remap gradients
  13515. */
  13516. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13517. /**
  13518. * Adds a new alpha remap gradient
  13519. * @param gradient defines the gradient to use (between 0 and 1)
  13520. * @param min defines the alpha remap minimal range
  13521. * @param max defines the alpha remap maximal range
  13522. * @returns the current particle system
  13523. */
  13524. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13525. /**
  13526. * Gets the current list of alpha remap gradients.
  13527. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13528. * @returns the list of alpha remap gradients
  13529. */
  13530. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13531. /**
  13532. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13535. * @returns the emitter
  13536. */
  13537. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13538. /**
  13539. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13540. * @param radius The radius of the hemisphere to emit from
  13541. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13542. * @returns the emitter
  13543. */
  13544. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13545. /**
  13546. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13547. * @param radius The radius of the sphere to emit from
  13548. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13549. * @returns the emitter
  13550. */
  13551. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13552. /**
  13553. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13554. * @param radius The radius of the sphere to emit from
  13555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13557. * @returns the emitter
  13558. */
  13559. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13560. /**
  13561. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13562. * @param radius The radius of the emission cylinder
  13563. * @param height The height of the emission cylinder
  13564. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13565. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13566. * @returns the emitter
  13567. */
  13568. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13569. /**
  13570. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13571. * @param radius The radius of the cylinder to emit from
  13572. * @param height The height of the emission cylinder
  13573. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13576. * @returns the emitter
  13577. */
  13578. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13579. /**
  13580. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13581. * @param radius The radius of the cone to emit from
  13582. * @param angle The base angle of the cone
  13583. * @returns the emitter
  13584. */
  13585. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13586. /**
  13587. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13590. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13591. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13592. * @returns the emitter
  13593. */
  13594. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13595. /**
  13596. * Get hosting scene
  13597. * @returns the scene
  13598. */
  13599. getScene(): Scene;
  13600. }
  13601. }
  13602. declare module BABYLON {
  13603. /**
  13604. * 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.
  13605. * @see https://doc.babylonjs.com/how_to/transformnode
  13606. */
  13607. export class TransformNode extends Node {
  13608. /**
  13609. * Object will not rotate to face the camera
  13610. */
  13611. static BILLBOARDMODE_NONE: number;
  13612. /**
  13613. * Object will rotate to face the camera but only on the x axis
  13614. */
  13615. static BILLBOARDMODE_X: number;
  13616. /**
  13617. * Object will rotate to face the camera but only on the y axis
  13618. */
  13619. static BILLBOARDMODE_Y: number;
  13620. /**
  13621. * Object will rotate to face the camera but only on the z axis
  13622. */
  13623. static BILLBOARDMODE_Z: number;
  13624. /**
  13625. * Object will rotate to face the camera
  13626. */
  13627. static BILLBOARDMODE_ALL: number;
  13628. /**
  13629. * Object will rotate to face the camera's position instead of orientation
  13630. */
  13631. static BILLBOARDMODE_USE_POSITION: number;
  13632. private _forward;
  13633. private _forwardInverted;
  13634. private _up;
  13635. private _right;
  13636. private _rightInverted;
  13637. private _position;
  13638. private _rotation;
  13639. private _rotationQuaternion;
  13640. protected _scaling: Vector3;
  13641. protected _isDirty: boolean;
  13642. private _transformToBoneReferal;
  13643. private _isAbsoluteSynced;
  13644. private _billboardMode;
  13645. /**
  13646. * Gets or sets the billboard mode. Default is 0.
  13647. *
  13648. * | Value | Type | Description |
  13649. * | --- | --- | --- |
  13650. * | 0 | BILLBOARDMODE_NONE | |
  13651. * | 1 | BILLBOARDMODE_X | |
  13652. * | 2 | BILLBOARDMODE_Y | |
  13653. * | 4 | BILLBOARDMODE_Z | |
  13654. * | 7 | BILLBOARDMODE_ALL | |
  13655. *
  13656. */
  13657. get billboardMode(): number;
  13658. set billboardMode(value: number);
  13659. private _preserveParentRotationForBillboard;
  13660. /**
  13661. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13662. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13663. */
  13664. get preserveParentRotationForBillboard(): boolean;
  13665. set preserveParentRotationForBillboard(value: boolean);
  13666. /**
  13667. * 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
  13668. */
  13669. scalingDeterminant: number;
  13670. private _infiniteDistance;
  13671. /**
  13672. * Gets or sets the distance of the object to max, often used by skybox
  13673. */
  13674. get infiniteDistance(): boolean;
  13675. set infiniteDistance(value: boolean);
  13676. /**
  13677. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13678. * By default the system will update normals to compensate
  13679. */
  13680. ignoreNonUniformScaling: boolean;
  13681. /**
  13682. * 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
  13683. */
  13684. reIntegrateRotationIntoRotationQuaternion: boolean;
  13685. /** @hidden */
  13686. _poseMatrix: Nullable<Matrix>;
  13687. /** @hidden */
  13688. _localMatrix: Matrix;
  13689. private _usePivotMatrix;
  13690. private _absolutePosition;
  13691. private _absoluteScaling;
  13692. private _absoluteRotationQuaternion;
  13693. private _pivotMatrix;
  13694. private _pivotMatrixInverse;
  13695. protected _postMultiplyPivotMatrix: boolean;
  13696. protected _isWorldMatrixFrozen: boolean;
  13697. /** @hidden */
  13698. _indexInSceneTransformNodesArray: number;
  13699. /**
  13700. * An event triggered after the world matrix is updated
  13701. */
  13702. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13703. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13704. /**
  13705. * Gets a string identifying the name of the class
  13706. * @returns "TransformNode" string
  13707. */
  13708. getClassName(): string;
  13709. /**
  13710. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13711. */
  13712. get position(): Vector3;
  13713. set position(newPosition: Vector3);
  13714. /**
  13715. * 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)).
  13716. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13717. */
  13718. get rotation(): Vector3;
  13719. set rotation(newRotation: Vector3);
  13720. /**
  13721. * 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)).
  13722. */
  13723. get scaling(): Vector3;
  13724. set scaling(newScaling: Vector3);
  13725. /**
  13726. * 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).
  13727. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13728. */
  13729. get rotationQuaternion(): Nullable<Quaternion>;
  13730. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13731. /**
  13732. * The forward direction of that transform in world space.
  13733. */
  13734. get forward(): Vector3;
  13735. /**
  13736. * The up direction of that transform in world space.
  13737. */
  13738. get up(): Vector3;
  13739. /**
  13740. * The right direction of that transform in world space.
  13741. */
  13742. get right(): Vector3;
  13743. /**
  13744. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13745. * @param matrix the matrix to copy the pose from
  13746. * @returns this TransformNode.
  13747. */
  13748. updatePoseMatrix(matrix: Matrix): TransformNode;
  13749. /**
  13750. * Returns the mesh Pose matrix.
  13751. * @returns the pose matrix
  13752. */
  13753. getPoseMatrix(): Matrix;
  13754. /** @hidden */
  13755. _isSynchronized(): boolean;
  13756. /** @hidden */
  13757. _initCache(): void;
  13758. /**
  13759. * Flag the transform node as dirty (Forcing it to update everything)
  13760. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13761. * @returns this transform node
  13762. */
  13763. markAsDirty(property: string): TransformNode;
  13764. /**
  13765. * Returns the current mesh absolute position.
  13766. * Returns a Vector3.
  13767. */
  13768. get absolutePosition(): Vector3;
  13769. /**
  13770. * Returns the current mesh absolute scaling.
  13771. * Returns a Vector3.
  13772. */
  13773. get absoluteScaling(): Vector3;
  13774. /**
  13775. * Returns the current mesh absolute rotation.
  13776. * Returns a Quaternion.
  13777. */
  13778. get absoluteRotationQuaternion(): Quaternion;
  13779. /**
  13780. * Sets a new matrix to apply before all other transformation
  13781. * @param matrix defines the transform matrix
  13782. * @returns the current TransformNode
  13783. */
  13784. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13785. /**
  13786. * Sets a new pivot matrix to the current node
  13787. * @param matrix defines the new pivot matrix to use
  13788. * @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
  13789. * @returns the current TransformNode
  13790. */
  13791. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13792. /**
  13793. * Returns the mesh pivot matrix.
  13794. * Default : Identity.
  13795. * @returns the matrix
  13796. */
  13797. getPivotMatrix(): Matrix;
  13798. /**
  13799. * Instantiate (when possible) or clone that node with its hierarchy
  13800. * @param newParent defines the new parent to use for the instance (or clone)
  13801. * @param options defines options to configure how copy is done
  13802. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13803. * @returns an instance (or a clone) of the current node with its hiearchy
  13804. */
  13805. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13806. doNotInstantiate: boolean;
  13807. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13808. /**
  13809. * Prevents the World matrix to be computed any longer
  13810. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13811. * @returns the TransformNode.
  13812. */
  13813. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13814. /**
  13815. * Allows back the World matrix computation.
  13816. * @returns the TransformNode.
  13817. */
  13818. unfreezeWorldMatrix(): this;
  13819. /**
  13820. * True if the World matrix has been frozen.
  13821. */
  13822. get isWorldMatrixFrozen(): boolean;
  13823. /**
  13824. * Retuns the mesh absolute position in the World.
  13825. * @returns a Vector3.
  13826. */
  13827. getAbsolutePosition(): Vector3;
  13828. /**
  13829. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13830. * @param absolutePosition the absolute position to set
  13831. * @returns the TransformNode.
  13832. */
  13833. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13834. /**
  13835. * Sets the mesh position in its local space.
  13836. * @param vector3 the position to set in localspace
  13837. * @returns the TransformNode.
  13838. */
  13839. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13840. /**
  13841. * Returns the mesh position in the local space from the current World matrix values.
  13842. * @returns a new Vector3.
  13843. */
  13844. getPositionExpressedInLocalSpace(): Vector3;
  13845. /**
  13846. * Translates the mesh along the passed Vector3 in its local space.
  13847. * @param vector3 the distance to translate in localspace
  13848. * @returns the TransformNode.
  13849. */
  13850. locallyTranslate(vector3: Vector3): TransformNode;
  13851. private static _lookAtVectorCache;
  13852. /**
  13853. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13854. * @param targetPoint the position (must be in same space as current mesh) to look at
  13855. * @param yawCor optional yaw (y-axis) correction in radians
  13856. * @param pitchCor optional pitch (x-axis) correction in radians
  13857. * @param rollCor optional roll (z-axis) correction in radians
  13858. * @param space the choosen space of the target
  13859. * @returns the TransformNode.
  13860. */
  13861. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13862. /**
  13863. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13864. * This Vector3 is expressed in the World space.
  13865. * @param localAxis axis to rotate
  13866. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13867. */
  13868. getDirection(localAxis: Vector3): Vector3;
  13869. /**
  13870. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13871. * localAxis is expressed in the mesh local space.
  13872. * result is computed in the Wordl space from the mesh World matrix.
  13873. * @param localAxis axis to rotate
  13874. * @param result the resulting transformnode
  13875. * @returns this TransformNode.
  13876. */
  13877. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13878. /**
  13879. * Sets this transform node rotation to the given local axis.
  13880. * @param localAxis the axis in local space
  13881. * @param yawCor optional yaw (y-axis) correction in radians
  13882. * @param pitchCor optional pitch (x-axis) correction in radians
  13883. * @param rollCor optional roll (z-axis) correction in radians
  13884. * @returns this TransformNode
  13885. */
  13886. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13887. /**
  13888. * Sets a new pivot point to the current node
  13889. * @param point defines the new pivot point to use
  13890. * @param space defines if the point is in world or local space (local by default)
  13891. * @returns the current TransformNode
  13892. */
  13893. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13894. /**
  13895. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13896. * @returns the pivot point
  13897. */
  13898. getPivotPoint(): Vector3;
  13899. /**
  13900. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13901. * @param result the vector3 to store the result
  13902. * @returns this TransformNode.
  13903. */
  13904. getPivotPointToRef(result: Vector3): TransformNode;
  13905. /**
  13906. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13907. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13908. */
  13909. getAbsolutePivotPoint(): Vector3;
  13910. /**
  13911. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13912. * @param result vector3 to store the result
  13913. * @returns this TransformNode.
  13914. */
  13915. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13916. /**
  13917. * Defines the passed node as the parent of the current node.
  13918. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13919. * @see https://doc.babylonjs.com/how_to/parenting
  13920. * @param node the node ot set as the parent
  13921. * @returns this TransformNode.
  13922. */
  13923. setParent(node: Nullable<Node>): TransformNode;
  13924. private _nonUniformScaling;
  13925. /**
  13926. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13927. */
  13928. get nonUniformScaling(): boolean;
  13929. /** @hidden */
  13930. _updateNonUniformScalingState(value: boolean): boolean;
  13931. /**
  13932. * Attach the current TransformNode to another TransformNode associated with a bone
  13933. * @param bone Bone affecting the TransformNode
  13934. * @param affectedTransformNode TransformNode associated with the bone
  13935. * @returns this object
  13936. */
  13937. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13938. /**
  13939. * Detach the transform node if its associated with a bone
  13940. * @returns this object
  13941. */
  13942. detachFromBone(): TransformNode;
  13943. private static _rotationAxisCache;
  13944. /**
  13945. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13946. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13947. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13948. * The passed axis is also normalized.
  13949. * @param axis the axis to rotate around
  13950. * @param amount the amount to rotate in radians
  13951. * @param space Space to rotate in (Default: local)
  13952. * @returns the TransformNode.
  13953. */
  13954. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13955. /**
  13956. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13957. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13958. * The passed axis is also normalized. .
  13959. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13960. * @param point the point to rotate around
  13961. * @param axis the axis to rotate around
  13962. * @param amount the amount to rotate in radians
  13963. * @returns the TransformNode
  13964. */
  13965. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13966. /**
  13967. * Translates the mesh along the axis vector for the passed distance in the given space.
  13968. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13969. * @param axis the axis to translate in
  13970. * @param distance the distance to translate
  13971. * @param space Space to rotate in (Default: local)
  13972. * @returns the TransformNode.
  13973. */
  13974. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13975. /**
  13976. * Adds a rotation step to the mesh current rotation.
  13977. * x, y, z are Euler angles expressed in radians.
  13978. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13979. * This means this rotation is made in the mesh local space only.
  13980. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13981. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13982. * ```javascript
  13983. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13984. * ```
  13985. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13986. * 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.
  13987. * @param x Rotation to add
  13988. * @param y Rotation to add
  13989. * @param z Rotation to add
  13990. * @returns the TransformNode.
  13991. */
  13992. addRotation(x: number, y: number, z: number): TransformNode;
  13993. /**
  13994. * @hidden
  13995. */
  13996. protected _getEffectiveParent(): Nullable<Node>;
  13997. /**
  13998. * Computes the world matrix of the node
  13999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14000. * @returns the world matrix
  14001. */
  14002. computeWorldMatrix(force?: boolean): Matrix;
  14003. /**
  14004. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14005. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14006. */
  14007. resetLocalMatrix(independentOfChildren?: boolean): void;
  14008. protected _afterComputeWorldMatrix(): void;
  14009. /**
  14010. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14011. * @param func callback function to add
  14012. *
  14013. * @returns the TransformNode.
  14014. */
  14015. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14016. /**
  14017. * Removes a registered callback function.
  14018. * @param func callback function to remove
  14019. * @returns the TransformNode.
  14020. */
  14021. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14022. /**
  14023. * Gets the position of the current mesh in camera space
  14024. * @param camera defines the camera to use
  14025. * @returns a position
  14026. */
  14027. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14028. /**
  14029. * Returns the distance from the mesh to the active camera
  14030. * @param camera defines the camera to use
  14031. * @returns the distance
  14032. */
  14033. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14034. /**
  14035. * Clone the current transform node
  14036. * @param name Name of the new clone
  14037. * @param newParent New parent for the clone
  14038. * @param doNotCloneChildren Do not clone children hierarchy
  14039. * @returns the new transform node
  14040. */
  14041. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14042. /**
  14043. * Serializes the objects information.
  14044. * @param currentSerializationObject defines the object to serialize in
  14045. * @returns the serialized object
  14046. */
  14047. serialize(currentSerializationObject?: any): any;
  14048. /**
  14049. * Returns a new TransformNode object parsed from the source provided.
  14050. * @param parsedTransformNode is the source.
  14051. * @param scene the scne the object belongs to
  14052. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14053. * @returns a new TransformNode object parsed from the source provided.
  14054. */
  14055. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14056. /**
  14057. * Get all child-transformNodes of this node
  14058. * @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
  14059. * @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
  14060. * @returns an array of TransformNode
  14061. */
  14062. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14063. /**
  14064. * Releases resources associated with this transform node.
  14065. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14066. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14067. */
  14068. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14069. /**
  14070. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14071. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14072. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14073. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14074. * @returns the current mesh
  14075. */
  14076. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14077. private _syncAbsoluteScalingAndRotation;
  14078. }
  14079. }
  14080. declare module BABYLON {
  14081. /**
  14082. * Class used to override all child animations of a given target
  14083. */
  14084. export class AnimationPropertiesOverride {
  14085. /**
  14086. * Gets or sets a value indicating if animation blending must be used
  14087. */
  14088. enableBlending: boolean;
  14089. /**
  14090. * Gets or sets the blending speed to use when enableBlending is true
  14091. */
  14092. blendingSpeed: number;
  14093. /**
  14094. * Gets or sets the default loop mode to use
  14095. */
  14096. loopMode: number;
  14097. }
  14098. }
  14099. declare module BABYLON {
  14100. /**
  14101. * Class used to store bone information
  14102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14103. */
  14104. export class Bone extends Node {
  14105. /**
  14106. * defines the bone name
  14107. */
  14108. name: string;
  14109. private static _tmpVecs;
  14110. private static _tmpQuat;
  14111. private static _tmpMats;
  14112. /**
  14113. * Gets the list of child bones
  14114. */
  14115. children: Bone[];
  14116. /** Gets the animations associated with this bone */
  14117. animations: Animation[];
  14118. /**
  14119. * Gets or sets bone length
  14120. */
  14121. length: number;
  14122. /**
  14123. * @hidden Internal only
  14124. * Set this value to map this bone to a different index in the transform matrices
  14125. * Set this value to -1 to exclude the bone from the transform matrices
  14126. */
  14127. _index: Nullable<number>;
  14128. private _skeleton;
  14129. private _localMatrix;
  14130. private _restPose;
  14131. private _baseMatrix;
  14132. private _absoluteTransform;
  14133. private _invertedAbsoluteTransform;
  14134. private _parent;
  14135. private _scalingDeterminant;
  14136. private _worldTransform;
  14137. private _localScaling;
  14138. private _localRotation;
  14139. private _localPosition;
  14140. private _needToDecompose;
  14141. private _needToCompose;
  14142. /** @hidden */
  14143. _linkedTransformNode: Nullable<TransformNode>;
  14144. /** @hidden */
  14145. _waitingTransformNodeId: Nullable<string>;
  14146. /** @hidden */
  14147. get _matrix(): Matrix;
  14148. /** @hidden */
  14149. set _matrix(value: Matrix);
  14150. /**
  14151. * Create a new bone
  14152. * @param name defines the bone name
  14153. * @param skeleton defines the parent skeleton
  14154. * @param parentBone defines the parent (can be null if the bone is the root)
  14155. * @param localMatrix defines the local matrix
  14156. * @param restPose defines the rest pose matrix
  14157. * @param baseMatrix defines the base matrix
  14158. * @param index defines index of the bone in the hiearchy
  14159. */
  14160. constructor(
  14161. /**
  14162. * defines the bone name
  14163. */
  14164. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14165. /**
  14166. * Gets the current object class name.
  14167. * @return the class name
  14168. */
  14169. getClassName(): string;
  14170. /**
  14171. * Gets the parent skeleton
  14172. * @returns a skeleton
  14173. */
  14174. getSkeleton(): Skeleton;
  14175. /**
  14176. * Gets parent bone
  14177. * @returns a bone or null if the bone is the root of the bone hierarchy
  14178. */
  14179. getParent(): Nullable<Bone>;
  14180. /**
  14181. * Returns an array containing the root bones
  14182. * @returns an array containing the root bones
  14183. */
  14184. getChildren(): Array<Bone>;
  14185. /**
  14186. * Gets the node index in matrix array generated for rendering
  14187. * @returns the node index
  14188. */
  14189. getIndex(): number;
  14190. /**
  14191. * Sets the parent bone
  14192. * @param parent defines the parent (can be null if the bone is the root)
  14193. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14194. */
  14195. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14196. /**
  14197. * Gets the local matrix
  14198. * @returns a matrix
  14199. */
  14200. getLocalMatrix(): Matrix;
  14201. /**
  14202. * Gets the base matrix (initial matrix which remains unchanged)
  14203. * @returns a matrix
  14204. */
  14205. getBaseMatrix(): Matrix;
  14206. /**
  14207. * Gets the rest pose matrix
  14208. * @returns a matrix
  14209. */
  14210. getRestPose(): Matrix;
  14211. /**
  14212. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14213. */
  14214. getWorldMatrix(): Matrix;
  14215. /**
  14216. * Sets the local matrix to rest pose matrix
  14217. */
  14218. returnToRest(): void;
  14219. /**
  14220. * Gets the inverse of the absolute transform matrix.
  14221. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14222. * @returns a matrix
  14223. */
  14224. getInvertedAbsoluteTransform(): Matrix;
  14225. /**
  14226. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14227. * @returns a matrix
  14228. */
  14229. getAbsoluteTransform(): Matrix;
  14230. /**
  14231. * Links with the given transform node.
  14232. * The local matrix of this bone is copied from the transform node every frame.
  14233. * @param transformNode defines the transform node to link to
  14234. */
  14235. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14236. /**
  14237. * Gets the node used to drive the bone's transformation
  14238. * @returns a transform node or null
  14239. */
  14240. getTransformNode(): Nullable<TransformNode>;
  14241. /** Gets or sets current position (in local space) */
  14242. get position(): Vector3;
  14243. set position(newPosition: Vector3);
  14244. /** Gets or sets current rotation (in local space) */
  14245. get rotation(): Vector3;
  14246. set rotation(newRotation: Vector3);
  14247. /** Gets or sets current rotation quaternion (in local space) */
  14248. get rotationQuaternion(): Quaternion;
  14249. set rotationQuaternion(newRotation: Quaternion);
  14250. /** Gets or sets current scaling (in local space) */
  14251. get scaling(): Vector3;
  14252. set scaling(newScaling: Vector3);
  14253. /**
  14254. * Gets the animation properties override
  14255. */
  14256. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14257. private _decompose;
  14258. private _compose;
  14259. /**
  14260. * Update the base and local matrices
  14261. * @param matrix defines the new base or local matrix
  14262. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14263. * @param updateLocalMatrix defines if the local matrix should be updated
  14264. */
  14265. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14266. /** @hidden */
  14267. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14268. /**
  14269. * Flag the bone as dirty (Forcing it to update everything)
  14270. */
  14271. markAsDirty(): void;
  14272. /** @hidden */
  14273. _markAsDirtyAndCompose(): void;
  14274. private _markAsDirtyAndDecompose;
  14275. /**
  14276. * Translate the bone in local or world space
  14277. * @param vec The amount to translate the bone
  14278. * @param space The space that the translation is in
  14279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14280. */
  14281. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14282. /**
  14283. * Set the postion of the bone in local or world space
  14284. * @param position The position to set the bone
  14285. * @param space The space that the position is in
  14286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14287. */
  14288. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14289. /**
  14290. * Set the absolute position of the bone (world space)
  14291. * @param position The position to set the bone
  14292. * @param mesh The mesh that this bone is attached to
  14293. */
  14294. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14295. /**
  14296. * Scale the bone on the x, y and z axes (in local space)
  14297. * @param x The amount to scale the bone on the x axis
  14298. * @param y The amount to scale the bone on the y axis
  14299. * @param z The amount to scale the bone on the z axis
  14300. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14301. */
  14302. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14303. /**
  14304. * Set the bone scaling in local space
  14305. * @param scale defines the scaling vector
  14306. */
  14307. setScale(scale: Vector3): void;
  14308. /**
  14309. * Gets the current scaling in local space
  14310. * @returns the current scaling vector
  14311. */
  14312. getScale(): Vector3;
  14313. /**
  14314. * Gets the current scaling in local space and stores it in a target vector
  14315. * @param result defines the target vector
  14316. */
  14317. getScaleToRef(result: Vector3): void;
  14318. /**
  14319. * Set the yaw, pitch, and roll of the bone in local or world space
  14320. * @param yaw The rotation of the bone on the y axis
  14321. * @param pitch The rotation of the bone on the x axis
  14322. * @param roll The rotation of the bone on the z axis
  14323. * @param space The space that the axes of rotation are in
  14324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14325. */
  14326. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14327. /**
  14328. * Add a rotation to the bone on an axis in local or world space
  14329. * @param axis The axis to rotate the bone on
  14330. * @param amount The amount to rotate the bone
  14331. * @param space The space that the axis is in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. */
  14334. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14335. /**
  14336. * Set the rotation of the bone to a particular axis angle in local or world space
  14337. * @param axis The axis to rotate the bone on
  14338. * @param angle The angle that the bone should be rotated to
  14339. * @param space The space that the axis is in
  14340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14341. */
  14342. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14343. /**
  14344. * Set the euler rotation of the bone in local of world space
  14345. * @param rotation The euler 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. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14350. /**
  14351. * Set the quaternion rotation of the bone in local of world space
  14352. * @param quat The quaternion rotation 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. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14357. /**
  14358. * Set the rotation matrix of the bone in local of world space
  14359. * @param rotMat The rotation matrix that the bone should be set to
  14360. * @param space The space that the rotation is in
  14361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14362. */
  14363. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14364. private _rotateWithMatrix;
  14365. private _getNegativeRotationToRef;
  14366. /**
  14367. * Get the position of the bone 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. * @returns The position of the bone
  14371. */
  14372. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14373. /**
  14374. * Copy the position of the bone to a vector3 in local or world space
  14375. * @param space The space that the returned position is in
  14376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14377. * @param result The vector3 to copy the position to
  14378. */
  14379. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14380. /**
  14381. * Get the absolute position of the bone (world space)
  14382. * @param mesh The mesh that this bone is attached to
  14383. * @returns The absolute position of the bone
  14384. */
  14385. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14386. /**
  14387. * Copy the absolute position of the bone (world space) to the result param
  14388. * @param mesh The mesh that this bone is attached to
  14389. * @param result The vector3 to copy the absolute position to
  14390. */
  14391. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14392. /**
  14393. * Compute the absolute transforms of this bone and its children
  14394. */
  14395. computeAbsoluteTransforms(): void;
  14396. /**
  14397. * Get the world direction 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. * @returns The world direction
  14401. */
  14402. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14403. /**
  14404. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14405. * @param localAxis The local direction that is used to compute the world direction
  14406. * @param mesh The mesh that this bone is attached to
  14407. * @param result The vector3 that the world direction will be copied to
  14408. */
  14409. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14410. /**
  14411. * Get the euler rotation of the bone in 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. * @returns The euler rotation
  14415. */
  14416. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14417. /**
  14418. * Copy the euler rotation of the bone to a vector3. The rotation can be 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. * @param result The vector3 that the rotation should be copied to
  14422. */
  14423. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14424. /**
  14425. * Get the quaternion rotation of the bone 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. * @returns The quaternion rotation
  14429. */
  14430. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14431. /**
  14432. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either 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. * @param result The quaternion that the rotation should be copied to
  14436. */
  14437. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14438. /**
  14439. * Get the rotation matrix of the bone in 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. * @returns The rotation matrix
  14443. */
  14444. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14445. /**
  14446. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14447. * @param space The space that the rotation should be in
  14448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14449. * @param result The quaternion that the rotation should be copied to
  14450. */
  14451. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14452. /**
  14453. * Get the world position of a point that is in the local space of the bone
  14454. * @param position The local position
  14455. * @param mesh The mesh that this bone is attached to
  14456. * @returns The world position
  14457. */
  14458. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14459. /**
  14460. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14461. * @param position The local position
  14462. * @param mesh The mesh that this bone is attached to
  14463. * @param result The vector3 that the world position should be copied to
  14464. */
  14465. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14466. /**
  14467. * Get the local position of a point that is in world space
  14468. * @param position The world position
  14469. * @param mesh The mesh that this bone is attached to
  14470. * @returns The local position
  14471. */
  14472. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14473. /**
  14474. * Get the local position of a point that is in world space and copy it to the result param
  14475. * @param position The world position
  14476. * @param mesh The mesh that this bone is attached to
  14477. * @param result The vector3 that the local position should be copied to
  14478. */
  14479. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14480. }
  14481. }
  14482. declare module BABYLON {
  14483. /**
  14484. * Defines a runtime animation
  14485. */
  14486. export class RuntimeAnimation {
  14487. private _events;
  14488. /**
  14489. * The current frame of the runtime animation
  14490. */
  14491. private _currentFrame;
  14492. /**
  14493. * The animation used by the runtime animation
  14494. */
  14495. private _animation;
  14496. /**
  14497. * The target of the runtime animation
  14498. */
  14499. private _target;
  14500. /**
  14501. * The initiating animatable
  14502. */
  14503. private _host;
  14504. /**
  14505. * The original value of the runtime animation
  14506. */
  14507. private _originalValue;
  14508. /**
  14509. * The original blend value of the runtime animation
  14510. */
  14511. private _originalBlendValue;
  14512. /**
  14513. * The offsets cache of the runtime animation
  14514. */
  14515. private _offsetsCache;
  14516. /**
  14517. * The high limits cache of the runtime animation
  14518. */
  14519. private _highLimitsCache;
  14520. /**
  14521. * Specifies if the runtime animation has been stopped
  14522. */
  14523. private _stopped;
  14524. /**
  14525. * The blending factor of the runtime animation
  14526. */
  14527. private _blendingFactor;
  14528. /**
  14529. * The BabylonJS scene
  14530. */
  14531. private _scene;
  14532. /**
  14533. * The current value of the runtime animation
  14534. */
  14535. private _currentValue;
  14536. /** @hidden */
  14537. _animationState: _IAnimationState;
  14538. /**
  14539. * The active target of the runtime animation
  14540. */
  14541. private _activeTargets;
  14542. private _currentActiveTarget;
  14543. private _directTarget;
  14544. /**
  14545. * The target path of the runtime animation
  14546. */
  14547. private _targetPath;
  14548. /**
  14549. * The weight of the runtime animation
  14550. */
  14551. private _weight;
  14552. /**
  14553. * The ratio offset of the runtime animation
  14554. */
  14555. private _ratioOffset;
  14556. /**
  14557. * The previous delay of the runtime animation
  14558. */
  14559. private _previousDelay;
  14560. /**
  14561. * The previous ratio of the runtime animation
  14562. */
  14563. private _previousRatio;
  14564. private _enableBlending;
  14565. private _keys;
  14566. private _minFrame;
  14567. private _maxFrame;
  14568. private _minValue;
  14569. private _maxValue;
  14570. private _targetIsArray;
  14571. /**
  14572. * Gets the current frame of the runtime animation
  14573. */
  14574. get currentFrame(): number;
  14575. /**
  14576. * Gets the weight of the runtime animation
  14577. */
  14578. get weight(): number;
  14579. /**
  14580. * Gets the current value of the runtime animation
  14581. */
  14582. get currentValue(): any;
  14583. /**
  14584. * Gets the target path of the runtime animation
  14585. */
  14586. get targetPath(): string;
  14587. /**
  14588. * Gets the actual target of the runtime animation
  14589. */
  14590. get target(): any;
  14591. /**
  14592. * Gets the additive state of the runtime animation
  14593. */
  14594. get isAdditive(): boolean;
  14595. /** @hidden */
  14596. _onLoop: () => void;
  14597. /**
  14598. * Create a new RuntimeAnimation object
  14599. * @param target defines the target of the animation
  14600. * @param animation defines the source animation object
  14601. * @param scene defines the hosting scene
  14602. * @param host defines the initiating Animatable
  14603. */
  14604. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14605. private _preparePath;
  14606. /**
  14607. * Gets the animation from the runtime animation
  14608. */
  14609. get animation(): Animation;
  14610. /**
  14611. * Resets the runtime animation to the beginning
  14612. * @param restoreOriginal defines whether to restore the target property to the original value
  14613. */
  14614. reset(restoreOriginal?: boolean): void;
  14615. /**
  14616. * Specifies if the runtime animation is stopped
  14617. * @returns Boolean specifying if the runtime animation is stopped
  14618. */
  14619. isStopped(): boolean;
  14620. /**
  14621. * Disposes of the runtime animation
  14622. */
  14623. dispose(): void;
  14624. /**
  14625. * Apply the interpolated value to the target
  14626. * @param currentValue defines the value computed by the animation
  14627. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14628. */
  14629. setValue(currentValue: any, weight: number): void;
  14630. private _getOriginalValues;
  14631. private _setValue;
  14632. /**
  14633. * Gets the loop pmode of the runtime animation
  14634. * @returns Loop Mode
  14635. */
  14636. private _getCorrectLoopMode;
  14637. /**
  14638. * Move the current animation to a given frame
  14639. * @param frame defines the frame to move to
  14640. */
  14641. goToFrame(frame: number): void;
  14642. /**
  14643. * @hidden Internal use only
  14644. */
  14645. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14646. /**
  14647. * Execute the current animation
  14648. * @param delay defines the delay to add to the current frame
  14649. * @param from defines the lower bound of the animation range
  14650. * @param to defines the upper bound of the animation range
  14651. * @param loop defines if the current animation must loop
  14652. * @param speedRatio defines the current speed ratio
  14653. * @param weight defines the weight of the animation (default is -1 so no weight)
  14654. * @param onLoop optional callback called when animation loops
  14655. * @returns a boolean indicating if the animation is running
  14656. */
  14657. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14658. }
  14659. }
  14660. declare module BABYLON {
  14661. /**
  14662. * Class used to store an actual running animation
  14663. */
  14664. export class Animatable {
  14665. /** defines the target object */
  14666. target: any;
  14667. /** defines the starting frame number (default is 0) */
  14668. fromFrame: number;
  14669. /** defines the ending frame number (default is 100) */
  14670. toFrame: number;
  14671. /** defines if the animation must loop (default is false) */
  14672. loopAnimation: boolean;
  14673. /** defines a callback to call when animation ends if it is not looping */
  14674. onAnimationEnd?: (() => void) | null | undefined;
  14675. /** defines a callback to call when animation loops */
  14676. onAnimationLoop?: (() => void) | null | undefined;
  14677. /** defines whether the animation should be evaluated additively */
  14678. isAdditive: boolean;
  14679. private _localDelayOffset;
  14680. private _pausedDelay;
  14681. private _runtimeAnimations;
  14682. private _paused;
  14683. private _scene;
  14684. private _speedRatio;
  14685. private _weight;
  14686. private _syncRoot;
  14687. /**
  14688. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14689. * This will only apply for non looping animation (default is true)
  14690. */
  14691. disposeOnEnd: boolean;
  14692. /**
  14693. * Gets a boolean indicating if the animation has started
  14694. */
  14695. animationStarted: boolean;
  14696. /**
  14697. * Observer raised when the animation ends
  14698. */
  14699. onAnimationEndObservable: Observable<Animatable>;
  14700. /**
  14701. * Observer raised when the animation loops
  14702. */
  14703. onAnimationLoopObservable: Observable<Animatable>;
  14704. /**
  14705. * Gets the root Animatable used to synchronize and normalize animations
  14706. */
  14707. get syncRoot(): Nullable<Animatable>;
  14708. /**
  14709. * Gets the current frame of the first RuntimeAnimation
  14710. * Used to synchronize Animatables
  14711. */
  14712. get masterFrame(): number;
  14713. /**
  14714. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14715. */
  14716. get weight(): number;
  14717. set weight(value: number);
  14718. /**
  14719. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14720. */
  14721. get speedRatio(): number;
  14722. set speedRatio(value: number);
  14723. /**
  14724. * Creates a new Animatable
  14725. * @param scene defines the hosting scene
  14726. * @param target defines the target object
  14727. * @param fromFrame defines the starting frame number (default is 0)
  14728. * @param toFrame defines the ending frame number (default is 100)
  14729. * @param loopAnimation defines if the animation must loop (default is false)
  14730. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14731. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14732. * @param animations defines a group of animation to add to the new Animatable
  14733. * @param onAnimationLoop defines a callback to call when animation loops
  14734. * @param isAdditive defines whether the animation should be evaluated additively
  14735. */
  14736. constructor(scene: Scene,
  14737. /** defines the target object */
  14738. target: any,
  14739. /** defines the starting frame number (default is 0) */
  14740. fromFrame?: number,
  14741. /** defines the ending frame number (default is 100) */
  14742. toFrame?: number,
  14743. /** defines if the animation must loop (default is false) */
  14744. loopAnimation?: boolean, speedRatio?: number,
  14745. /** defines a callback to call when animation ends if it is not looping */
  14746. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14747. /** defines a callback to call when animation loops */
  14748. onAnimationLoop?: (() => void) | null | undefined,
  14749. /** defines whether the animation should be evaluated additively */
  14750. isAdditive?: boolean);
  14751. /**
  14752. * Synchronize and normalize current Animatable with a source Animatable
  14753. * This is useful when using animation weights and when animations are not of the same length
  14754. * @param root defines the root Animatable to synchronize with
  14755. * @returns the current Animatable
  14756. */
  14757. syncWith(root: Animatable): Animatable;
  14758. /**
  14759. * Gets the list of runtime animations
  14760. * @returns an array of RuntimeAnimation
  14761. */
  14762. getAnimations(): RuntimeAnimation[];
  14763. /**
  14764. * Adds more animations to the current animatable
  14765. * @param target defines the target of the animations
  14766. * @param animations defines the new animations to add
  14767. */
  14768. appendAnimations(target: any, animations: Animation[]): void;
  14769. /**
  14770. * Gets the source animation for a specific property
  14771. * @param property defines the propertyu to look for
  14772. * @returns null or the source animation for the given property
  14773. */
  14774. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14775. /**
  14776. * Gets the runtime animation for a specific property
  14777. * @param property defines the propertyu to look for
  14778. * @returns null or the runtime animation for the given property
  14779. */
  14780. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14781. /**
  14782. * Resets the animatable to its original state
  14783. */
  14784. reset(): void;
  14785. /**
  14786. * Allows the animatable to blend with current running animations
  14787. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14788. * @param blendingSpeed defines the blending speed to use
  14789. */
  14790. enableBlending(blendingSpeed: number): void;
  14791. /**
  14792. * Disable animation blending
  14793. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14794. */
  14795. disableBlending(): void;
  14796. /**
  14797. * Jump directly to a given frame
  14798. * @param frame defines the frame to jump to
  14799. */
  14800. goToFrame(frame: number): void;
  14801. /**
  14802. * Pause the animation
  14803. */
  14804. pause(): void;
  14805. /**
  14806. * Restart the animation
  14807. */
  14808. restart(): void;
  14809. private _raiseOnAnimationEnd;
  14810. /**
  14811. * Stop and delete the current animation
  14812. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14813. * @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)
  14814. */
  14815. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14816. /**
  14817. * Wait asynchronously for the animation to end
  14818. * @returns a promise which will be fullfilled when the animation ends
  14819. */
  14820. waitAsync(): Promise<Animatable>;
  14821. /** @hidden */
  14822. _animate(delay: number): boolean;
  14823. }
  14824. interface Scene {
  14825. /** @hidden */
  14826. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14827. /** @hidden */
  14828. _processLateAnimationBindingsForMatrices(holder: {
  14829. totalWeight: number;
  14830. totalAdditiveWeight: number;
  14831. animations: RuntimeAnimation[];
  14832. additiveAnimations: RuntimeAnimation[];
  14833. originalValue: Matrix;
  14834. }): any;
  14835. /** @hidden */
  14836. _processLateAnimationBindingsForQuaternions(holder: {
  14837. totalWeight: number;
  14838. totalAdditiveWeight: number;
  14839. animations: RuntimeAnimation[];
  14840. additiveAnimations: RuntimeAnimation[];
  14841. originalValue: Quaternion;
  14842. }, refQuaternion: Quaternion): Quaternion;
  14843. /** @hidden */
  14844. _processLateAnimationBindings(): void;
  14845. /**
  14846. * Will start the animation sequence of a given target
  14847. * @param target defines the target
  14848. * @param from defines from which frame should animation start
  14849. * @param to defines until which frame should animation run.
  14850. * @param weight defines the weight to apply to the animation (1.0 by default)
  14851. * @param loop defines if the animation loops
  14852. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14853. * @param onAnimationEnd defines the function to be executed when the animation ends
  14854. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14855. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14856. * @param onAnimationLoop defines the callback to call when an animation loops
  14857. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14858. * @returns the animatable object created for this animation
  14859. */
  14860. 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;
  14861. /**
  14862. * Will start the animation sequence of a given target
  14863. * @param target defines the target
  14864. * @param from defines from which frame should animation start
  14865. * @param to defines until which frame should animation run.
  14866. * @param loop defines if the animation loops
  14867. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14868. * @param onAnimationEnd defines the function to be executed when the animation ends
  14869. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14870. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14871. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14872. * @param onAnimationLoop defines the callback to call when an animation loops
  14873. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14874. * @returns the animatable object created for this animation
  14875. */
  14876. 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;
  14877. /**
  14878. * Will start the animation sequence of a given target and its hierarchy
  14879. * @param target defines the target
  14880. * @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.
  14881. * @param from defines from which frame should animation start
  14882. * @param to defines until which frame should animation run.
  14883. * @param loop defines if the animation loops
  14884. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14885. * @param onAnimationEnd defines the function to be executed when the animation ends
  14886. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14887. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14888. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14889. * @param onAnimationLoop defines the callback to call when an animation loops
  14890. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14891. * @returns the list of created animatables
  14892. */
  14893. 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[];
  14894. /**
  14895. * Begin a new animation on a given node
  14896. * @param target defines the target where the animation will take place
  14897. * @param animations defines the list of animations to start
  14898. * @param from defines the initial value
  14899. * @param to defines the final value
  14900. * @param loop defines if you want animation to loop (off by default)
  14901. * @param speedRatio defines the speed ratio to apply to all animations
  14902. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14903. * @param onAnimationLoop defines the callback to call when an animation loops
  14904. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14905. * @returns the list of created animatables
  14906. */
  14907. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14908. /**
  14909. * Begin a new animation on a given node and its hierarchy
  14910. * @param target defines the root node where the animation will take place
  14911. * @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.
  14912. * @param animations defines the list of animations to start
  14913. * @param from defines the initial value
  14914. * @param to defines the final value
  14915. * @param loop defines if you want animation to loop (off by default)
  14916. * @param speedRatio defines the speed ratio to apply to all animations
  14917. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14918. * @param onAnimationLoop defines the callback to call when an animation loops
  14919. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14920. * @returns the list of animatables created for all nodes
  14921. */
  14922. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14923. /**
  14924. * Gets the animatable associated with a specific target
  14925. * @param target defines the target of the animatable
  14926. * @returns the required animatable if found
  14927. */
  14928. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14929. /**
  14930. * Gets all animatables associated with a given target
  14931. * @param target defines the target to look animatables for
  14932. * @returns an array of Animatables
  14933. */
  14934. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14935. /**
  14936. * Stops and removes all animations that have been applied to the scene
  14937. */
  14938. stopAllAnimations(): void;
  14939. /**
  14940. * Gets the current delta time used by animation engine
  14941. */
  14942. deltaTime: number;
  14943. }
  14944. interface Bone {
  14945. /**
  14946. * Copy an animation range from another bone
  14947. * @param source defines the source bone
  14948. * @param rangeName defines the range name to copy
  14949. * @param frameOffset defines the frame offset
  14950. * @param rescaleAsRequired defines if rescaling must be applied if required
  14951. * @param skelDimensionsRatio defines the scaling ratio
  14952. * @returns true if operation was successful
  14953. */
  14954. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14955. }
  14956. }
  14957. declare module BABYLON {
  14958. /**
  14959. * Class used to handle skinning animations
  14960. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14961. */
  14962. export class Skeleton implements IAnimatable {
  14963. /** defines the skeleton name */
  14964. name: string;
  14965. /** defines the skeleton Id */
  14966. id: string;
  14967. /**
  14968. * Defines the list of child bones
  14969. */
  14970. bones: Bone[];
  14971. /**
  14972. * Defines an estimate of the dimension of the skeleton at rest
  14973. */
  14974. dimensionsAtRest: Vector3;
  14975. /**
  14976. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14977. */
  14978. needInitialSkinMatrix: boolean;
  14979. /**
  14980. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14981. */
  14982. overrideMesh: Nullable<AbstractMesh>;
  14983. /**
  14984. * Gets the list of animations attached to this skeleton
  14985. */
  14986. animations: Array<Animation>;
  14987. private _scene;
  14988. private _isDirty;
  14989. private _transformMatrices;
  14990. private _transformMatrixTexture;
  14991. private _meshesWithPoseMatrix;
  14992. private _animatables;
  14993. private _identity;
  14994. private _synchronizedWithMesh;
  14995. private _ranges;
  14996. private _lastAbsoluteTransformsUpdateId;
  14997. private _canUseTextureForBones;
  14998. private _uniqueId;
  14999. /** @hidden */
  15000. _numBonesWithLinkedTransformNode: number;
  15001. /** @hidden */
  15002. _hasWaitingData: Nullable<boolean>;
  15003. /**
  15004. * Specifies if the skeleton should be serialized
  15005. */
  15006. doNotSerialize: boolean;
  15007. private _useTextureToStoreBoneMatrices;
  15008. /**
  15009. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15010. * Please note that this option is not available if the hardware does not support it
  15011. */
  15012. get useTextureToStoreBoneMatrices(): boolean;
  15013. set useTextureToStoreBoneMatrices(value: boolean);
  15014. private _animationPropertiesOverride;
  15015. /**
  15016. * Gets or sets the animation properties override
  15017. */
  15018. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15019. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15020. /**
  15021. * List of inspectable custom properties (used by the Inspector)
  15022. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15023. */
  15024. inspectableCustomProperties: IInspectable[];
  15025. /**
  15026. * An observable triggered before computing the skeleton's matrices
  15027. */
  15028. onBeforeComputeObservable: Observable<Skeleton>;
  15029. /**
  15030. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15031. */
  15032. get isUsingTextureForMatrices(): boolean;
  15033. /**
  15034. * Gets the unique ID of this skeleton
  15035. */
  15036. get uniqueId(): number;
  15037. /**
  15038. * Creates a new skeleton
  15039. * @param name defines the skeleton name
  15040. * @param id defines the skeleton Id
  15041. * @param scene defines the hosting scene
  15042. */
  15043. constructor(
  15044. /** defines the skeleton name */
  15045. name: string,
  15046. /** defines the skeleton Id */
  15047. id: string, scene: Scene);
  15048. /**
  15049. * Gets the current object class name.
  15050. * @return the class name
  15051. */
  15052. getClassName(): string;
  15053. /**
  15054. * Returns an array containing the root bones
  15055. * @returns an array containing the root bones
  15056. */
  15057. getChildren(): Array<Bone>;
  15058. /**
  15059. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15060. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15061. * @returns a Float32Array containing matrices data
  15062. */
  15063. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15064. /**
  15065. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15066. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15067. * @returns a raw texture containing the data
  15068. */
  15069. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15070. /**
  15071. * Gets the current hosting scene
  15072. * @returns a scene object
  15073. */
  15074. getScene(): Scene;
  15075. /**
  15076. * Gets a string representing the current skeleton data
  15077. * @param fullDetails defines a boolean indicating if we want a verbose version
  15078. * @returns a string representing the current skeleton data
  15079. */
  15080. toString(fullDetails?: boolean): string;
  15081. /**
  15082. * Get bone's index searching by name
  15083. * @param name defines bone's name to search for
  15084. * @return the indice of the bone. Returns -1 if not found
  15085. */
  15086. getBoneIndexByName(name: string): number;
  15087. /**
  15088. * Creater a new animation range
  15089. * @param name defines the name of the range
  15090. * @param from defines the start key
  15091. * @param to defines the end key
  15092. */
  15093. createAnimationRange(name: string, from: number, to: number): void;
  15094. /**
  15095. * Delete a specific animation range
  15096. * @param name defines the name of the range
  15097. * @param deleteFrames defines if frames must be removed as well
  15098. */
  15099. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15100. /**
  15101. * Gets a specific animation range
  15102. * @param name defines the name of the range to look for
  15103. * @returns the requested animation range or null if not found
  15104. */
  15105. getAnimationRange(name: string): Nullable<AnimationRange>;
  15106. /**
  15107. * Gets the list of all animation ranges defined on this skeleton
  15108. * @returns an array
  15109. */
  15110. getAnimationRanges(): Nullable<AnimationRange>[];
  15111. /**
  15112. * Copy animation range from a source skeleton.
  15113. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15114. * @param source defines the source skeleton
  15115. * @param name defines the name of the range to copy
  15116. * @param rescaleAsRequired defines if rescaling must be applied if required
  15117. * @returns true if operation was successful
  15118. */
  15119. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15120. /**
  15121. * Forces the skeleton to go to rest pose
  15122. */
  15123. returnToRest(): void;
  15124. private _getHighestAnimationFrame;
  15125. /**
  15126. * Begin a specific animation range
  15127. * @param name defines the name of the range to start
  15128. * @param loop defines if looping must be turned on (false by default)
  15129. * @param speedRatio defines the speed ratio to apply (1 by default)
  15130. * @param onAnimationEnd defines a callback which will be called when animation will end
  15131. * @returns a new animatable
  15132. */
  15133. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15134. /**
  15135. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15136. * @param skeleton defines the Skeleton containing the animation range to convert
  15137. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15138. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15139. * @returns the original skeleton
  15140. */
  15141. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15142. /** @hidden */
  15143. _markAsDirty(): void;
  15144. /** @hidden */
  15145. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15146. /** @hidden */
  15147. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15148. private _computeTransformMatrices;
  15149. /**
  15150. * Build all resources required to render a skeleton
  15151. */
  15152. prepare(): void;
  15153. /**
  15154. * Gets the list of animatables currently running for this skeleton
  15155. * @returns an array of animatables
  15156. */
  15157. getAnimatables(): IAnimatable[];
  15158. /**
  15159. * Clone the current skeleton
  15160. * @param name defines the name of the new skeleton
  15161. * @param id defines the id of the new skeleton
  15162. * @returns the new skeleton
  15163. */
  15164. clone(name: string, id?: string): Skeleton;
  15165. /**
  15166. * Enable animation blending for this skeleton
  15167. * @param blendingSpeed defines the blending speed to apply
  15168. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15169. */
  15170. enableBlending(blendingSpeed?: number): void;
  15171. /**
  15172. * Releases all resources associated with the current skeleton
  15173. */
  15174. dispose(): void;
  15175. /**
  15176. * Serialize the skeleton in a JSON object
  15177. * @returns a JSON object
  15178. */
  15179. serialize(): any;
  15180. /**
  15181. * Creates a new skeleton from serialized data
  15182. * @param parsedSkeleton defines the serialized data
  15183. * @param scene defines the hosting scene
  15184. * @returns a new skeleton
  15185. */
  15186. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15187. /**
  15188. * Compute all node absolute transforms
  15189. * @param forceUpdate defines if computation must be done even if cache is up to date
  15190. */
  15191. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15192. /**
  15193. * Gets the root pose matrix
  15194. * @returns a matrix
  15195. */
  15196. getPoseMatrix(): Nullable<Matrix>;
  15197. /**
  15198. * Sorts bones per internal index
  15199. */
  15200. sortBones(): void;
  15201. private _sortBones;
  15202. }
  15203. }
  15204. declare module BABYLON {
  15205. /**
  15206. * Creates an instance based on a source mesh.
  15207. */
  15208. export class InstancedMesh extends AbstractMesh {
  15209. private _sourceMesh;
  15210. private _currentLOD;
  15211. /** @hidden */
  15212. _indexInSourceMeshInstanceArray: number;
  15213. constructor(name: string, source: Mesh);
  15214. /**
  15215. * Returns the string "InstancedMesh".
  15216. */
  15217. getClassName(): string;
  15218. /** Gets the list of lights affecting that mesh */
  15219. get lightSources(): Light[];
  15220. _resyncLightSources(): void;
  15221. _resyncLightSource(light: Light): void;
  15222. _removeLightSource(light: Light, dispose: boolean): void;
  15223. /**
  15224. * If the source mesh receives shadows
  15225. */
  15226. get receiveShadows(): boolean;
  15227. /**
  15228. * The material of the source mesh
  15229. */
  15230. get material(): Nullable<Material>;
  15231. /**
  15232. * Visibility of the source mesh
  15233. */
  15234. get visibility(): number;
  15235. /**
  15236. * Skeleton of the source mesh
  15237. */
  15238. get skeleton(): Nullable<Skeleton>;
  15239. /**
  15240. * Rendering ground id of the source mesh
  15241. */
  15242. get renderingGroupId(): number;
  15243. set renderingGroupId(value: number);
  15244. /**
  15245. * Returns the total number of vertices (integer).
  15246. */
  15247. getTotalVertices(): number;
  15248. /**
  15249. * Returns a positive integer : the total number of indices in this mesh geometry.
  15250. * @returns the numner of indices or zero if the mesh has no geometry.
  15251. */
  15252. getTotalIndices(): number;
  15253. /**
  15254. * The source mesh of the instance
  15255. */
  15256. get sourceMesh(): Mesh;
  15257. /**
  15258. * Is this node ready to be used/rendered
  15259. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15260. * @return {boolean} is it ready
  15261. */
  15262. isReady(completeCheck?: boolean): boolean;
  15263. /**
  15264. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15265. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15266. * @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.
  15267. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15268. */
  15269. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15270. /**
  15271. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15272. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15273. * The `data` are either a numeric array either a Float32Array.
  15274. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15275. * 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).
  15276. * Note that a new underlying VertexBuffer object is created each call.
  15277. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15278. *
  15279. * Possible `kind` values :
  15280. * - VertexBuffer.PositionKind
  15281. * - VertexBuffer.UVKind
  15282. * - VertexBuffer.UV2Kind
  15283. * - VertexBuffer.UV3Kind
  15284. * - VertexBuffer.UV4Kind
  15285. * - VertexBuffer.UV5Kind
  15286. * - VertexBuffer.UV6Kind
  15287. * - VertexBuffer.ColorKind
  15288. * - VertexBuffer.MatricesIndicesKind
  15289. * - VertexBuffer.MatricesIndicesExtraKind
  15290. * - VertexBuffer.MatricesWeightsKind
  15291. * - VertexBuffer.MatricesWeightsExtraKind
  15292. *
  15293. * Returns the Mesh.
  15294. */
  15295. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15296. /**
  15297. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15298. * If the mesh has no geometry, it is simply returned as it is.
  15299. * The `data` are either a numeric array either a Float32Array.
  15300. * No new underlying VertexBuffer object is created.
  15301. * 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.
  15302. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15303. *
  15304. * Possible `kind` values :
  15305. * - VertexBuffer.PositionKind
  15306. * - VertexBuffer.UVKind
  15307. * - VertexBuffer.UV2Kind
  15308. * - VertexBuffer.UV3Kind
  15309. * - VertexBuffer.UV4Kind
  15310. * - VertexBuffer.UV5Kind
  15311. * - VertexBuffer.UV6Kind
  15312. * - VertexBuffer.ColorKind
  15313. * - VertexBuffer.MatricesIndicesKind
  15314. * - VertexBuffer.MatricesIndicesExtraKind
  15315. * - VertexBuffer.MatricesWeightsKind
  15316. * - VertexBuffer.MatricesWeightsExtraKind
  15317. *
  15318. * Returns the Mesh.
  15319. */
  15320. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15321. /**
  15322. * Sets the mesh indices.
  15323. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15324. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15325. * This method creates a new index buffer each call.
  15326. * Returns the Mesh.
  15327. */
  15328. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15329. /**
  15330. * Boolean : True if the mesh owns the requested kind of data.
  15331. */
  15332. isVerticesDataPresent(kind: string): boolean;
  15333. /**
  15334. * Returns an array of indices (IndicesArray).
  15335. */
  15336. getIndices(): Nullable<IndicesArray>;
  15337. get _positions(): Nullable<Vector3[]>;
  15338. /**
  15339. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15340. * This means the mesh underlying bounding box and sphere are recomputed.
  15341. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15342. * @returns the current mesh
  15343. */
  15344. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15345. /** @hidden */
  15346. _preActivate(): InstancedMesh;
  15347. /** @hidden */
  15348. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15349. /** @hidden */
  15350. _postActivate(): void;
  15351. getWorldMatrix(): Matrix;
  15352. get isAnInstance(): boolean;
  15353. /**
  15354. * Returns the current associated LOD AbstractMesh.
  15355. */
  15356. getLOD(camera: Camera): AbstractMesh;
  15357. /** @hidden */
  15358. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15359. /** @hidden */
  15360. _syncSubMeshes(): InstancedMesh;
  15361. /** @hidden */
  15362. _generatePointsArray(): boolean;
  15363. /**
  15364. * Creates a new InstancedMesh from the current mesh.
  15365. * - name (string) : the cloned mesh name
  15366. * - newParent (optional Node) : the optional Node to parent the clone to.
  15367. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15368. *
  15369. * Returns the clone.
  15370. */
  15371. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15372. /**
  15373. * Disposes the InstancedMesh.
  15374. * Returns nothing.
  15375. */
  15376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15377. }
  15378. interface Mesh {
  15379. /**
  15380. * Register a custom buffer that will be instanced
  15381. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15382. * @param kind defines the buffer kind
  15383. * @param stride defines the stride in floats
  15384. */
  15385. registerInstancedBuffer(kind: string, stride: number): void;
  15386. /** @hidden */
  15387. _userInstancedBuffersStorage: {
  15388. data: {
  15389. [key: string]: Float32Array;
  15390. };
  15391. sizes: {
  15392. [key: string]: number;
  15393. };
  15394. vertexBuffers: {
  15395. [key: string]: Nullable<VertexBuffer>;
  15396. };
  15397. strides: {
  15398. [key: string]: number;
  15399. };
  15400. };
  15401. }
  15402. interface AbstractMesh {
  15403. /**
  15404. * Object used to store instanced buffers defined by user
  15405. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15406. */
  15407. instancedBuffers: {
  15408. [key: string]: any;
  15409. };
  15410. }
  15411. }
  15412. declare module BABYLON {
  15413. /**
  15414. * Defines the options associated with the creation of a shader material.
  15415. */
  15416. export interface IShaderMaterialOptions {
  15417. /**
  15418. * Does the material work in alpha blend mode
  15419. */
  15420. needAlphaBlending: boolean;
  15421. /**
  15422. * Does the material work in alpha test mode
  15423. */
  15424. needAlphaTesting: boolean;
  15425. /**
  15426. * The list of attribute names used in the shader
  15427. */
  15428. attributes: string[];
  15429. /**
  15430. * The list of unifrom names used in the shader
  15431. */
  15432. uniforms: string[];
  15433. /**
  15434. * The list of UBO names used in the shader
  15435. */
  15436. uniformBuffers: string[];
  15437. /**
  15438. * The list of sampler names used in the shader
  15439. */
  15440. samplers: string[];
  15441. /**
  15442. * The list of defines used in the shader
  15443. */
  15444. defines: string[];
  15445. }
  15446. /**
  15447. * 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.
  15448. *
  15449. * This returned material effects how the mesh will look based on the code in the shaders.
  15450. *
  15451. * @see http://doc.babylonjs.com/how_to/shader_material
  15452. */
  15453. export class ShaderMaterial extends Material {
  15454. private _shaderPath;
  15455. private _options;
  15456. private _textures;
  15457. private _textureArrays;
  15458. private _floats;
  15459. private _ints;
  15460. private _floatsArrays;
  15461. private _colors3;
  15462. private _colors3Arrays;
  15463. private _colors4;
  15464. private _colors4Arrays;
  15465. private _vectors2;
  15466. private _vectors3;
  15467. private _vectors4;
  15468. private _matrices;
  15469. private _matrixArrays;
  15470. private _matrices3x3;
  15471. private _matrices2x2;
  15472. private _vectors2Arrays;
  15473. private _vectors3Arrays;
  15474. private _vectors4Arrays;
  15475. private _cachedWorldViewMatrix;
  15476. private _cachedWorldViewProjectionMatrix;
  15477. private _renderId;
  15478. private _multiview;
  15479. /**
  15480. * Instantiate a new shader material.
  15481. * 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.
  15482. * This returned material effects how the mesh will look based on the code in the shaders.
  15483. * @see http://doc.babylonjs.com/how_to/shader_material
  15484. * @param name Define the name of the material in the scene
  15485. * @param scene Define the scene the material belongs to
  15486. * @param shaderPath Defines the route to the shader code in one of three ways:
  15487. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15488. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15489. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15490. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15491. * @param options Define the options used to create the shader
  15492. */
  15493. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15494. /**
  15495. * Gets the shader path used to define the shader code
  15496. * It can be modified to trigger a new compilation
  15497. */
  15498. get shaderPath(): any;
  15499. /**
  15500. * Sets the shader path used to define the shader code
  15501. * It can be modified to trigger a new compilation
  15502. */
  15503. set shaderPath(shaderPath: any);
  15504. /**
  15505. * Gets the options used to compile the shader.
  15506. * They can be modified to trigger a new compilation
  15507. */
  15508. get options(): IShaderMaterialOptions;
  15509. /**
  15510. * Gets the current class name of the material e.g. "ShaderMaterial"
  15511. * Mainly use in serialization.
  15512. * @returns the class name
  15513. */
  15514. getClassName(): string;
  15515. /**
  15516. * Specifies if the material will require alpha blending
  15517. * @returns a boolean specifying if alpha blending is needed
  15518. */
  15519. needAlphaBlending(): boolean;
  15520. /**
  15521. * Specifies if this material should be rendered in alpha test mode
  15522. * @returns a boolean specifying if an alpha test is needed.
  15523. */
  15524. needAlphaTesting(): boolean;
  15525. private _checkUniform;
  15526. /**
  15527. * Set a texture in the shader.
  15528. * @param name Define the name of the uniform samplers as defined in the shader
  15529. * @param texture Define the texture to bind to this sampler
  15530. * @return the material itself allowing "fluent" like uniform updates
  15531. */
  15532. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15533. /**
  15534. * Set a texture array in the shader.
  15535. * @param name Define the name of the uniform sampler array as defined in the shader
  15536. * @param textures Define the list of textures to bind to this sampler
  15537. * @return the material itself allowing "fluent" like uniform updates
  15538. */
  15539. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15540. /**
  15541. * Set a float 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. setFloat(name: string, value: number): ShaderMaterial;
  15547. /**
  15548. * Set a int 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. setInt(name: string, value: number): ShaderMaterial;
  15554. /**
  15555. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  15561. /**
  15562. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  15568. /**
  15569. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15575. /**
  15576. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  15582. /**
  15583. * Set a vec4 array in the shader from a Color4 array.
  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. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15589. /**
  15590. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  15596. /**
  15597. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  15603. /**
  15604. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  15610. /**
  15611. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15617. /**
  15618. * Set a float32Array in the shader from a matrix array.
  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. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15624. /**
  15625. * Set a mat3 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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15631. /**
  15632. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15638. /**
  15639. * Set a vec2 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. setArray2(name: string, value: number[]): ShaderMaterial;
  15645. /**
  15646. * Set a vec3 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. setArray3(name: string, value: number[]): ShaderMaterial;
  15652. /**
  15653. * Set a vec4 array in the shader from a number array.
  15654. * @param name Define the name of the uniform as defined in the shader
  15655. * @param value Define the value to give to the uniform
  15656. * @return the material itself allowing "fluent" like uniform updates
  15657. */
  15658. setArray4(name: string, value: number[]): ShaderMaterial;
  15659. private _checkCache;
  15660. /**
  15661. * Specifies that the submesh is ready to be used
  15662. * @param mesh defines the mesh to check
  15663. * @param subMesh defines which submesh to check
  15664. * @param useInstances specifies that instances should be used
  15665. * @returns a boolean indicating that the submesh is ready or not
  15666. */
  15667. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15668. /**
  15669. * Checks if the material is ready to render the requested mesh
  15670. * @param mesh Define the mesh to render
  15671. * @param useInstances Define whether or not the material is used with instances
  15672. * @returns true if ready, otherwise false
  15673. */
  15674. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15675. /**
  15676. * Binds the world matrix to the material
  15677. * @param world defines the world transformation matrix
  15678. */
  15679. bindOnlyWorldMatrix(world: Matrix): void;
  15680. /**
  15681. * Binds the material to the mesh
  15682. * @param world defines the world transformation matrix
  15683. * @param mesh defines the mesh to bind the material to
  15684. */
  15685. bind(world: Matrix, mesh?: Mesh): void;
  15686. protected _afterBind(mesh?: Mesh): void;
  15687. /**
  15688. * Gets the active textures from the material
  15689. * @returns an array of textures
  15690. */
  15691. getActiveTextures(): BaseTexture[];
  15692. /**
  15693. * Specifies if the material uses a texture
  15694. * @param texture defines the texture to check against the material
  15695. * @returns a boolean specifying if the material uses the texture
  15696. */
  15697. hasTexture(texture: BaseTexture): boolean;
  15698. /**
  15699. * Makes a duplicate of the material, and gives it a new name
  15700. * @param name defines the new name for the duplicated material
  15701. * @returns the cloned material
  15702. */
  15703. clone(name: string): ShaderMaterial;
  15704. /**
  15705. * Disposes the material
  15706. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15707. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15708. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15709. */
  15710. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15711. /**
  15712. * Serializes this material in a JSON representation
  15713. * @returns the serialized material object
  15714. */
  15715. serialize(): any;
  15716. /**
  15717. * Creates a shader material from parsed shader material data
  15718. * @param source defines the JSON represnetation of the material
  15719. * @param scene defines the hosting scene
  15720. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15721. * @returns a new material
  15722. */
  15723. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15724. }
  15725. }
  15726. declare module BABYLON {
  15727. /** @hidden */
  15728. export var colorPixelShader: {
  15729. name: string;
  15730. shader: string;
  15731. };
  15732. }
  15733. declare module BABYLON {
  15734. /** @hidden */
  15735. export var colorVertexShader: {
  15736. name: string;
  15737. shader: string;
  15738. };
  15739. }
  15740. declare module BABYLON {
  15741. /**
  15742. * Line mesh
  15743. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15744. */
  15745. export class LinesMesh extends Mesh {
  15746. /**
  15747. * If vertex color should be applied to the mesh
  15748. */
  15749. readonly useVertexColor?: boolean | undefined;
  15750. /**
  15751. * If vertex alpha should be applied to the mesh
  15752. */
  15753. readonly useVertexAlpha?: boolean | undefined;
  15754. /**
  15755. * Color of the line (Default: White)
  15756. */
  15757. color: Color3;
  15758. /**
  15759. * Alpha of the line (Default: 1)
  15760. */
  15761. alpha: number;
  15762. /**
  15763. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15764. * This margin is expressed in world space coordinates, so its value may vary.
  15765. * Default value is 0.1
  15766. */
  15767. intersectionThreshold: number;
  15768. private _colorShader;
  15769. private color4;
  15770. /**
  15771. * Creates a new LinesMesh
  15772. * @param name defines the name
  15773. * @param scene defines the hosting scene
  15774. * @param parent defines the parent mesh if any
  15775. * @param source defines the optional source LinesMesh used to clone data from
  15776. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15777. * When false, achieved by calling a clone(), also passing False.
  15778. * This will make creation of children, recursive.
  15779. * @param useVertexColor defines if this LinesMesh supports vertex color
  15780. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15781. */
  15782. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15783. /**
  15784. * If vertex color should be applied to the mesh
  15785. */
  15786. useVertexColor?: boolean | undefined,
  15787. /**
  15788. * If vertex alpha should be applied to the mesh
  15789. */
  15790. useVertexAlpha?: boolean | undefined);
  15791. private _addClipPlaneDefine;
  15792. private _removeClipPlaneDefine;
  15793. isReady(): boolean;
  15794. /**
  15795. * Returns the string "LineMesh"
  15796. */
  15797. getClassName(): string;
  15798. /**
  15799. * @hidden
  15800. */
  15801. get material(): Material;
  15802. /**
  15803. * @hidden
  15804. */
  15805. set material(value: Material);
  15806. /**
  15807. * @hidden
  15808. */
  15809. get checkCollisions(): boolean;
  15810. /** @hidden */
  15811. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15812. /** @hidden */
  15813. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15814. /**
  15815. * Disposes of the line mesh
  15816. * @param doNotRecurse If children should be disposed
  15817. */
  15818. dispose(doNotRecurse?: boolean): void;
  15819. /**
  15820. * Returns a new LineMesh object cloned from the current one.
  15821. */
  15822. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15823. /**
  15824. * Creates a new InstancedLinesMesh object from the mesh model.
  15825. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15826. * @param name defines the name of the new instance
  15827. * @returns a new InstancedLinesMesh
  15828. */
  15829. createInstance(name: string): InstancedLinesMesh;
  15830. }
  15831. /**
  15832. * Creates an instance based on a source LinesMesh
  15833. */
  15834. export class InstancedLinesMesh extends InstancedMesh {
  15835. /**
  15836. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15837. * This margin is expressed in world space coordinates, so its value may vary.
  15838. * Initilized with the intersectionThreshold value of the source LinesMesh
  15839. */
  15840. intersectionThreshold: number;
  15841. constructor(name: string, source: LinesMesh);
  15842. /**
  15843. * Returns the string "InstancedLinesMesh".
  15844. */
  15845. getClassName(): string;
  15846. }
  15847. }
  15848. declare module BABYLON {
  15849. /** @hidden */
  15850. export var linePixelShader: {
  15851. name: string;
  15852. shader: string;
  15853. };
  15854. }
  15855. declare module BABYLON {
  15856. /** @hidden */
  15857. export var lineVertexShader: {
  15858. name: string;
  15859. shader: string;
  15860. };
  15861. }
  15862. declare module BABYLON {
  15863. interface AbstractMesh {
  15864. /**
  15865. * Gets the edgesRenderer associated with the mesh
  15866. */
  15867. edgesRenderer: Nullable<EdgesRenderer>;
  15868. }
  15869. interface LinesMesh {
  15870. /**
  15871. * Enables the edge rendering mode on the mesh.
  15872. * This mode makes the mesh edges visible
  15873. * @param epsilon defines the maximal distance between two angles to detect a face
  15874. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15875. * @returns the currentAbstractMesh
  15876. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15877. */
  15878. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15879. }
  15880. interface InstancedLinesMesh {
  15881. /**
  15882. * Enables the edge rendering mode on the mesh.
  15883. * This mode makes the mesh edges visible
  15884. * @param epsilon defines the maximal distance between two angles to detect a face
  15885. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15886. * @returns the current InstancedLinesMesh
  15887. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15888. */
  15889. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15890. }
  15891. /**
  15892. * Defines the minimum contract an Edges renderer should follow.
  15893. */
  15894. export interface IEdgesRenderer extends IDisposable {
  15895. /**
  15896. * Gets or sets a boolean indicating if the edgesRenderer is active
  15897. */
  15898. isEnabled: boolean;
  15899. /**
  15900. * Renders the edges of the attached mesh,
  15901. */
  15902. render(): void;
  15903. /**
  15904. * Checks wether or not the edges renderer is ready to render.
  15905. * @return true if ready, otherwise false.
  15906. */
  15907. isReady(): boolean;
  15908. }
  15909. /**
  15910. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15911. */
  15912. export class EdgesRenderer implements IEdgesRenderer {
  15913. /**
  15914. * Define the size of the edges with an orthographic camera
  15915. */
  15916. edgesWidthScalerForOrthographic: number;
  15917. /**
  15918. * Define the size of the edges with a perspective camera
  15919. */
  15920. edgesWidthScalerForPerspective: number;
  15921. protected _source: AbstractMesh;
  15922. protected _linesPositions: number[];
  15923. protected _linesNormals: number[];
  15924. protected _linesIndices: number[];
  15925. protected _epsilon: number;
  15926. protected _indicesCount: number;
  15927. protected _lineShader: ShaderMaterial;
  15928. protected _ib: DataBuffer;
  15929. protected _buffers: {
  15930. [key: string]: Nullable<VertexBuffer>;
  15931. };
  15932. protected _checkVerticesInsteadOfIndices: boolean;
  15933. private _meshRebuildObserver;
  15934. private _meshDisposeObserver;
  15935. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15936. isEnabled: boolean;
  15937. /**
  15938. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15939. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15940. * @param source Mesh used to create edges
  15941. * @param epsilon sum of angles in adjacency to check for edge
  15942. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15943. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15944. */
  15945. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15946. protected _prepareRessources(): void;
  15947. /** @hidden */
  15948. _rebuild(): void;
  15949. /**
  15950. * Releases the required resources for the edges renderer
  15951. */
  15952. dispose(): void;
  15953. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15954. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15955. /**
  15956. * Checks if the pair of p0 and p1 is en edge
  15957. * @param faceIndex
  15958. * @param edge
  15959. * @param faceNormals
  15960. * @param p0
  15961. * @param p1
  15962. * @private
  15963. */
  15964. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15965. /**
  15966. * push line into the position, normal and index buffer
  15967. * @protected
  15968. */
  15969. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15970. /**
  15971. * Generates lines edges from adjacencjes
  15972. * @private
  15973. */
  15974. _generateEdgesLines(): void;
  15975. /**
  15976. * Checks wether or not the edges renderer is ready to render.
  15977. * @return true if ready, otherwise false.
  15978. */
  15979. isReady(): boolean;
  15980. /**
  15981. * Renders the edges of the attached mesh,
  15982. */
  15983. render(): void;
  15984. }
  15985. /**
  15986. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15987. */
  15988. export class LineEdgesRenderer extends EdgesRenderer {
  15989. /**
  15990. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15991. * @param source LineMesh used to generate edges
  15992. * @param epsilon not important (specified angle for edge detection)
  15993. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15994. */
  15995. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15996. /**
  15997. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15998. */
  15999. _generateEdgesLines(): void;
  16000. }
  16001. }
  16002. declare module BABYLON {
  16003. /**
  16004. * This represents the object necessary to create a rendering group.
  16005. * This is exclusively used and created by the rendering manager.
  16006. * To modify the behavior, you use the available helpers in your scene or meshes.
  16007. * @hidden
  16008. */
  16009. export class RenderingGroup {
  16010. index: number;
  16011. private static _zeroVector;
  16012. private _scene;
  16013. private _opaqueSubMeshes;
  16014. private _transparentSubMeshes;
  16015. private _alphaTestSubMeshes;
  16016. private _depthOnlySubMeshes;
  16017. private _particleSystems;
  16018. private _spriteManagers;
  16019. private _opaqueSortCompareFn;
  16020. private _alphaTestSortCompareFn;
  16021. private _transparentSortCompareFn;
  16022. private _renderOpaque;
  16023. private _renderAlphaTest;
  16024. private _renderTransparent;
  16025. /** @hidden */
  16026. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16027. onBeforeTransparentRendering: () => void;
  16028. /**
  16029. * Set the opaque sort comparison function.
  16030. * If null the sub meshes will be render in the order they were created
  16031. */
  16032. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16033. /**
  16034. * Set the alpha test sort comparison function.
  16035. * If null the sub meshes will be render in the order they were created
  16036. */
  16037. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16038. /**
  16039. * Set the transparent sort comparison function.
  16040. * If null the sub meshes will be render in the order they were created
  16041. */
  16042. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16043. /**
  16044. * Creates a new rendering group.
  16045. * @param index The rendering group index
  16046. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16047. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16048. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16049. */
  16050. 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>);
  16051. /**
  16052. * Render all the sub meshes contained in the group.
  16053. * @param customRenderFunction Used to override the default render behaviour of the group.
  16054. * @returns true if rendered some submeshes.
  16055. */
  16056. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16057. /**
  16058. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16059. * @param subMeshes The submeshes to render
  16060. */
  16061. private renderOpaqueSorted;
  16062. /**
  16063. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16064. * @param subMeshes The submeshes to render
  16065. */
  16066. private renderAlphaTestSorted;
  16067. /**
  16068. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16069. * @param subMeshes The submeshes to render
  16070. */
  16071. private renderTransparentSorted;
  16072. /**
  16073. * Renders the submeshes in a specified order.
  16074. * @param subMeshes The submeshes to sort before render
  16075. * @param sortCompareFn The comparison function use to sort
  16076. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16077. * @param transparent Specifies to activate blending if true
  16078. */
  16079. private static renderSorted;
  16080. /**
  16081. * Renders the submeshes in the order they were dispatched (no sort applied).
  16082. * @param subMeshes The submeshes to render
  16083. */
  16084. private static renderUnsorted;
  16085. /**
  16086. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16087. * are rendered back to front if in the same alpha index.
  16088. *
  16089. * @param a The first submesh
  16090. * @param b The second submesh
  16091. * @returns The result of the comparison
  16092. */
  16093. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16094. /**
  16095. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16096. * are rendered back to front.
  16097. *
  16098. * @param a The first submesh
  16099. * @param b The second submesh
  16100. * @returns The result of the comparison
  16101. */
  16102. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16103. /**
  16104. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16105. * are rendered front to back (prevent overdraw).
  16106. *
  16107. * @param a The first submesh
  16108. * @param b The second submesh
  16109. * @returns The result of the comparison
  16110. */
  16111. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16112. /**
  16113. * Resets the different lists of submeshes to prepare a new frame.
  16114. */
  16115. prepare(): void;
  16116. dispose(): void;
  16117. /**
  16118. * Inserts the submesh in its correct queue depending on its material.
  16119. * @param subMesh The submesh to dispatch
  16120. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16121. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16122. */
  16123. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16124. dispatchSprites(spriteManager: ISpriteManager): void;
  16125. dispatchParticles(particleSystem: IParticleSystem): void;
  16126. private _renderParticles;
  16127. private _renderSprites;
  16128. }
  16129. }
  16130. declare module BABYLON {
  16131. /**
  16132. * Interface describing the different options available in the rendering manager
  16133. * regarding Auto Clear between groups.
  16134. */
  16135. export interface IRenderingManagerAutoClearSetup {
  16136. /**
  16137. * Defines whether or not autoclear is enable.
  16138. */
  16139. autoClear: boolean;
  16140. /**
  16141. * Defines whether or not to autoclear the depth buffer.
  16142. */
  16143. depth: boolean;
  16144. /**
  16145. * Defines whether or not to autoclear the stencil buffer.
  16146. */
  16147. stencil: boolean;
  16148. }
  16149. /**
  16150. * This class is used by the onRenderingGroupObservable
  16151. */
  16152. export class RenderingGroupInfo {
  16153. /**
  16154. * The Scene that being rendered
  16155. */
  16156. scene: Scene;
  16157. /**
  16158. * The camera currently used for the rendering pass
  16159. */
  16160. camera: Nullable<Camera>;
  16161. /**
  16162. * The ID of the renderingGroup being processed
  16163. */
  16164. renderingGroupId: number;
  16165. }
  16166. /**
  16167. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16168. * It is enable to manage the different groups as well as the different necessary sort functions.
  16169. * This should not be used directly aside of the few static configurations
  16170. */
  16171. export class RenderingManager {
  16172. /**
  16173. * The max id used for rendering groups (not included)
  16174. */
  16175. static MAX_RENDERINGGROUPS: number;
  16176. /**
  16177. * The min id used for rendering groups (included)
  16178. */
  16179. static MIN_RENDERINGGROUPS: number;
  16180. /**
  16181. * Used to globally prevent autoclearing scenes.
  16182. */
  16183. static AUTOCLEAR: boolean;
  16184. /**
  16185. * @hidden
  16186. */
  16187. _useSceneAutoClearSetup: boolean;
  16188. private _scene;
  16189. private _renderingGroups;
  16190. private _depthStencilBufferAlreadyCleaned;
  16191. private _autoClearDepthStencil;
  16192. private _customOpaqueSortCompareFn;
  16193. private _customAlphaTestSortCompareFn;
  16194. private _customTransparentSortCompareFn;
  16195. private _renderingGroupInfo;
  16196. /**
  16197. * Instantiates a new rendering group for a particular scene
  16198. * @param scene Defines the scene the groups belongs to
  16199. */
  16200. constructor(scene: Scene);
  16201. private _clearDepthStencilBuffer;
  16202. /**
  16203. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16204. * @hidden
  16205. */
  16206. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16207. /**
  16208. * Resets the different information of the group to prepare a new frame
  16209. * @hidden
  16210. */
  16211. reset(): void;
  16212. /**
  16213. * Dispose and release the group and its associated resources.
  16214. * @hidden
  16215. */
  16216. dispose(): void;
  16217. /**
  16218. * Clear the info related to rendering groups preventing retention points during dispose.
  16219. */
  16220. freeRenderingGroups(): void;
  16221. private _prepareRenderingGroup;
  16222. /**
  16223. * Add a sprite manager to the rendering manager in order to render it this frame.
  16224. * @param spriteManager Define the sprite manager to render
  16225. */
  16226. dispatchSprites(spriteManager: ISpriteManager): void;
  16227. /**
  16228. * Add a particle system to the rendering manager in order to render it this frame.
  16229. * @param particleSystem Define the particle system to render
  16230. */
  16231. dispatchParticles(particleSystem: IParticleSystem): void;
  16232. /**
  16233. * Add a submesh to the manager in order to render it this frame
  16234. * @param subMesh The submesh to dispatch
  16235. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16236. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16237. */
  16238. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16239. /**
  16240. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16241. * This allowed control for front to back rendering or reversly depending of the special needs.
  16242. *
  16243. * @param renderingGroupId The rendering group id corresponding to its index
  16244. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16245. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16246. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16247. */
  16248. 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;
  16249. /**
  16250. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16251. *
  16252. * @param renderingGroupId The rendering group id corresponding to its index
  16253. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16254. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16255. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16256. */
  16257. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16258. /**
  16259. * Gets the current auto clear configuration for one rendering group of the rendering
  16260. * manager.
  16261. * @param index the rendering group index to get the information for
  16262. * @returns The auto clear setup for the requested rendering group
  16263. */
  16264. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16265. }
  16266. }
  16267. declare module BABYLON {
  16268. /**
  16269. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16270. */
  16271. export interface ICustomShaderOptions {
  16272. /**
  16273. * Gets or sets the custom shader name to use
  16274. */
  16275. shaderName: string;
  16276. /**
  16277. * The list of attribute names used in the shader
  16278. */
  16279. attributes?: string[];
  16280. /**
  16281. * The list of unifrom names used in the shader
  16282. */
  16283. uniforms?: string[];
  16284. /**
  16285. * The list of sampler names used in the shader
  16286. */
  16287. samplers?: string[];
  16288. /**
  16289. * The list of defines used in the shader
  16290. */
  16291. defines?: string[];
  16292. }
  16293. /**
  16294. * Interface to implement to create a shadow generator compatible with BJS.
  16295. */
  16296. export interface IShadowGenerator {
  16297. /**
  16298. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16299. * @returns The render target texture if present otherwise, null
  16300. */
  16301. getShadowMap(): Nullable<RenderTargetTexture>;
  16302. /**
  16303. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16304. * @param subMesh The submesh we want to render in the shadow map
  16305. * @param useInstances Defines wether will draw in the map using instances
  16306. * @returns true if ready otherwise, false
  16307. */
  16308. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16309. /**
  16310. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16311. * @param defines Defines of the material we want to update
  16312. * @param lightIndex Index of the light in the enabled light list of the material
  16313. */
  16314. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16315. /**
  16316. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16317. * defined in the generator but impacting the effect).
  16318. * It implies the unifroms available on the materials are the standard BJS ones.
  16319. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16320. * @param effect The effect we are binfing the information for
  16321. */
  16322. bindShadowLight(lightIndex: string, effect: Effect): void;
  16323. /**
  16324. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16325. * (eq to shadow prjection matrix * light transform matrix)
  16326. * @returns The transform matrix used to create the shadow map
  16327. */
  16328. getTransformMatrix(): Matrix;
  16329. /**
  16330. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16331. * Cube and 2D textures for instance.
  16332. */
  16333. recreateShadowMap(): void;
  16334. /**
  16335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16336. * @param onCompiled Callback triggered at the and of the effects compilation
  16337. * @param options Sets of optional options forcing the compilation with different modes
  16338. */
  16339. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16340. useInstances: boolean;
  16341. }>): void;
  16342. /**
  16343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16344. * @param options Sets of optional options forcing the compilation with different modes
  16345. * @returns A promise that resolves when the compilation completes
  16346. */
  16347. forceCompilationAsync(options?: Partial<{
  16348. useInstances: boolean;
  16349. }>): Promise<void>;
  16350. /**
  16351. * Serializes the shadow generator setup to a json object.
  16352. * @returns The serialized JSON object
  16353. */
  16354. serialize(): any;
  16355. /**
  16356. * Disposes the Shadow map and related Textures and effects.
  16357. */
  16358. dispose(): void;
  16359. }
  16360. /**
  16361. * Default implementation IShadowGenerator.
  16362. * This is the main object responsible of generating shadows in the framework.
  16363. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16364. */
  16365. export class ShadowGenerator implements IShadowGenerator {
  16366. /**
  16367. * Name of the shadow generator class
  16368. */
  16369. static CLASSNAME: string;
  16370. /**
  16371. * Shadow generator mode None: no filtering applied.
  16372. */
  16373. static readonly FILTER_NONE: number;
  16374. /**
  16375. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16376. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16377. */
  16378. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16379. /**
  16380. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16381. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16382. */
  16383. static readonly FILTER_POISSONSAMPLING: number;
  16384. /**
  16385. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16386. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16387. */
  16388. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16389. /**
  16390. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16391. * edge artifacts on steep falloff.
  16392. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16393. */
  16394. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16395. /**
  16396. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16397. * edge artifacts on steep falloff.
  16398. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16399. */
  16400. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16401. /**
  16402. * Shadow generator mode PCF: Percentage Closer Filtering
  16403. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16404. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16405. */
  16406. static readonly FILTER_PCF: number;
  16407. /**
  16408. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16409. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16410. * Contact Hardening
  16411. */
  16412. static readonly FILTER_PCSS: number;
  16413. /**
  16414. * Reserved for PCF and PCSS
  16415. * Highest Quality.
  16416. *
  16417. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16418. *
  16419. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16420. */
  16421. static readonly QUALITY_HIGH: number;
  16422. /**
  16423. * Reserved for PCF and PCSS
  16424. * Good tradeoff for quality/perf cross devices
  16425. *
  16426. * Execute PCF on a 3*3 kernel.
  16427. *
  16428. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16429. */
  16430. static readonly QUALITY_MEDIUM: number;
  16431. /**
  16432. * Reserved for PCF and PCSS
  16433. * The lowest quality but the fastest.
  16434. *
  16435. * Execute PCF on a 1*1 kernel.
  16436. *
  16437. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16438. */
  16439. static readonly QUALITY_LOW: number;
  16440. /** Gets or sets the custom shader name to use */
  16441. customShaderOptions: ICustomShaderOptions;
  16442. /**
  16443. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16444. */
  16445. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16446. /**
  16447. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16448. */
  16449. onAfterShadowMapRenderObservable: Observable<Effect>;
  16450. /**
  16451. * Observable triggered before a mesh is rendered in the shadow map.
  16452. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16453. */
  16454. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16455. /**
  16456. * Observable triggered after a mesh is rendered in the shadow map.
  16457. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16458. */
  16459. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16460. protected _bias: number;
  16461. /**
  16462. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16463. */
  16464. get bias(): number;
  16465. /**
  16466. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16467. */
  16468. set bias(bias: number);
  16469. protected _normalBias: number;
  16470. /**
  16471. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16472. */
  16473. get normalBias(): number;
  16474. /**
  16475. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16476. */
  16477. set normalBias(normalBias: number);
  16478. protected _blurBoxOffset: number;
  16479. /**
  16480. * Gets the blur box offset: offset applied during the blur pass.
  16481. * Only useful if useKernelBlur = false
  16482. */
  16483. get blurBoxOffset(): number;
  16484. /**
  16485. * Sets the blur box offset: offset applied during the blur pass.
  16486. * Only useful if useKernelBlur = false
  16487. */
  16488. set blurBoxOffset(value: number);
  16489. protected _blurScale: number;
  16490. /**
  16491. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16492. * 2 means half of the size.
  16493. */
  16494. get blurScale(): number;
  16495. /**
  16496. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16497. * 2 means half of the size.
  16498. */
  16499. set blurScale(value: number);
  16500. protected _blurKernel: number;
  16501. /**
  16502. * Gets the blur kernel: kernel size of the blur pass.
  16503. * Only useful if useKernelBlur = true
  16504. */
  16505. get blurKernel(): number;
  16506. /**
  16507. * Sets the blur kernel: kernel size of the blur pass.
  16508. * Only useful if useKernelBlur = true
  16509. */
  16510. set blurKernel(value: number);
  16511. protected _useKernelBlur: boolean;
  16512. /**
  16513. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16514. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16515. */
  16516. get useKernelBlur(): boolean;
  16517. /**
  16518. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16519. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16520. */
  16521. set useKernelBlur(value: boolean);
  16522. protected _depthScale: number;
  16523. /**
  16524. * Gets the depth scale used in ESM mode.
  16525. */
  16526. get depthScale(): number;
  16527. /**
  16528. * Sets the depth scale used in ESM mode.
  16529. * This can override the scale stored on the light.
  16530. */
  16531. set depthScale(value: number);
  16532. protected _validateFilter(filter: number): number;
  16533. protected _filter: number;
  16534. /**
  16535. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16536. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16537. */
  16538. get filter(): number;
  16539. /**
  16540. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16541. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16542. */
  16543. set filter(value: number);
  16544. /**
  16545. * Gets if the current filter is set to Poisson Sampling.
  16546. */
  16547. get usePoissonSampling(): boolean;
  16548. /**
  16549. * Sets the current filter to Poisson Sampling.
  16550. */
  16551. set usePoissonSampling(value: boolean);
  16552. /**
  16553. * Gets if the current filter is set to ESM.
  16554. */
  16555. get useExponentialShadowMap(): boolean;
  16556. /**
  16557. * Sets the current filter is to ESM.
  16558. */
  16559. set useExponentialShadowMap(value: boolean);
  16560. /**
  16561. * Gets if the current filter is set to filtered ESM.
  16562. */
  16563. get useBlurExponentialShadowMap(): boolean;
  16564. /**
  16565. * Gets if the current filter is set to filtered ESM.
  16566. */
  16567. set useBlurExponentialShadowMap(value: boolean);
  16568. /**
  16569. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16570. * exponential to prevent steep falloff artifacts).
  16571. */
  16572. get useCloseExponentialShadowMap(): boolean;
  16573. /**
  16574. * Sets the current filter to "close ESM" (using the inverse of the
  16575. * exponential to prevent steep falloff artifacts).
  16576. */
  16577. set useCloseExponentialShadowMap(value: boolean);
  16578. /**
  16579. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16580. * exponential to prevent steep falloff artifacts).
  16581. */
  16582. get useBlurCloseExponentialShadowMap(): boolean;
  16583. /**
  16584. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16585. * exponential to prevent steep falloff artifacts).
  16586. */
  16587. set useBlurCloseExponentialShadowMap(value: boolean);
  16588. /**
  16589. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16590. */
  16591. get usePercentageCloserFiltering(): boolean;
  16592. /**
  16593. * Sets the current filter to "PCF" (percentage closer filtering).
  16594. */
  16595. set usePercentageCloserFiltering(value: boolean);
  16596. protected _filteringQuality: number;
  16597. /**
  16598. * Gets the PCF or PCSS Quality.
  16599. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16600. */
  16601. get filteringQuality(): number;
  16602. /**
  16603. * Sets the PCF or PCSS Quality.
  16604. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16605. */
  16606. set filteringQuality(filteringQuality: number);
  16607. /**
  16608. * Gets if the current filter is set to "PCSS" (contact hardening).
  16609. */
  16610. get useContactHardeningShadow(): boolean;
  16611. /**
  16612. * Sets the current filter to "PCSS" (contact hardening).
  16613. */
  16614. set useContactHardeningShadow(value: boolean);
  16615. protected _contactHardeningLightSizeUVRatio: number;
  16616. /**
  16617. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16618. * Using a ratio helps keeping shape stability independently of the map size.
  16619. *
  16620. * It does not account for the light projection as it was having too much
  16621. * instability during the light setup or during light position changes.
  16622. *
  16623. * Only valid if useContactHardeningShadow is true.
  16624. */
  16625. get contactHardeningLightSizeUVRatio(): number;
  16626. /**
  16627. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16628. * Using a ratio helps keeping shape stability independently of the map size.
  16629. *
  16630. * It does not account for the light projection as it was having too much
  16631. * instability during the light setup or during light position changes.
  16632. *
  16633. * Only valid if useContactHardeningShadow is true.
  16634. */
  16635. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16636. protected _darkness: number;
  16637. /** Gets or sets the actual darkness of a shadow */
  16638. get darkness(): number;
  16639. set darkness(value: number);
  16640. /**
  16641. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16642. * 0 means strongest and 1 would means no shadow.
  16643. * @returns the darkness.
  16644. */
  16645. getDarkness(): number;
  16646. /**
  16647. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16648. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16649. * @returns the shadow generator allowing fluent coding.
  16650. */
  16651. setDarkness(darkness: number): ShadowGenerator;
  16652. protected _transparencyShadow: boolean;
  16653. /** Gets or sets the ability to have transparent shadow */
  16654. get transparencyShadow(): boolean;
  16655. set transparencyShadow(value: boolean);
  16656. /**
  16657. * Sets the ability to have transparent shadow (boolean).
  16658. * @param transparent True if transparent else False
  16659. * @returns the shadow generator allowing fluent coding
  16660. */
  16661. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16662. protected _shadowMap: Nullable<RenderTargetTexture>;
  16663. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16664. /**
  16665. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16666. * @returns The render target texture if present otherwise, null
  16667. */
  16668. getShadowMap(): Nullable<RenderTargetTexture>;
  16669. /**
  16670. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16671. * @returns The render target texture if the shadow map is present otherwise, null
  16672. */
  16673. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16674. /**
  16675. * Gets the class name of that object
  16676. * @returns "ShadowGenerator"
  16677. */
  16678. getClassName(): string;
  16679. /**
  16680. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16681. * @param mesh Mesh to add
  16682. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16683. * @returns the Shadow Generator itself
  16684. */
  16685. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16686. /**
  16687. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16688. * @param mesh Mesh to remove
  16689. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16690. * @returns the Shadow Generator itself
  16691. */
  16692. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16693. /**
  16694. * Controls the extent to which the shadows fade out at the edge of the frustum
  16695. */
  16696. frustumEdgeFalloff: number;
  16697. protected _light: IShadowLight;
  16698. /**
  16699. * Returns the associated light object.
  16700. * @returns the light generating the shadow
  16701. */
  16702. getLight(): IShadowLight;
  16703. /**
  16704. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16705. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16706. * It might on the other hand introduce peter panning.
  16707. */
  16708. forceBackFacesOnly: boolean;
  16709. protected _scene: Scene;
  16710. protected _lightDirection: Vector3;
  16711. protected _effect: Effect;
  16712. protected _viewMatrix: Matrix;
  16713. protected _projectionMatrix: Matrix;
  16714. protected _transformMatrix: Matrix;
  16715. protected _cachedPosition: Vector3;
  16716. protected _cachedDirection: Vector3;
  16717. protected _cachedDefines: string;
  16718. protected _currentRenderID: number;
  16719. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16720. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16721. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16722. protected _blurPostProcesses: PostProcess[];
  16723. protected _mapSize: number;
  16724. protected _currentFaceIndex: number;
  16725. protected _currentFaceIndexCache: number;
  16726. protected _textureType: number;
  16727. protected _defaultTextureMatrix: Matrix;
  16728. protected _storedUniqueId: Nullable<number>;
  16729. /** @hidden */
  16730. static _SceneComponentInitialization: (scene: Scene) => void;
  16731. /**
  16732. * Creates a ShadowGenerator object.
  16733. * A ShadowGenerator is the required tool to use the shadows.
  16734. * Each light casting shadows needs to use its own ShadowGenerator.
  16735. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16736. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16737. * @param light The light object generating the shadows.
  16738. * @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.
  16739. */
  16740. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16741. protected _initializeGenerator(): void;
  16742. protected _createTargetRenderTexture(): void;
  16743. protected _initializeShadowMap(): void;
  16744. protected _initializeBlurRTTAndPostProcesses(): void;
  16745. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16746. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16747. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16748. protected _applyFilterValues(): void;
  16749. /**
  16750. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16751. * @param onCompiled Callback triggered at the and of the effects compilation
  16752. * @param options Sets of optional options forcing the compilation with different modes
  16753. */
  16754. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16755. useInstances: boolean;
  16756. }>): void;
  16757. /**
  16758. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16759. * @param options Sets of optional options forcing the compilation with different modes
  16760. * @returns A promise that resolves when the compilation completes
  16761. */
  16762. forceCompilationAsync(options?: Partial<{
  16763. useInstances: boolean;
  16764. }>): Promise<void>;
  16765. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16766. /**
  16767. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16768. * @param subMesh The submesh we want to render in the shadow map
  16769. * @param useInstances Defines wether will draw in the map using instances
  16770. * @returns true if ready otherwise, false
  16771. */
  16772. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16773. /**
  16774. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16775. * @param defines Defines of the material we want to update
  16776. * @param lightIndex Index of the light in the enabled light list of the material
  16777. */
  16778. prepareDefines(defines: any, lightIndex: number): void;
  16779. /**
  16780. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16781. * defined in the generator but impacting the effect).
  16782. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16783. * @param effect The effect we are binfing the information for
  16784. */
  16785. bindShadowLight(lightIndex: string, effect: Effect): void;
  16786. /**
  16787. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16788. * (eq to shadow prjection matrix * light transform matrix)
  16789. * @returns The transform matrix used to create the shadow map
  16790. */
  16791. getTransformMatrix(): Matrix;
  16792. /**
  16793. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16794. * Cube and 2D textures for instance.
  16795. */
  16796. recreateShadowMap(): void;
  16797. protected _disposeBlurPostProcesses(): void;
  16798. protected _disposeRTTandPostProcesses(): void;
  16799. /**
  16800. * Disposes the ShadowGenerator.
  16801. * Returns nothing.
  16802. */
  16803. dispose(): void;
  16804. /**
  16805. * Serializes the shadow generator setup to a json object.
  16806. * @returns The serialized JSON object
  16807. */
  16808. serialize(): any;
  16809. /**
  16810. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16811. * @param parsedShadowGenerator The JSON object to parse
  16812. * @param scene The scene to create the shadow map for
  16813. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16814. * @returns The parsed shadow generator
  16815. */
  16816. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16817. }
  16818. }
  16819. declare module BABYLON {
  16820. /**
  16821. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16822. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16823. * 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.
  16824. */
  16825. export abstract class Light extends Node {
  16826. /**
  16827. * Falloff Default: light is falling off following the material specification:
  16828. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16829. */
  16830. static readonly FALLOFF_DEFAULT: number;
  16831. /**
  16832. * Falloff Physical: light is falling off following the inverse squared distance law.
  16833. */
  16834. static readonly FALLOFF_PHYSICAL: number;
  16835. /**
  16836. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16837. * to enhance interoperability with other engines.
  16838. */
  16839. static readonly FALLOFF_GLTF: number;
  16840. /**
  16841. * Falloff Standard: light is falling off like in the standard material
  16842. * to enhance interoperability with other materials.
  16843. */
  16844. static readonly FALLOFF_STANDARD: number;
  16845. /**
  16846. * If every light affecting the material is in this lightmapMode,
  16847. * material.lightmapTexture adds or multiplies
  16848. * (depends on material.useLightmapAsShadowmap)
  16849. * after every other light calculations.
  16850. */
  16851. static readonly LIGHTMAP_DEFAULT: number;
  16852. /**
  16853. * material.lightmapTexture as only diffuse lighting from this light
  16854. * adds only specular lighting from this light
  16855. * adds dynamic shadows
  16856. */
  16857. static readonly LIGHTMAP_SPECULAR: number;
  16858. /**
  16859. * material.lightmapTexture as only lighting
  16860. * no light calculation from this light
  16861. * only adds dynamic shadows from this light
  16862. */
  16863. static readonly LIGHTMAP_SHADOWSONLY: number;
  16864. /**
  16865. * Each light type uses the default quantity according to its type:
  16866. * point/spot lights use luminous intensity
  16867. * directional lights use illuminance
  16868. */
  16869. static readonly INTENSITYMODE_AUTOMATIC: number;
  16870. /**
  16871. * lumen (lm)
  16872. */
  16873. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16874. /**
  16875. * candela (lm/sr)
  16876. */
  16877. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16878. /**
  16879. * lux (lm/m^2)
  16880. */
  16881. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16882. /**
  16883. * nit (cd/m^2)
  16884. */
  16885. static readonly INTENSITYMODE_LUMINANCE: number;
  16886. /**
  16887. * Light type const id of the point light.
  16888. */
  16889. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16890. /**
  16891. * Light type const id of the directional light.
  16892. */
  16893. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16894. /**
  16895. * Light type const id of the spot light.
  16896. */
  16897. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16898. /**
  16899. * Light type const id of the hemispheric light.
  16900. */
  16901. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16902. /**
  16903. * Diffuse gives the basic color to an object.
  16904. */
  16905. diffuse: Color3;
  16906. /**
  16907. * Specular produces a highlight color on an object.
  16908. * Note: This is note affecting PBR materials.
  16909. */
  16910. specular: Color3;
  16911. /**
  16912. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16913. * falling off base on range or angle.
  16914. * This can be set to any values in Light.FALLOFF_x.
  16915. *
  16916. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16917. * other types of materials.
  16918. */
  16919. falloffType: number;
  16920. /**
  16921. * Strength of the light.
  16922. * Note: By default it is define in the framework own unit.
  16923. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16924. */
  16925. intensity: number;
  16926. private _range;
  16927. protected _inverseSquaredRange: number;
  16928. /**
  16929. * Defines how far from the source the light is impacting in scene units.
  16930. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16931. */
  16932. get range(): number;
  16933. /**
  16934. * Defines how far from the source the light is impacting in scene units.
  16935. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16936. */
  16937. set range(value: number);
  16938. /**
  16939. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16940. * of light.
  16941. */
  16942. private _photometricScale;
  16943. private _intensityMode;
  16944. /**
  16945. * Gets the photometric scale used to interpret the intensity.
  16946. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16947. */
  16948. get intensityMode(): number;
  16949. /**
  16950. * Sets the photometric scale used to interpret the intensity.
  16951. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16952. */
  16953. set intensityMode(value: number);
  16954. private _radius;
  16955. /**
  16956. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16957. */
  16958. get radius(): number;
  16959. /**
  16960. * sets the light radius used by PBR Materials to simulate soft area lights.
  16961. */
  16962. set radius(value: number);
  16963. private _renderPriority;
  16964. /**
  16965. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16966. * exceeding the number allowed of the materials.
  16967. */
  16968. renderPriority: number;
  16969. private _shadowEnabled;
  16970. /**
  16971. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16972. * the current shadow generator.
  16973. */
  16974. get shadowEnabled(): boolean;
  16975. /**
  16976. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16977. * the current shadow generator.
  16978. */
  16979. set shadowEnabled(value: boolean);
  16980. private _includedOnlyMeshes;
  16981. /**
  16982. * Gets the only meshes impacted by this light.
  16983. */
  16984. get includedOnlyMeshes(): AbstractMesh[];
  16985. /**
  16986. * Sets the only meshes impacted by this light.
  16987. */
  16988. set includedOnlyMeshes(value: AbstractMesh[]);
  16989. private _excludedMeshes;
  16990. /**
  16991. * Gets the meshes not impacted by this light.
  16992. */
  16993. get excludedMeshes(): AbstractMesh[];
  16994. /**
  16995. * Sets the meshes not impacted by this light.
  16996. */
  16997. set excludedMeshes(value: AbstractMesh[]);
  16998. private _excludeWithLayerMask;
  16999. /**
  17000. * Gets the layer id use to find what meshes are not impacted by the light.
  17001. * Inactive if 0
  17002. */
  17003. get excludeWithLayerMask(): number;
  17004. /**
  17005. * Sets the layer id use to find what meshes are not impacted by the light.
  17006. * Inactive if 0
  17007. */
  17008. set excludeWithLayerMask(value: number);
  17009. private _includeOnlyWithLayerMask;
  17010. /**
  17011. * Gets the layer id use to find what meshes are impacted by the light.
  17012. * Inactive if 0
  17013. */
  17014. get includeOnlyWithLayerMask(): number;
  17015. /**
  17016. * Sets the layer id use to find what meshes are impacted by the light.
  17017. * Inactive if 0
  17018. */
  17019. set includeOnlyWithLayerMask(value: number);
  17020. private _lightmapMode;
  17021. /**
  17022. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17023. */
  17024. get lightmapMode(): number;
  17025. /**
  17026. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17027. */
  17028. set lightmapMode(value: number);
  17029. /**
  17030. * Shadow generator associted to the light.
  17031. * @hidden Internal use only.
  17032. */
  17033. _shadowGenerator: Nullable<IShadowGenerator>;
  17034. /**
  17035. * @hidden Internal use only.
  17036. */
  17037. _excludedMeshesIds: string[];
  17038. /**
  17039. * @hidden Internal use only.
  17040. */
  17041. _includedOnlyMeshesIds: string[];
  17042. /**
  17043. * The current light unifom buffer.
  17044. * @hidden Internal use only.
  17045. */
  17046. _uniformBuffer: UniformBuffer;
  17047. /** @hidden */
  17048. _renderId: number;
  17049. /**
  17050. * Creates a Light object in the scene.
  17051. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17052. * @param name The firendly name of the light
  17053. * @param scene The scene the light belongs too
  17054. */
  17055. constructor(name: string, scene: Scene);
  17056. protected abstract _buildUniformLayout(): void;
  17057. /**
  17058. * Sets the passed Effect "effect" with the Light information.
  17059. * @param effect The effect to update
  17060. * @param lightIndex The index of the light in the effect to update
  17061. * @returns The light
  17062. */
  17063. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17064. /**
  17065. * Sets the passed Effect "effect" with the Light textures.
  17066. * @param effect The effect to update
  17067. * @param lightIndex The index of the light in the effect to update
  17068. * @returns The light
  17069. */
  17070. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17071. /**
  17072. * Binds the lights information from the scene to the effect for the given mesh.
  17073. * @param lightIndex Light index
  17074. * @param scene The scene where the light belongs to
  17075. * @param effect The effect we are binding the data to
  17076. * @param useSpecular Defines if specular is supported
  17077. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17078. */
  17079. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17080. /**
  17081. * Sets the passed Effect "effect" with the Light information.
  17082. * @param effect The effect to update
  17083. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17084. * @returns The light
  17085. */
  17086. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17087. /**
  17088. * Returns the string "Light".
  17089. * @returns the class name
  17090. */
  17091. getClassName(): string;
  17092. /** @hidden */
  17093. readonly _isLight: boolean;
  17094. /**
  17095. * Converts the light information to a readable string for debug purpose.
  17096. * @param fullDetails Supports for multiple levels of logging within scene loading
  17097. * @returns the human readable light info
  17098. */
  17099. toString(fullDetails?: boolean): string;
  17100. /** @hidden */
  17101. protected _syncParentEnabledState(): void;
  17102. /**
  17103. * Set the enabled state of this node.
  17104. * @param value - the new enabled state
  17105. */
  17106. setEnabled(value: boolean): void;
  17107. /**
  17108. * Returns the Light associated shadow generator if any.
  17109. * @return the associated shadow generator.
  17110. */
  17111. getShadowGenerator(): Nullable<IShadowGenerator>;
  17112. /**
  17113. * Returns a Vector3, the absolute light position in the World.
  17114. * @returns the world space position of the light
  17115. */
  17116. getAbsolutePosition(): Vector3;
  17117. /**
  17118. * Specifies if the light will affect the passed mesh.
  17119. * @param mesh The mesh to test against the light
  17120. * @return true the mesh is affected otherwise, false.
  17121. */
  17122. canAffectMesh(mesh: AbstractMesh): boolean;
  17123. /**
  17124. * Sort function to order lights for rendering.
  17125. * @param a First Light object to compare to second.
  17126. * @param b Second Light object to compare first.
  17127. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17128. */
  17129. static CompareLightsPriority(a: Light, b: Light): number;
  17130. /**
  17131. * Releases resources associated with this node.
  17132. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17133. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17134. */
  17135. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17136. /**
  17137. * Returns the light type ID (integer).
  17138. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17139. */
  17140. getTypeID(): number;
  17141. /**
  17142. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17143. * @returns the scaled intensity in intensity mode unit
  17144. */
  17145. getScaledIntensity(): number;
  17146. /**
  17147. * Returns a new Light object, named "name", from the current one.
  17148. * @param name The name of the cloned light
  17149. * @returns the new created light
  17150. */
  17151. clone(name: string): Nullable<Light>;
  17152. /**
  17153. * Serializes the current light into a Serialization object.
  17154. * @returns the serialized object.
  17155. */
  17156. serialize(): any;
  17157. /**
  17158. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17159. * This new light is named "name" and added to the passed scene.
  17160. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17161. * @param name The friendly name of the light
  17162. * @param scene The scene the new light will belong to
  17163. * @returns the constructor function
  17164. */
  17165. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17166. /**
  17167. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17168. * @param parsedLight The JSON representation of the light
  17169. * @param scene The scene to create the parsed light in
  17170. * @returns the created light after parsing
  17171. */
  17172. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17173. private _hookArrayForExcluded;
  17174. private _hookArrayForIncludedOnly;
  17175. private _resyncMeshes;
  17176. /**
  17177. * Forces the meshes to update their light related information in their rendering used effects
  17178. * @hidden Internal Use Only
  17179. */
  17180. _markMeshesAsLightDirty(): void;
  17181. /**
  17182. * Recomputes the cached photometric scale if needed.
  17183. */
  17184. private _computePhotometricScale;
  17185. /**
  17186. * Returns the Photometric Scale according to the light type and intensity mode.
  17187. */
  17188. private _getPhotometricScale;
  17189. /**
  17190. * Reorder the light in the scene according to their defined priority.
  17191. * @hidden Internal Use Only
  17192. */
  17193. _reorderLightsInScene(): void;
  17194. /**
  17195. * Prepares the list of defines specific to the light type.
  17196. * @param defines the list of defines
  17197. * @param lightIndex defines the index of the light for the effect
  17198. */
  17199. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17200. }
  17201. }
  17202. declare module BABYLON {
  17203. /**
  17204. * Interface used to define Action
  17205. */
  17206. export interface IAction {
  17207. /**
  17208. * Trigger for the action
  17209. */
  17210. trigger: number;
  17211. /** Options of the trigger */
  17212. triggerOptions: any;
  17213. /**
  17214. * Gets the trigger parameters
  17215. * @returns the trigger parameters
  17216. */
  17217. getTriggerParameter(): any;
  17218. /**
  17219. * Internal only - executes current action event
  17220. * @hidden
  17221. */
  17222. _executeCurrent(evt?: ActionEvent): void;
  17223. /**
  17224. * Serialize placeholder for child classes
  17225. * @param parent of child
  17226. * @returns the serialized object
  17227. */
  17228. serialize(parent: any): any;
  17229. /**
  17230. * Internal only
  17231. * @hidden
  17232. */
  17233. _prepare(): void;
  17234. /**
  17235. * Internal only - manager for action
  17236. * @hidden
  17237. */
  17238. _actionManager: AbstractActionManager;
  17239. /**
  17240. * Adds action to chain of actions, may be a DoNothingAction
  17241. * @param action defines the next action to execute
  17242. * @returns The action passed in
  17243. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17244. */
  17245. then(action: IAction): IAction;
  17246. }
  17247. /**
  17248. * The action to be carried out following a trigger
  17249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17250. */
  17251. export class Action implements IAction {
  17252. /** the trigger, with or without parameters, for the action */
  17253. triggerOptions: any;
  17254. /**
  17255. * Trigger for the action
  17256. */
  17257. trigger: number;
  17258. /**
  17259. * Internal only - manager for action
  17260. * @hidden
  17261. */
  17262. _actionManager: ActionManager;
  17263. private _nextActiveAction;
  17264. private _child;
  17265. private _condition?;
  17266. private _triggerParameter;
  17267. /**
  17268. * An event triggered prior to action being executed.
  17269. */
  17270. onBeforeExecuteObservable: Observable<Action>;
  17271. /**
  17272. * Creates a new Action
  17273. * @param triggerOptions the trigger, with or without parameters, for the action
  17274. * @param condition an optional determinant of action
  17275. */
  17276. constructor(
  17277. /** the trigger, with or without parameters, for the action */
  17278. triggerOptions: any, condition?: Condition);
  17279. /**
  17280. * Internal only
  17281. * @hidden
  17282. */
  17283. _prepare(): void;
  17284. /**
  17285. * Gets the trigger parameters
  17286. * @returns the trigger parameters
  17287. */
  17288. getTriggerParameter(): any;
  17289. /**
  17290. * Internal only - executes current action event
  17291. * @hidden
  17292. */
  17293. _executeCurrent(evt?: ActionEvent): void;
  17294. /**
  17295. * Execute placeholder for child classes
  17296. * @param evt optional action event
  17297. */
  17298. execute(evt?: ActionEvent): void;
  17299. /**
  17300. * Skips to next active action
  17301. */
  17302. skipToNextActiveAction(): void;
  17303. /**
  17304. * Adds action to chain of actions, may be a DoNothingAction
  17305. * @param action defines the next action to execute
  17306. * @returns The action passed in
  17307. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17308. */
  17309. then(action: Action): Action;
  17310. /**
  17311. * Internal only
  17312. * @hidden
  17313. */
  17314. _getProperty(propertyPath: string): string;
  17315. /**
  17316. * Internal only
  17317. * @hidden
  17318. */
  17319. _getEffectiveTarget(target: any, propertyPath: string): any;
  17320. /**
  17321. * Serialize placeholder for child classes
  17322. * @param parent of child
  17323. * @returns the serialized object
  17324. */
  17325. serialize(parent: any): any;
  17326. /**
  17327. * Internal only called by serialize
  17328. * @hidden
  17329. */
  17330. protected _serialize(serializedAction: any, parent?: any): any;
  17331. /**
  17332. * Internal only
  17333. * @hidden
  17334. */
  17335. static _SerializeValueAsString: (value: any) => string;
  17336. /**
  17337. * Internal only
  17338. * @hidden
  17339. */
  17340. static _GetTargetProperty: (target: Node | Scene) => {
  17341. name: string;
  17342. targetType: string;
  17343. value: string;
  17344. };
  17345. }
  17346. }
  17347. declare module BABYLON {
  17348. /**
  17349. * A Condition applied to an Action
  17350. */
  17351. export class Condition {
  17352. /**
  17353. * Internal only - manager for action
  17354. * @hidden
  17355. */
  17356. _actionManager: ActionManager;
  17357. /**
  17358. * Internal only
  17359. * @hidden
  17360. */
  17361. _evaluationId: number;
  17362. /**
  17363. * Internal only
  17364. * @hidden
  17365. */
  17366. _currentResult: boolean;
  17367. /**
  17368. * Creates a new Condition
  17369. * @param actionManager the manager of the action the condition is applied to
  17370. */
  17371. constructor(actionManager: ActionManager);
  17372. /**
  17373. * Check if the current condition is valid
  17374. * @returns a boolean
  17375. */
  17376. isValid(): boolean;
  17377. /**
  17378. * Internal only
  17379. * @hidden
  17380. */
  17381. _getProperty(propertyPath: string): string;
  17382. /**
  17383. * Internal only
  17384. * @hidden
  17385. */
  17386. _getEffectiveTarget(target: any, propertyPath: string): any;
  17387. /**
  17388. * Serialize placeholder for child classes
  17389. * @returns the serialized object
  17390. */
  17391. serialize(): any;
  17392. /**
  17393. * Internal only
  17394. * @hidden
  17395. */
  17396. protected _serialize(serializedCondition: any): any;
  17397. }
  17398. /**
  17399. * Defines specific conditional operators as extensions of Condition
  17400. */
  17401. export class ValueCondition extends Condition {
  17402. /** path to specify the property of the target the conditional operator uses */
  17403. propertyPath: string;
  17404. /** the value compared by the conditional operator against the current value of the property */
  17405. value: any;
  17406. /** the conditional operator, default ValueCondition.IsEqual */
  17407. operator: number;
  17408. /**
  17409. * Internal only
  17410. * @hidden
  17411. */
  17412. private static _IsEqual;
  17413. /**
  17414. * Internal only
  17415. * @hidden
  17416. */
  17417. private static _IsDifferent;
  17418. /**
  17419. * Internal only
  17420. * @hidden
  17421. */
  17422. private static _IsGreater;
  17423. /**
  17424. * Internal only
  17425. * @hidden
  17426. */
  17427. private static _IsLesser;
  17428. /**
  17429. * returns the number for IsEqual
  17430. */
  17431. static get IsEqual(): number;
  17432. /**
  17433. * Returns the number for IsDifferent
  17434. */
  17435. static get IsDifferent(): number;
  17436. /**
  17437. * Returns the number for IsGreater
  17438. */
  17439. static get IsGreater(): number;
  17440. /**
  17441. * Returns the number for IsLesser
  17442. */
  17443. static get IsLesser(): number;
  17444. /**
  17445. * Internal only The action manager for the condition
  17446. * @hidden
  17447. */
  17448. _actionManager: ActionManager;
  17449. /**
  17450. * Internal only
  17451. * @hidden
  17452. */
  17453. private _target;
  17454. /**
  17455. * Internal only
  17456. * @hidden
  17457. */
  17458. private _effectiveTarget;
  17459. /**
  17460. * Internal only
  17461. * @hidden
  17462. */
  17463. private _property;
  17464. /**
  17465. * Creates a new ValueCondition
  17466. * @param actionManager manager for the action the condition applies to
  17467. * @param target for the action
  17468. * @param propertyPath path to specify the property of the target the conditional operator uses
  17469. * @param value the value compared by the conditional operator against the current value of the property
  17470. * @param operator the conditional operator, default ValueCondition.IsEqual
  17471. */
  17472. constructor(actionManager: ActionManager, target: any,
  17473. /** path to specify the property of the target the conditional operator uses */
  17474. propertyPath: string,
  17475. /** the value compared by the conditional operator against the current value of the property */
  17476. value: any,
  17477. /** the conditional operator, default ValueCondition.IsEqual */
  17478. operator?: number);
  17479. /**
  17480. * Compares the given value with the property value for the specified conditional operator
  17481. * @returns the result of the comparison
  17482. */
  17483. isValid(): boolean;
  17484. /**
  17485. * Serialize the ValueCondition into a JSON compatible object
  17486. * @returns serialization object
  17487. */
  17488. serialize(): any;
  17489. /**
  17490. * Gets the name of the conditional operator for the ValueCondition
  17491. * @param operator the conditional operator
  17492. * @returns the name
  17493. */
  17494. static GetOperatorName(operator: number): string;
  17495. }
  17496. /**
  17497. * Defines a predicate condition as an extension of Condition
  17498. */
  17499. export class PredicateCondition extends Condition {
  17500. /** defines the predicate function used to validate the condition */
  17501. predicate: () => boolean;
  17502. /**
  17503. * Internal only - manager for action
  17504. * @hidden
  17505. */
  17506. _actionManager: ActionManager;
  17507. /**
  17508. * Creates a new PredicateCondition
  17509. * @param actionManager manager for the action the condition applies to
  17510. * @param predicate defines the predicate function used to validate the condition
  17511. */
  17512. constructor(actionManager: ActionManager,
  17513. /** defines the predicate function used to validate the condition */
  17514. predicate: () => boolean);
  17515. /**
  17516. * @returns the validity of the predicate condition
  17517. */
  17518. isValid(): boolean;
  17519. }
  17520. /**
  17521. * Defines a state condition as an extension of Condition
  17522. */
  17523. export class StateCondition extends Condition {
  17524. /** Value to compare with target state */
  17525. value: string;
  17526. /**
  17527. * Internal only - manager for action
  17528. * @hidden
  17529. */
  17530. _actionManager: ActionManager;
  17531. /**
  17532. * Internal only
  17533. * @hidden
  17534. */
  17535. private _target;
  17536. /**
  17537. * Creates a new StateCondition
  17538. * @param actionManager manager for the action the condition applies to
  17539. * @param target of the condition
  17540. * @param value to compare with target state
  17541. */
  17542. constructor(actionManager: ActionManager, target: any,
  17543. /** Value to compare with target state */
  17544. value: string);
  17545. /**
  17546. * Gets a boolean indicating if the current condition is met
  17547. * @returns the validity of the state
  17548. */
  17549. isValid(): boolean;
  17550. /**
  17551. * Serialize the StateCondition into a JSON compatible object
  17552. * @returns serialization object
  17553. */
  17554. serialize(): any;
  17555. }
  17556. }
  17557. declare module BABYLON {
  17558. /**
  17559. * This defines an action responsible to toggle a boolean once triggered.
  17560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17561. */
  17562. export class SwitchBooleanAction extends Action {
  17563. /**
  17564. * The path to the boolean property in the target object
  17565. */
  17566. propertyPath: string;
  17567. private _target;
  17568. private _effectiveTarget;
  17569. private _property;
  17570. /**
  17571. * Instantiate the action
  17572. * @param triggerOptions defines the trigger options
  17573. * @param target defines the object containing the boolean
  17574. * @param propertyPath defines the path to the boolean property in the target object
  17575. * @param condition defines the trigger related conditions
  17576. */
  17577. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17578. /** @hidden */
  17579. _prepare(): void;
  17580. /**
  17581. * Execute the action toggle the boolean value.
  17582. */
  17583. execute(): void;
  17584. /**
  17585. * Serializes the actions and its related information.
  17586. * @param parent defines the object to serialize in
  17587. * @returns the serialized object
  17588. */
  17589. serialize(parent: any): any;
  17590. }
  17591. /**
  17592. * This defines an action responsible to set a the state field of the target
  17593. * to a desired value once triggered.
  17594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17595. */
  17596. export class SetStateAction extends Action {
  17597. /**
  17598. * The value to store in the state field.
  17599. */
  17600. value: string;
  17601. private _target;
  17602. /**
  17603. * Instantiate the action
  17604. * @param triggerOptions defines the trigger options
  17605. * @param target defines the object containing the state property
  17606. * @param value defines the value to store in the state field
  17607. * @param condition defines the trigger related conditions
  17608. */
  17609. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17610. /**
  17611. * Execute the action and store the value on the target state property.
  17612. */
  17613. execute(): void;
  17614. /**
  17615. * Serializes the actions and its related information.
  17616. * @param parent defines the object to serialize in
  17617. * @returns the serialized object
  17618. */
  17619. serialize(parent: any): any;
  17620. }
  17621. /**
  17622. * This defines an action responsible to set a property of the target
  17623. * to a desired value once triggered.
  17624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17625. */
  17626. export class SetValueAction extends Action {
  17627. /**
  17628. * The path of the property to set in the target.
  17629. */
  17630. propertyPath: string;
  17631. /**
  17632. * The value to set in the property
  17633. */
  17634. value: any;
  17635. private _target;
  17636. private _effectiveTarget;
  17637. private _property;
  17638. /**
  17639. * Instantiate the action
  17640. * @param triggerOptions defines the trigger options
  17641. * @param target defines the object containing the property
  17642. * @param propertyPath defines the path of the property to set in the target
  17643. * @param value defines the value to set in the property
  17644. * @param condition defines the trigger related conditions
  17645. */
  17646. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17647. /** @hidden */
  17648. _prepare(): void;
  17649. /**
  17650. * Execute the action and set the targetted property to the desired value.
  17651. */
  17652. execute(): void;
  17653. /**
  17654. * Serializes the actions and its related information.
  17655. * @param parent defines the object to serialize in
  17656. * @returns the serialized object
  17657. */
  17658. serialize(parent: any): any;
  17659. }
  17660. /**
  17661. * This defines an action responsible to increment the target value
  17662. * to a desired value once triggered.
  17663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17664. */
  17665. export class IncrementValueAction extends Action {
  17666. /**
  17667. * The path of the property to increment in the target.
  17668. */
  17669. propertyPath: string;
  17670. /**
  17671. * The value we should increment the property by.
  17672. */
  17673. value: any;
  17674. private _target;
  17675. private _effectiveTarget;
  17676. private _property;
  17677. /**
  17678. * Instantiate the action
  17679. * @param triggerOptions defines the trigger options
  17680. * @param target defines the object containing the property
  17681. * @param propertyPath defines the path of the property to increment in the target
  17682. * @param value defines the value value we should increment the property by
  17683. * @param condition defines the trigger related conditions
  17684. */
  17685. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17686. /** @hidden */
  17687. _prepare(): void;
  17688. /**
  17689. * Execute the action and increment the target of the value amount.
  17690. */
  17691. execute(): void;
  17692. /**
  17693. * Serializes the actions and its related information.
  17694. * @param parent defines the object to serialize in
  17695. * @returns the serialized object
  17696. */
  17697. serialize(parent: any): any;
  17698. }
  17699. /**
  17700. * This defines an action responsible to start an animation once triggered.
  17701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17702. */
  17703. export class PlayAnimationAction extends Action {
  17704. /**
  17705. * Where the animation should start (animation frame)
  17706. */
  17707. from: number;
  17708. /**
  17709. * Where the animation should stop (animation frame)
  17710. */
  17711. to: number;
  17712. /**
  17713. * Define if the animation should loop or stop after the first play.
  17714. */
  17715. loop?: boolean;
  17716. private _target;
  17717. /**
  17718. * Instantiate the action
  17719. * @param triggerOptions defines the trigger options
  17720. * @param target defines the target animation or animation name
  17721. * @param from defines from where the animation should start (animation frame)
  17722. * @param end defines where the animation should stop (animation frame)
  17723. * @param loop defines if the animation should loop or stop after the first play
  17724. * @param condition defines the trigger related conditions
  17725. */
  17726. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17727. /** @hidden */
  17728. _prepare(): void;
  17729. /**
  17730. * Execute the action and play the animation.
  17731. */
  17732. execute(): void;
  17733. /**
  17734. * Serializes the actions and its related information.
  17735. * @param parent defines the object to serialize in
  17736. * @returns the serialized object
  17737. */
  17738. serialize(parent: any): any;
  17739. }
  17740. /**
  17741. * This defines an action responsible to stop an animation once triggered.
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17743. */
  17744. export class StopAnimationAction extends Action {
  17745. private _target;
  17746. /**
  17747. * Instantiate the action
  17748. * @param triggerOptions defines the trigger options
  17749. * @param target defines the target animation or animation name
  17750. * @param condition defines the trigger related conditions
  17751. */
  17752. constructor(triggerOptions: any, target: any, condition?: Condition);
  17753. /** @hidden */
  17754. _prepare(): void;
  17755. /**
  17756. * Execute the action and stop the animation.
  17757. */
  17758. execute(): void;
  17759. /**
  17760. * Serializes the actions and its related information.
  17761. * @param parent defines the object to serialize in
  17762. * @returns the serialized object
  17763. */
  17764. serialize(parent: any): any;
  17765. }
  17766. /**
  17767. * This defines an action responsible that does nothing once triggered.
  17768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17769. */
  17770. export class DoNothingAction extends Action {
  17771. /**
  17772. * Instantiate the action
  17773. * @param triggerOptions defines the trigger options
  17774. * @param condition defines the trigger related conditions
  17775. */
  17776. constructor(triggerOptions?: any, condition?: Condition);
  17777. /**
  17778. * Execute the action and do nothing.
  17779. */
  17780. execute(): void;
  17781. /**
  17782. * Serializes the actions and its related information.
  17783. * @param parent defines the object to serialize in
  17784. * @returns the serialized object
  17785. */
  17786. serialize(parent: any): any;
  17787. }
  17788. /**
  17789. * This defines an action responsible to trigger several actions once triggered.
  17790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17791. */
  17792. export class CombineAction extends Action {
  17793. /**
  17794. * The list of aggregated animations to run.
  17795. */
  17796. children: Action[];
  17797. /**
  17798. * Instantiate the action
  17799. * @param triggerOptions defines the trigger options
  17800. * @param children defines the list of aggregated animations to run
  17801. * @param condition defines the trigger related conditions
  17802. */
  17803. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17804. /** @hidden */
  17805. _prepare(): void;
  17806. /**
  17807. * Execute the action and executes all the aggregated actions.
  17808. */
  17809. execute(evt: ActionEvent): void;
  17810. /**
  17811. * Serializes the actions and its related information.
  17812. * @param parent defines the object to serialize in
  17813. * @returns the serialized object
  17814. */
  17815. serialize(parent: any): any;
  17816. }
  17817. /**
  17818. * This defines an action responsible to run code (external event) once triggered.
  17819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17820. */
  17821. export class ExecuteCodeAction extends Action {
  17822. /**
  17823. * The callback function to run.
  17824. */
  17825. func: (evt: ActionEvent) => void;
  17826. /**
  17827. * Instantiate the action
  17828. * @param triggerOptions defines the trigger options
  17829. * @param func defines the callback function to run
  17830. * @param condition defines the trigger related conditions
  17831. */
  17832. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17833. /**
  17834. * Execute the action and run the attached code.
  17835. */
  17836. execute(evt: ActionEvent): void;
  17837. }
  17838. /**
  17839. * This defines an action responsible to set the parent property of the target once triggered.
  17840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17841. */
  17842. export class SetParentAction extends Action {
  17843. private _parent;
  17844. private _target;
  17845. /**
  17846. * Instantiate the action
  17847. * @param triggerOptions defines the trigger options
  17848. * @param target defines the target containing the parent property
  17849. * @param parent defines from where the animation should start (animation frame)
  17850. * @param condition defines the trigger related conditions
  17851. */
  17852. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17853. /** @hidden */
  17854. _prepare(): void;
  17855. /**
  17856. * Execute the action and set the parent property.
  17857. */
  17858. execute(): void;
  17859. /**
  17860. * Serializes the actions and its related information.
  17861. * @param parent defines the object to serialize in
  17862. * @returns the serialized object
  17863. */
  17864. serialize(parent: any): any;
  17865. }
  17866. }
  17867. declare module BABYLON {
  17868. /**
  17869. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17870. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17872. */
  17873. export class ActionManager extends AbstractActionManager {
  17874. /**
  17875. * Nothing
  17876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17877. */
  17878. static readonly NothingTrigger: number;
  17879. /**
  17880. * On pick
  17881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17882. */
  17883. static readonly OnPickTrigger: number;
  17884. /**
  17885. * On left pick
  17886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17887. */
  17888. static readonly OnLeftPickTrigger: number;
  17889. /**
  17890. * On right pick
  17891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17892. */
  17893. static readonly OnRightPickTrigger: number;
  17894. /**
  17895. * On center pick
  17896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17897. */
  17898. static readonly OnCenterPickTrigger: number;
  17899. /**
  17900. * On pick down
  17901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17902. */
  17903. static readonly OnPickDownTrigger: number;
  17904. /**
  17905. * On double pick
  17906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17907. */
  17908. static readonly OnDoublePickTrigger: number;
  17909. /**
  17910. * On pick up
  17911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17912. */
  17913. static readonly OnPickUpTrigger: number;
  17914. /**
  17915. * On pick out.
  17916. * This trigger will only be raised if you also declared a OnPickDown
  17917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17918. */
  17919. static readonly OnPickOutTrigger: number;
  17920. /**
  17921. * On long press
  17922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17923. */
  17924. static readonly OnLongPressTrigger: number;
  17925. /**
  17926. * On pointer over
  17927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17928. */
  17929. static readonly OnPointerOverTrigger: number;
  17930. /**
  17931. * On pointer out
  17932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17933. */
  17934. static readonly OnPointerOutTrigger: number;
  17935. /**
  17936. * On every frame
  17937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17938. */
  17939. static readonly OnEveryFrameTrigger: number;
  17940. /**
  17941. * On intersection enter
  17942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17943. */
  17944. static readonly OnIntersectionEnterTrigger: number;
  17945. /**
  17946. * On intersection exit
  17947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17948. */
  17949. static readonly OnIntersectionExitTrigger: number;
  17950. /**
  17951. * On key down
  17952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17953. */
  17954. static readonly OnKeyDownTrigger: number;
  17955. /**
  17956. * On key up
  17957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17958. */
  17959. static readonly OnKeyUpTrigger: number;
  17960. private _scene;
  17961. /**
  17962. * Creates a new action manager
  17963. * @param scene defines the hosting scene
  17964. */
  17965. constructor(scene: Scene);
  17966. /**
  17967. * Releases all associated resources
  17968. */
  17969. dispose(): void;
  17970. /**
  17971. * Gets hosting scene
  17972. * @returns the hosting scene
  17973. */
  17974. getScene(): Scene;
  17975. /**
  17976. * Does this action manager handles actions of any of the given triggers
  17977. * @param triggers defines the triggers to be tested
  17978. * @return a boolean indicating whether one (or more) of the triggers is handled
  17979. */
  17980. hasSpecificTriggers(triggers: number[]): boolean;
  17981. /**
  17982. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17983. * speed.
  17984. * @param triggerA defines the trigger to be tested
  17985. * @param triggerB defines the trigger to be tested
  17986. * @return a boolean indicating whether one (or more) of the triggers is handled
  17987. */
  17988. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17989. /**
  17990. * Does this action manager handles actions of a given trigger
  17991. * @param trigger defines the trigger to be tested
  17992. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17993. * @return whether the trigger is handled
  17994. */
  17995. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17996. /**
  17997. * Does this action manager has pointer triggers
  17998. */
  17999. get hasPointerTriggers(): boolean;
  18000. /**
  18001. * Does this action manager has pick triggers
  18002. */
  18003. get hasPickTriggers(): boolean;
  18004. /**
  18005. * Registers an action to this action manager
  18006. * @param action defines the action to be registered
  18007. * @return the action amended (prepared) after registration
  18008. */
  18009. registerAction(action: IAction): Nullable<IAction>;
  18010. /**
  18011. * Unregisters an action to this action manager
  18012. * @param action defines the action to be unregistered
  18013. * @return a boolean indicating whether the action has been unregistered
  18014. */
  18015. unregisterAction(action: IAction): Boolean;
  18016. /**
  18017. * Process a specific trigger
  18018. * @param trigger defines the trigger to process
  18019. * @param evt defines the event details to be processed
  18020. */
  18021. processTrigger(trigger: number, evt?: IActionEvent): void;
  18022. /** @hidden */
  18023. _getEffectiveTarget(target: any, propertyPath: string): any;
  18024. /** @hidden */
  18025. _getProperty(propertyPath: string): string;
  18026. /**
  18027. * Serialize this manager to a JSON object
  18028. * @param name defines the property name to store this manager
  18029. * @returns a JSON representation of this manager
  18030. */
  18031. serialize(name: string): any;
  18032. /**
  18033. * Creates a new ActionManager from a JSON data
  18034. * @param parsedActions defines the JSON data to read from
  18035. * @param object defines the hosting mesh
  18036. * @param scene defines the hosting scene
  18037. */
  18038. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18039. /**
  18040. * Get a trigger name by index
  18041. * @param trigger defines the trigger index
  18042. * @returns a trigger name
  18043. */
  18044. static GetTriggerName(trigger: number): string;
  18045. }
  18046. }
  18047. declare module BABYLON {
  18048. /**
  18049. * Class used to represent a sprite
  18050. * @see http://doc.babylonjs.com/babylon101/sprites
  18051. */
  18052. export class Sprite {
  18053. /** defines the name */
  18054. name: string;
  18055. /** Gets or sets the current world position */
  18056. position: Vector3;
  18057. /** Gets or sets the main color */
  18058. color: Color4;
  18059. /** Gets or sets the width */
  18060. width: number;
  18061. /** Gets or sets the height */
  18062. height: number;
  18063. /** Gets or sets rotation angle */
  18064. angle: number;
  18065. /** Gets or sets the cell index in the sprite sheet */
  18066. cellIndex: number;
  18067. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18068. cellRef: string;
  18069. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18070. invertU: number;
  18071. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18072. invertV: number;
  18073. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18074. disposeWhenFinishedAnimating: boolean;
  18075. /** Gets the list of attached animations */
  18076. animations: Animation[];
  18077. /** Gets or sets a boolean indicating if the sprite can be picked */
  18078. isPickable: boolean;
  18079. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18080. useAlphaForPicking: boolean;
  18081. /** @hidden */
  18082. _xOffset: number;
  18083. /** @hidden */
  18084. _yOffset: number;
  18085. /** @hidden */
  18086. _xSize: number;
  18087. /** @hidden */
  18088. _ySize: number;
  18089. /**
  18090. * Gets or sets the associated action manager
  18091. */
  18092. actionManager: Nullable<ActionManager>;
  18093. private _animationStarted;
  18094. private _loopAnimation;
  18095. private _fromIndex;
  18096. private _toIndex;
  18097. private _delay;
  18098. private _direction;
  18099. private _manager;
  18100. private _time;
  18101. private _onAnimationEnd;
  18102. /**
  18103. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18104. */
  18105. isVisible: boolean;
  18106. /**
  18107. * Gets or sets the sprite size
  18108. */
  18109. get size(): number;
  18110. set size(value: number);
  18111. /**
  18112. * Creates a new Sprite
  18113. * @param name defines the name
  18114. * @param manager defines the manager
  18115. */
  18116. constructor(
  18117. /** defines the name */
  18118. name: string, manager: ISpriteManager);
  18119. /**
  18120. * Starts an animation
  18121. * @param from defines the initial key
  18122. * @param to defines the end key
  18123. * @param loop defines if the animation must loop
  18124. * @param delay defines the start delay (in ms)
  18125. * @param onAnimationEnd defines a callback to call when animation ends
  18126. */
  18127. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18128. /** Stops current animation (if any) */
  18129. stopAnimation(): void;
  18130. /** @hidden */
  18131. _animate(deltaTime: number): void;
  18132. /** Release associated resources */
  18133. dispose(): void;
  18134. }
  18135. }
  18136. declare module BABYLON {
  18137. /**
  18138. * Information about the result of picking within a scene
  18139. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18140. */
  18141. export class PickingInfo {
  18142. /** @hidden */
  18143. _pickingUnavailable: boolean;
  18144. /**
  18145. * If the pick collided with an object
  18146. */
  18147. hit: boolean;
  18148. /**
  18149. * Distance away where the pick collided
  18150. */
  18151. distance: number;
  18152. /**
  18153. * The location of pick collision
  18154. */
  18155. pickedPoint: Nullable<Vector3>;
  18156. /**
  18157. * The mesh corresponding the the pick collision
  18158. */
  18159. pickedMesh: Nullable<AbstractMesh>;
  18160. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18161. bu: number;
  18162. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18163. bv: number;
  18164. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18165. faceId: number;
  18166. /** Id of the the submesh that was picked */
  18167. subMeshId: number;
  18168. /** If a sprite was picked, this will be the sprite the pick collided with */
  18169. pickedSprite: Nullable<Sprite>;
  18170. /**
  18171. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18172. */
  18173. originMesh: Nullable<AbstractMesh>;
  18174. /**
  18175. * The ray that was used to perform the picking.
  18176. */
  18177. ray: Nullable<Ray>;
  18178. /**
  18179. * Gets the normal correspodning to the face the pick collided with
  18180. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18181. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18182. * @returns The normal correspodning to the face the pick collided with
  18183. */
  18184. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18185. /**
  18186. * Gets the texture coordinates of where the pick occured
  18187. * @returns the vector containing the coordnates of the texture
  18188. */
  18189. getTextureCoordinates(): Nullable<Vector2>;
  18190. }
  18191. }
  18192. declare module BABYLON {
  18193. /**
  18194. * Gather the list of pointer event types as constants.
  18195. */
  18196. export class PointerEventTypes {
  18197. /**
  18198. * 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.
  18199. */
  18200. static readonly POINTERDOWN: number;
  18201. /**
  18202. * The pointerup event is fired when a pointer is no longer active.
  18203. */
  18204. static readonly POINTERUP: number;
  18205. /**
  18206. * The pointermove event is fired when a pointer changes coordinates.
  18207. */
  18208. static readonly POINTERMOVE: number;
  18209. /**
  18210. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18211. */
  18212. static readonly POINTERWHEEL: number;
  18213. /**
  18214. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18215. */
  18216. static readonly POINTERPICK: number;
  18217. /**
  18218. * The pointertap event is fired when a the object has been touched and released without drag.
  18219. */
  18220. static readonly POINTERTAP: number;
  18221. /**
  18222. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18223. */
  18224. static readonly POINTERDOUBLETAP: number;
  18225. }
  18226. /**
  18227. * Base class of pointer info types.
  18228. */
  18229. export class PointerInfoBase {
  18230. /**
  18231. * Defines the type of event (PointerEventTypes)
  18232. */
  18233. type: number;
  18234. /**
  18235. * Defines the related dom event
  18236. */
  18237. event: PointerEvent | MouseWheelEvent;
  18238. /**
  18239. * Instantiates the base class of pointers info.
  18240. * @param type Defines the type of event (PointerEventTypes)
  18241. * @param event Defines the related dom event
  18242. */
  18243. constructor(
  18244. /**
  18245. * Defines the type of event (PointerEventTypes)
  18246. */
  18247. type: number,
  18248. /**
  18249. * Defines the related dom event
  18250. */
  18251. event: PointerEvent | MouseWheelEvent);
  18252. }
  18253. /**
  18254. * This class is used to store pointer related info for the onPrePointerObservable event.
  18255. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18256. */
  18257. export class PointerInfoPre extends PointerInfoBase {
  18258. /**
  18259. * Ray from a pointer if availible (eg. 6dof controller)
  18260. */
  18261. ray: Nullable<Ray>;
  18262. /**
  18263. * Defines the local position of the pointer on the canvas.
  18264. */
  18265. localPosition: Vector2;
  18266. /**
  18267. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18268. */
  18269. skipOnPointerObservable: boolean;
  18270. /**
  18271. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18272. * @param type Defines the type of event (PointerEventTypes)
  18273. * @param event Defines the related dom event
  18274. * @param localX Defines the local x coordinates of the pointer when the event occured
  18275. * @param localY Defines the local y coordinates of the pointer when the event occured
  18276. */
  18277. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18278. }
  18279. /**
  18280. * This type contains all the data related to a pointer event in Babylon.js.
  18281. * 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.
  18282. */
  18283. export class PointerInfo extends PointerInfoBase {
  18284. /**
  18285. * Defines the picking info associated to the info (if any)\
  18286. */
  18287. pickInfo: Nullable<PickingInfo>;
  18288. /**
  18289. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18290. * @param type Defines the type of event (PointerEventTypes)
  18291. * @param event Defines the related dom event
  18292. * @param pickInfo Defines the picking info associated to the info (if any)\
  18293. */
  18294. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18295. /**
  18296. * Defines the picking info associated to the info (if any)\
  18297. */
  18298. pickInfo: Nullable<PickingInfo>);
  18299. }
  18300. /**
  18301. * Data relating to a touch event on the screen.
  18302. */
  18303. export interface PointerTouch {
  18304. /**
  18305. * X coordinate of touch.
  18306. */
  18307. x: number;
  18308. /**
  18309. * Y coordinate of touch.
  18310. */
  18311. y: number;
  18312. /**
  18313. * Id of touch. Unique for each finger.
  18314. */
  18315. pointerId: number;
  18316. /**
  18317. * Event type passed from DOM.
  18318. */
  18319. type: any;
  18320. }
  18321. }
  18322. declare module BABYLON {
  18323. /**
  18324. * Manage the mouse inputs to control the movement of a free camera.
  18325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18326. */
  18327. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18328. /**
  18329. * Define if touch is enabled in the mouse input
  18330. */
  18331. touchEnabled: boolean;
  18332. /**
  18333. * Defines the camera the input is attached to.
  18334. */
  18335. camera: FreeCamera;
  18336. /**
  18337. * Defines the buttons associated with the input to handle camera move.
  18338. */
  18339. buttons: number[];
  18340. /**
  18341. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18342. */
  18343. angularSensibility: number;
  18344. private _pointerInput;
  18345. private _onMouseMove;
  18346. private _observer;
  18347. private previousPosition;
  18348. /**
  18349. * Observable for when a pointer move event occurs containing the move offset
  18350. */
  18351. onPointerMovedObservable: Observable<{
  18352. offsetX: number;
  18353. offsetY: number;
  18354. }>;
  18355. /**
  18356. * @hidden
  18357. * If the camera should be rotated automatically based on pointer movement
  18358. */
  18359. _allowCameraRotation: boolean;
  18360. /**
  18361. * Manage the mouse inputs to control the movement of a free camera.
  18362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18363. * @param touchEnabled Defines if touch is enabled or not
  18364. */
  18365. constructor(
  18366. /**
  18367. * Define if touch is enabled in the mouse input
  18368. */
  18369. touchEnabled?: boolean);
  18370. /**
  18371. * Attach the input controls to a specific dom element to get the input from.
  18372. * @param element Defines the element the controls should be listened from
  18373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18374. */
  18375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18376. /**
  18377. * Called on JS contextmenu event.
  18378. * Override this method to provide functionality.
  18379. */
  18380. protected onContextMenu(evt: PointerEvent): void;
  18381. /**
  18382. * Detach the current controls from the specified dom element.
  18383. * @param element Defines the element to stop listening the inputs from
  18384. */
  18385. detachControl(element: Nullable<HTMLElement>): void;
  18386. /**
  18387. * Gets the class name of the current intput.
  18388. * @returns the class name
  18389. */
  18390. getClassName(): string;
  18391. /**
  18392. * Get the friendly name associated with the input class.
  18393. * @returns the input friendly name
  18394. */
  18395. getSimpleName(): string;
  18396. }
  18397. }
  18398. declare module BABYLON {
  18399. /**
  18400. * Manage the touch inputs to control the movement of a free camera.
  18401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18402. */
  18403. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18404. /**
  18405. * Defines the camera the input is attached to.
  18406. */
  18407. camera: FreeCamera;
  18408. /**
  18409. * Defines the touch sensibility for rotation.
  18410. * The higher the faster.
  18411. */
  18412. touchAngularSensibility: number;
  18413. /**
  18414. * Defines the touch sensibility for move.
  18415. * The higher the faster.
  18416. */
  18417. touchMoveSensibility: number;
  18418. private _offsetX;
  18419. private _offsetY;
  18420. private _pointerPressed;
  18421. private _pointerInput;
  18422. private _observer;
  18423. private _onLostFocus;
  18424. /**
  18425. * Attach the input controls to a specific dom element to get the input from.
  18426. * @param element Defines the element the controls should be listened from
  18427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18428. */
  18429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18430. /**
  18431. * Detach the current controls from the specified dom element.
  18432. * @param element Defines the element to stop listening the inputs from
  18433. */
  18434. detachControl(element: Nullable<HTMLElement>): void;
  18435. /**
  18436. * Update the current camera state depending on the inputs that have been used this frame.
  18437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18438. */
  18439. checkInputs(): void;
  18440. /**
  18441. * Gets the class name of the current intput.
  18442. * @returns the class name
  18443. */
  18444. getClassName(): string;
  18445. /**
  18446. * Get the friendly name associated with the input class.
  18447. * @returns the input friendly name
  18448. */
  18449. getSimpleName(): string;
  18450. }
  18451. }
  18452. declare module BABYLON {
  18453. /**
  18454. * Default Inputs manager for the FreeCamera.
  18455. * It groups all the default supported inputs for ease of use.
  18456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18457. */
  18458. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18459. /**
  18460. * @hidden
  18461. */
  18462. _mouseInput: Nullable<FreeCameraMouseInput>;
  18463. /**
  18464. * Instantiates a new FreeCameraInputsManager.
  18465. * @param camera Defines the camera the inputs belong to
  18466. */
  18467. constructor(camera: FreeCamera);
  18468. /**
  18469. * Add keyboard input support to the input manager.
  18470. * @returns the current input manager
  18471. */
  18472. addKeyboard(): FreeCameraInputsManager;
  18473. /**
  18474. * Add mouse input support to the input manager.
  18475. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18476. * @returns the current input manager
  18477. */
  18478. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18479. /**
  18480. * Removes the mouse input support from the manager
  18481. * @returns the current input manager
  18482. */
  18483. removeMouse(): FreeCameraInputsManager;
  18484. /**
  18485. * Add touch input support to the input manager.
  18486. * @returns the current input manager
  18487. */
  18488. addTouch(): FreeCameraInputsManager;
  18489. /**
  18490. * Remove all attached input methods from a camera
  18491. */
  18492. clear(): void;
  18493. }
  18494. }
  18495. declare module BABYLON {
  18496. /**
  18497. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18498. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18499. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18500. */
  18501. export class FreeCamera extends TargetCamera {
  18502. /**
  18503. * Define the collision ellipsoid of the camera.
  18504. * This is helpful to simulate a camera body like the player body around the camera
  18505. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18506. */
  18507. ellipsoid: Vector3;
  18508. /**
  18509. * Define an offset for the position of the ellipsoid around the camera.
  18510. * This can be helpful to determine the center of the body near the gravity center of the body
  18511. * instead of its head.
  18512. */
  18513. ellipsoidOffset: Vector3;
  18514. /**
  18515. * Enable or disable collisions of the camera with the rest of the scene objects.
  18516. */
  18517. checkCollisions: boolean;
  18518. /**
  18519. * Enable or disable gravity on the camera.
  18520. */
  18521. applyGravity: boolean;
  18522. /**
  18523. * Define the input manager associated to the camera.
  18524. */
  18525. inputs: FreeCameraInputsManager;
  18526. /**
  18527. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18528. * Higher values reduce sensitivity.
  18529. */
  18530. get angularSensibility(): number;
  18531. /**
  18532. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18533. * Higher values reduce sensitivity.
  18534. */
  18535. set angularSensibility(value: number);
  18536. /**
  18537. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18538. */
  18539. get keysUp(): number[];
  18540. set keysUp(value: number[]);
  18541. /**
  18542. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18543. */
  18544. get keysUpward(): number[];
  18545. set keysUpward(value: number[]);
  18546. /**
  18547. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18548. */
  18549. get keysDown(): number[];
  18550. set keysDown(value: number[]);
  18551. /**
  18552. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18553. */
  18554. get keysDownward(): number[];
  18555. set keysDownward(value: number[]);
  18556. /**
  18557. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18558. */
  18559. get keysLeft(): number[];
  18560. set keysLeft(value: number[]);
  18561. /**
  18562. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18563. */
  18564. get keysRight(): number[];
  18565. set keysRight(value: number[]);
  18566. /**
  18567. * Event raised when the camera collide with a mesh in the scene.
  18568. */
  18569. onCollide: (collidedMesh: AbstractMesh) => void;
  18570. private _collider;
  18571. private _needMoveForGravity;
  18572. private _oldPosition;
  18573. private _diffPosition;
  18574. private _newPosition;
  18575. /** @hidden */
  18576. _localDirection: Vector3;
  18577. /** @hidden */
  18578. _transformedDirection: Vector3;
  18579. /**
  18580. * Instantiates a Free Camera.
  18581. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18582. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18583. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18584. * @param name Define the name of the camera in the scene
  18585. * @param position Define the start position of the camera in the scene
  18586. * @param scene Define the scene the camera belongs to
  18587. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18588. */
  18589. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18590. /**
  18591. * Attached controls to the current camera.
  18592. * @param element Defines the element the controls should be listened from
  18593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18594. */
  18595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18596. /**
  18597. * Detach the current controls from the camera.
  18598. * The camera will stop reacting to inputs.
  18599. * @param element Defines the element to stop listening the inputs from
  18600. */
  18601. detachControl(element: HTMLElement): void;
  18602. private _collisionMask;
  18603. /**
  18604. * Define a collision mask to limit the list of object the camera can collide with
  18605. */
  18606. get collisionMask(): number;
  18607. set collisionMask(mask: number);
  18608. /** @hidden */
  18609. _collideWithWorld(displacement: Vector3): void;
  18610. private _onCollisionPositionChange;
  18611. /** @hidden */
  18612. _checkInputs(): void;
  18613. /** @hidden */
  18614. _decideIfNeedsToMove(): boolean;
  18615. /** @hidden */
  18616. _updatePosition(): void;
  18617. /**
  18618. * Destroy the camera and release the current resources hold by it.
  18619. */
  18620. dispose(): void;
  18621. /**
  18622. * Gets the current object class name.
  18623. * @return the class name
  18624. */
  18625. getClassName(): string;
  18626. }
  18627. }
  18628. declare module BABYLON {
  18629. /**
  18630. * Represents a gamepad control stick position
  18631. */
  18632. export class StickValues {
  18633. /**
  18634. * The x component of the control stick
  18635. */
  18636. x: number;
  18637. /**
  18638. * The y component of the control stick
  18639. */
  18640. y: number;
  18641. /**
  18642. * Initializes the gamepad x and y control stick values
  18643. * @param x The x component of the gamepad control stick value
  18644. * @param y The y component of the gamepad control stick value
  18645. */
  18646. constructor(
  18647. /**
  18648. * The x component of the control stick
  18649. */
  18650. x: number,
  18651. /**
  18652. * The y component of the control stick
  18653. */
  18654. y: number);
  18655. }
  18656. /**
  18657. * An interface which manages callbacks for gamepad button changes
  18658. */
  18659. export interface GamepadButtonChanges {
  18660. /**
  18661. * Called when a gamepad has been changed
  18662. */
  18663. changed: boolean;
  18664. /**
  18665. * Called when a gamepad press event has been triggered
  18666. */
  18667. pressChanged: boolean;
  18668. /**
  18669. * Called when a touch event has been triggered
  18670. */
  18671. touchChanged: boolean;
  18672. /**
  18673. * Called when a value has changed
  18674. */
  18675. valueChanged: boolean;
  18676. }
  18677. /**
  18678. * Represents a gamepad
  18679. */
  18680. export class Gamepad {
  18681. /**
  18682. * The id of the gamepad
  18683. */
  18684. id: string;
  18685. /**
  18686. * The index of the gamepad
  18687. */
  18688. index: number;
  18689. /**
  18690. * The browser gamepad
  18691. */
  18692. browserGamepad: any;
  18693. /**
  18694. * Specifies what type of gamepad this represents
  18695. */
  18696. type: number;
  18697. private _leftStick;
  18698. private _rightStick;
  18699. /** @hidden */
  18700. _isConnected: boolean;
  18701. private _leftStickAxisX;
  18702. private _leftStickAxisY;
  18703. private _rightStickAxisX;
  18704. private _rightStickAxisY;
  18705. /**
  18706. * Triggered when the left control stick has been changed
  18707. */
  18708. private _onleftstickchanged;
  18709. /**
  18710. * Triggered when the right control stick has been changed
  18711. */
  18712. private _onrightstickchanged;
  18713. /**
  18714. * Represents a gamepad controller
  18715. */
  18716. static GAMEPAD: number;
  18717. /**
  18718. * Represents a generic controller
  18719. */
  18720. static GENERIC: number;
  18721. /**
  18722. * Represents an XBox controller
  18723. */
  18724. static XBOX: number;
  18725. /**
  18726. * Represents a pose-enabled controller
  18727. */
  18728. static POSE_ENABLED: number;
  18729. /**
  18730. * Represents an Dual Shock controller
  18731. */
  18732. static DUALSHOCK: number;
  18733. /**
  18734. * Specifies whether the left control stick should be Y-inverted
  18735. */
  18736. protected _invertLeftStickY: boolean;
  18737. /**
  18738. * Specifies if the gamepad has been connected
  18739. */
  18740. get isConnected(): boolean;
  18741. /**
  18742. * Initializes the gamepad
  18743. * @param id The id of the gamepad
  18744. * @param index The index of the gamepad
  18745. * @param browserGamepad The browser gamepad
  18746. * @param leftStickX The x component of the left joystick
  18747. * @param leftStickY The y component of the left joystick
  18748. * @param rightStickX The x component of the right joystick
  18749. * @param rightStickY The y component of the right joystick
  18750. */
  18751. constructor(
  18752. /**
  18753. * The id of the gamepad
  18754. */
  18755. id: string,
  18756. /**
  18757. * The index of the gamepad
  18758. */
  18759. index: number,
  18760. /**
  18761. * The browser gamepad
  18762. */
  18763. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18764. /**
  18765. * Callback triggered when the left joystick has changed
  18766. * @param callback
  18767. */
  18768. onleftstickchanged(callback: (values: StickValues) => void): void;
  18769. /**
  18770. * Callback triggered when the right joystick has changed
  18771. * @param callback
  18772. */
  18773. onrightstickchanged(callback: (values: StickValues) => void): void;
  18774. /**
  18775. * Gets the left joystick
  18776. */
  18777. get leftStick(): StickValues;
  18778. /**
  18779. * Sets the left joystick values
  18780. */
  18781. set leftStick(newValues: StickValues);
  18782. /**
  18783. * Gets the right joystick
  18784. */
  18785. get rightStick(): StickValues;
  18786. /**
  18787. * Sets the right joystick value
  18788. */
  18789. set rightStick(newValues: StickValues);
  18790. /**
  18791. * Updates the gamepad joystick positions
  18792. */
  18793. update(): void;
  18794. /**
  18795. * Disposes the gamepad
  18796. */
  18797. dispose(): void;
  18798. }
  18799. /**
  18800. * Represents a generic gamepad
  18801. */
  18802. export class GenericPad extends Gamepad {
  18803. private _buttons;
  18804. private _onbuttondown;
  18805. private _onbuttonup;
  18806. /**
  18807. * Observable triggered when a button has been pressed
  18808. */
  18809. onButtonDownObservable: Observable<number>;
  18810. /**
  18811. * Observable triggered when a button has been released
  18812. */
  18813. onButtonUpObservable: Observable<number>;
  18814. /**
  18815. * Callback triggered when a button has been pressed
  18816. * @param callback Called when a button has been pressed
  18817. */
  18818. onbuttondown(callback: (buttonPressed: number) => void): void;
  18819. /**
  18820. * Callback triggered when a button has been released
  18821. * @param callback Called when a button has been released
  18822. */
  18823. onbuttonup(callback: (buttonReleased: number) => void): void;
  18824. /**
  18825. * Initializes the generic gamepad
  18826. * @param id The id of the generic gamepad
  18827. * @param index The index of the generic gamepad
  18828. * @param browserGamepad The browser gamepad
  18829. */
  18830. constructor(id: string, index: number, browserGamepad: any);
  18831. private _setButtonValue;
  18832. /**
  18833. * Updates the generic gamepad
  18834. */
  18835. update(): void;
  18836. /**
  18837. * Disposes the generic gamepad
  18838. */
  18839. dispose(): void;
  18840. }
  18841. }
  18842. declare module BABYLON {
  18843. /**
  18844. * Defines the types of pose enabled controllers that are supported
  18845. */
  18846. export enum PoseEnabledControllerType {
  18847. /**
  18848. * HTC Vive
  18849. */
  18850. VIVE = 0,
  18851. /**
  18852. * Oculus Rift
  18853. */
  18854. OCULUS = 1,
  18855. /**
  18856. * Windows mixed reality
  18857. */
  18858. WINDOWS = 2,
  18859. /**
  18860. * Samsung gear VR
  18861. */
  18862. GEAR_VR = 3,
  18863. /**
  18864. * Google Daydream
  18865. */
  18866. DAYDREAM = 4,
  18867. /**
  18868. * Generic
  18869. */
  18870. GENERIC = 5
  18871. }
  18872. /**
  18873. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18874. */
  18875. export interface MutableGamepadButton {
  18876. /**
  18877. * Value of the button/trigger
  18878. */
  18879. value: number;
  18880. /**
  18881. * If the button/trigger is currently touched
  18882. */
  18883. touched: boolean;
  18884. /**
  18885. * If the button/trigger is currently pressed
  18886. */
  18887. pressed: boolean;
  18888. }
  18889. /**
  18890. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18891. * @hidden
  18892. */
  18893. export interface ExtendedGamepadButton extends GamepadButton {
  18894. /**
  18895. * If the button/trigger is currently pressed
  18896. */
  18897. readonly pressed: boolean;
  18898. /**
  18899. * If the button/trigger is currently touched
  18900. */
  18901. readonly touched: boolean;
  18902. /**
  18903. * Value of the button/trigger
  18904. */
  18905. readonly value: number;
  18906. }
  18907. /** @hidden */
  18908. export interface _GamePadFactory {
  18909. /**
  18910. * Returns whether or not the current gamepad can be created for this type of controller.
  18911. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18912. * @returns true if it can be created, otherwise false
  18913. */
  18914. canCreate(gamepadInfo: any): boolean;
  18915. /**
  18916. * Creates a new instance of the Gamepad.
  18917. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18918. * @returns the new gamepad instance
  18919. */
  18920. create(gamepadInfo: any): Gamepad;
  18921. }
  18922. /**
  18923. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18924. */
  18925. export class PoseEnabledControllerHelper {
  18926. /** @hidden */
  18927. static _ControllerFactories: _GamePadFactory[];
  18928. /** @hidden */
  18929. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18930. /**
  18931. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18932. * @param vrGamepad the gamepad to initialized
  18933. * @returns a vr controller of the type the gamepad identified as
  18934. */
  18935. static InitiateController(vrGamepad: any): Gamepad;
  18936. }
  18937. /**
  18938. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18939. */
  18940. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18941. /**
  18942. * If the controller is used in a webXR session
  18943. */
  18944. isXR: boolean;
  18945. private _deviceRoomPosition;
  18946. private _deviceRoomRotationQuaternion;
  18947. /**
  18948. * The device position in babylon space
  18949. */
  18950. devicePosition: Vector3;
  18951. /**
  18952. * The device rotation in babylon space
  18953. */
  18954. deviceRotationQuaternion: Quaternion;
  18955. /**
  18956. * The scale factor of the device in babylon space
  18957. */
  18958. deviceScaleFactor: number;
  18959. /**
  18960. * (Likely devicePosition should be used instead) The device position in its room space
  18961. */
  18962. position: Vector3;
  18963. /**
  18964. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18965. */
  18966. rotationQuaternion: Quaternion;
  18967. /**
  18968. * The type of controller (Eg. Windows mixed reality)
  18969. */
  18970. controllerType: PoseEnabledControllerType;
  18971. protected _calculatedPosition: Vector3;
  18972. private _calculatedRotation;
  18973. /**
  18974. * The raw pose from the device
  18975. */
  18976. rawPose: DevicePose;
  18977. private _trackPosition;
  18978. private _maxRotationDistFromHeadset;
  18979. private _draggedRoomRotation;
  18980. /**
  18981. * @hidden
  18982. */
  18983. _disableTrackPosition(fixedPosition: Vector3): void;
  18984. /**
  18985. * Internal, the mesh attached to the controller
  18986. * @hidden
  18987. */
  18988. _mesh: Nullable<AbstractMesh>;
  18989. private _poseControlledCamera;
  18990. private _leftHandSystemQuaternion;
  18991. /**
  18992. * Internal, matrix used to convert room space to babylon space
  18993. * @hidden
  18994. */
  18995. _deviceToWorld: Matrix;
  18996. /**
  18997. * Node to be used when casting a ray from the controller
  18998. * @hidden
  18999. */
  19000. _pointingPoseNode: Nullable<TransformNode>;
  19001. /**
  19002. * Name of the child mesh that can be used to cast a ray from the controller
  19003. */
  19004. static readonly POINTING_POSE: string;
  19005. /**
  19006. * Creates a new PoseEnabledController from a gamepad
  19007. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19008. */
  19009. constructor(browserGamepad: any);
  19010. private _workingMatrix;
  19011. /**
  19012. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19013. */
  19014. update(): void;
  19015. /**
  19016. * Updates only the pose device and mesh without doing any button event checking
  19017. */
  19018. protected _updatePoseAndMesh(): void;
  19019. /**
  19020. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19021. * @param poseData raw pose fromthe device
  19022. */
  19023. updateFromDevice(poseData: DevicePose): void;
  19024. /**
  19025. * @hidden
  19026. */
  19027. _meshAttachedObservable: Observable<AbstractMesh>;
  19028. /**
  19029. * Attaches a mesh to the controller
  19030. * @param mesh the mesh to be attached
  19031. */
  19032. attachToMesh(mesh: AbstractMesh): void;
  19033. /**
  19034. * Attaches the controllers mesh to a camera
  19035. * @param camera the camera the mesh should be attached to
  19036. */
  19037. attachToPoseControlledCamera(camera: TargetCamera): void;
  19038. /**
  19039. * Disposes of the controller
  19040. */
  19041. dispose(): void;
  19042. /**
  19043. * The mesh that is attached to the controller
  19044. */
  19045. get mesh(): Nullable<AbstractMesh>;
  19046. /**
  19047. * Gets the ray of the controller in the direction the controller is pointing
  19048. * @param length the length the resulting ray should be
  19049. * @returns a ray in the direction the controller is pointing
  19050. */
  19051. getForwardRay(length?: number): Ray;
  19052. }
  19053. }
  19054. declare module BABYLON {
  19055. /**
  19056. * Defines the WebVRController object that represents controllers tracked in 3D space
  19057. */
  19058. export abstract class WebVRController extends PoseEnabledController {
  19059. /**
  19060. * Internal, the default controller model for the controller
  19061. */
  19062. protected _defaultModel: Nullable<AbstractMesh>;
  19063. /**
  19064. * Fired when the trigger state has changed
  19065. */
  19066. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19067. /**
  19068. * Fired when the main button state has changed
  19069. */
  19070. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19071. /**
  19072. * Fired when the secondary button state has changed
  19073. */
  19074. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19075. /**
  19076. * Fired when the pad state has changed
  19077. */
  19078. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19079. /**
  19080. * Fired when controllers stick values have changed
  19081. */
  19082. onPadValuesChangedObservable: Observable<StickValues>;
  19083. /**
  19084. * Array of button availible on the controller
  19085. */
  19086. protected _buttons: Array<MutableGamepadButton>;
  19087. private _onButtonStateChange;
  19088. /**
  19089. * Fired when a controller button's state has changed
  19090. * @param callback the callback containing the button that was modified
  19091. */
  19092. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19093. /**
  19094. * X and Y axis corresponding to the controllers joystick
  19095. */
  19096. pad: StickValues;
  19097. /**
  19098. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19099. */
  19100. hand: string;
  19101. /**
  19102. * The default controller model for the controller
  19103. */
  19104. get defaultModel(): Nullable<AbstractMesh>;
  19105. /**
  19106. * Creates a new WebVRController from a gamepad
  19107. * @param vrGamepad the gamepad that the WebVRController should be created from
  19108. */
  19109. constructor(vrGamepad: any);
  19110. /**
  19111. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19112. */
  19113. update(): void;
  19114. /**
  19115. * Function to be called when a button is modified
  19116. */
  19117. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19118. /**
  19119. * Loads a mesh and attaches it to the controller
  19120. * @param scene the scene the mesh should be added to
  19121. * @param meshLoaded callback for when the mesh has been loaded
  19122. */
  19123. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19124. private _setButtonValue;
  19125. private _changes;
  19126. private _checkChanges;
  19127. /**
  19128. * Disposes of th webVRCOntroller
  19129. */
  19130. dispose(): void;
  19131. }
  19132. }
  19133. declare module BABYLON {
  19134. /**
  19135. * The HemisphericLight simulates the ambient environment light,
  19136. * so the passed direction is the light reflection direction, not the incoming direction.
  19137. */
  19138. export class HemisphericLight extends Light {
  19139. /**
  19140. * The groundColor is the light in the opposite direction to the one specified during creation.
  19141. * 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.
  19142. */
  19143. groundColor: Color3;
  19144. /**
  19145. * The light reflection direction, not the incoming direction.
  19146. */
  19147. direction: Vector3;
  19148. /**
  19149. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19150. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19151. * The HemisphericLight can't cast shadows.
  19152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19153. * @param name The friendly name of the light
  19154. * @param direction The direction of the light reflection
  19155. * @param scene The scene the light belongs to
  19156. */
  19157. constructor(name: string, direction: Vector3, scene: Scene);
  19158. protected _buildUniformLayout(): void;
  19159. /**
  19160. * Returns the string "HemisphericLight".
  19161. * @return The class name
  19162. */
  19163. getClassName(): string;
  19164. /**
  19165. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19166. * Returns the updated direction.
  19167. * @param target The target the direction should point to
  19168. * @return The computed direction
  19169. */
  19170. setDirectionToTarget(target: Vector3): Vector3;
  19171. /**
  19172. * Returns the shadow generator associated to the light.
  19173. * @returns Always null for hemispheric lights because it does not support shadows.
  19174. */
  19175. getShadowGenerator(): Nullable<IShadowGenerator>;
  19176. /**
  19177. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19178. * @param effect The effect to update
  19179. * @param lightIndex The index of the light in the effect to update
  19180. * @returns The hemispheric light
  19181. */
  19182. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19183. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19184. /**
  19185. * Computes the world matrix of the node
  19186. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19187. * @param useWasUpdatedFlag defines a reserved property
  19188. * @returns the world matrix
  19189. */
  19190. computeWorldMatrix(): Matrix;
  19191. /**
  19192. * Returns the integer 3.
  19193. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19194. */
  19195. getTypeID(): number;
  19196. /**
  19197. * Prepares the list of defines specific to the light type.
  19198. * @param defines the list of defines
  19199. * @param lightIndex defines the index of the light for the effect
  19200. */
  19201. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19202. }
  19203. }
  19204. declare module BABYLON {
  19205. /** @hidden */
  19206. export var vrMultiviewToSingleviewPixelShader: {
  19207. name: string;
  19208. shader: string;
  19209. };
  19210. }
  19211. declare module BABYLON {
  19212. /**
  19213. * Renders to multiple views with a single draw call
  19214. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19215. */
  19216. export class MultiviewRenderTarget extends RenderTargetTexture {
  19217. /**
  19218. * Creates a multiview render target
  19219. * @param scene scene used with the render target
  19220. * @param size the size of the render target (used for each view)
  19221. */
  19222. constructor(scene: Scene, size?: number | {
  19223. width: number;
  19224. height: number;
  19225. } | {
  19226. ratio: number;
  19227. });
  19228. /**
  19229. * @hidden
  19230. * @param faceIndex the face index, if its a cube texture
  19231. */
  19232. _bindFrameBuffer(faceIndex?: number): void;
  19233. /**
  19234. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19235. * @returns the view count
  19236. */
  19237. getViewCount(): number;
  19238. }
  19239. }
  19240. declare module BABYLON {
  19241. /**
  19242. * Represents a camera frustum
  19243. */
  19244. export class Frustum {
  19245. /**
  19246. * Gets the planes representing the frustum
  19247. * @param transform matrix to be applied to the returned planes
  19248. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19249. */
  19250. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19251. /**
  19252. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19257. /**
  19258. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19263. /**
  19264. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19269. /**
  19270. * Gets the right frustum plane transformed by the transform matrix
  19271. * @param transform transformation matrix to be applied to the resulting frustum plane
  19272. * @param frustumPlane the resuling frustum plane
  19273. */
  19274. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19275. /**
  19276. * Gets the top frustum plane transformed by the transform matrix
  19277. * @param transform transformation matrix to be applied to the resulting frustum plane
  19278. * @param frustumPlane the resuling frustum plane
  19279. */
  19280. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19281. /**
  19282. * Gets the bottom frustum plane transformed by the transform matrix
  19283. * @param transform transformation matrix to be applied to the resulting frustum plane
  19284. * @param frustumPlane the resuling frustum plane
  19285. */
  19286. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19287. /**
  19288. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19289. * @param transform transformation matrix to be applied to the resulting frustum planes
  19290. * @param frustumPlanes the resuling frustum planes
  19291. */
  19292. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19293. }
  19294. }
  19295. declare module BABYLON {
  19296. interface Engine {
  19297. /**
  19298. * Creates a new multiview render target
  19299. * @param width defines the width of the texture
  19300. * @param height defines the height of the texture
  19301. * @returns the created multiview texture
  19302. */
  19303. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19304. /**
  19305. * Binds a multiview framebuffer to be drawn to
  19306. * @param multiviewTexture texture to bind
  19307. */
  19308. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19309. }
  19310. interface Camera {
  19311. /**
  19312. * @hidden
  19313. * 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)
  19314. */
  19315. _useMultiviewToSingleView: boolean;
  19316. /**
  19317. * @hidden
  19318. * 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)
  19319. */
  19320. _multiviewTexture: Nullable<RenderTargetTexture>;
  19321. /**
  19322. * @hidden
  19323. * ensures the multiview texture of the camera exists and has the specified width/height
  19324. * @param width height to set on the multiview texture
  19325. * @param height width to set on the multiview texture
  19326. */
  19327. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19328. }
  19329. interface Scene {
  19330. /** @hidden */
  19331. _transformMatrixR: Matrix;
  19332. /** @hidden */
  19333. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19334. /** @hidden */
  19335. _createMultiviewUbo(): void;
  19336. /** @hidden */
  19337. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19338. /** @hidden */
  19339. _renderMultiviewToSingleView(camera: Camera): void;
  19340. }
  19341. }
  19342. declare module BABYLON {
  19343. /**
  19344. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19345. * This will not be used for webXR as it supports displaying texture arrays directly
  19346. */
  19347. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19348. /**
  19349. * Initializes a VRMultiviewToSingleview
  19350. * @param name name of the post process
  19351. * @param camera camera to be applied to
  19352. * @param scaleFactor scaling factor to the size of the output texture
  19353. */
  19354. constructor(name: string, camera: Camera, scaleFactor: number);
  19355. }
  19356. }
  19357. declare module BABYLON {
  19358. /**
  19359. * Interface used to define additional presentation attributes
  19360. */
  19361. export interface IVRPresentationAttributes {
  19362. /**
  19363. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19364. */
  19365. highRefreshRate: boolean;
  19366. /**
  19367. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19368. */
  19369. foveationLevel: number;
  19370. }
  19371. interface Engine {
  19372. /** @hidden */
  19373. _vrDisplay: any;
  19374. /** @hidden */
  19375. _vrSupported: boolean;
  19376. /** @hidden */
  19377. _oldSize: Size;
  19378. /** @hidden */
  19379. _oldHardwareScaleFactor: number;
  19380. /** @hidden */
  19381. _vrExclusivePointerMode: boolean;
  19382. /** @hidden */
  19383. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19384. /** @hidden */
  19385. _onVRDisplayPointerRestricted: () => void;
  19386. /** @hidden */
  19387. _onVRDisplayPointerUnrestricted: () => void;
  19388. /** @hidden */
  19389. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19390. /** @hidden */
  19391. _onVrDisplayDisconnect: Nullable<() => void>;
  19392. /** @hidden */
  19393. _onVrDisplayPresentChange: Nullable<() => void>;
  19394. /**
  19395. * Observable signaled when VR display mode changes
  19396. */
  19397. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19398. /**
  19399. * Observable signaled when VR request present is complete
  19400. */
  19401. onVRRequestPresentComplete: Observable<boolean>;
  19402. /**
  19403. * Observable signaled when VR request present starts
  19404. */
  19405. onVRRequestPresentStart: Observable<Engine>;
  19406. /**
  19407. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19408. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19409. */
  19410. isInVRExclusivePointerMode: boolean;
  19411. /**
  19412. * Gets a boolean indicating if a webVR device was detected
  19413. * @returns true if a webVR device was detected
  19414. */
  19415. isVRDevicePresent(): boolean;
  19416. /**
  19417. * Gets the current webVR device
  19418. * @returns the current webVR device (or null)
  19419. */
  19420. getVRDevice(): any;
  19421. /**
  19422. * Initializes a webVR display and starts listening to display change events
  19423. * The onVRDisplayChangedObservable will be notified upon these changes
  19424. * @returns A promise containing a VRDisplay and if vr is supported
  19425. */
  19426. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19427. /** @hidden */
  19428. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19429. /**
  19430. * Gets or sets the presentation attributes used to configure VR rendering
  19431. */
  19432. vrPresentationAttributes?: IVRPresentationAttributes;
  19433. /**
  19434. * Call this function to switch to webVR mode
  19435. * Will do nothing if webVR is not supported or if there is no webVR device
  19436. * @param options the webvr options provided to the camera. mainly used for multiview
  19437. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19438. */
  19439. enableVR(options: WebVROptions): void;
  19440. /** @hidden */
  19441. _onVRFullScreenTriggered(): void;
  19442. }
  19443. }
  19444. declare module BABYLON {
  19445. /**
  19446. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19447. * IMPORTANT!! The data is right-hand data.
  19448. * @export
  19449. * @interface DevicePose
  19450. */
  19451. export interface DevicePose {
  19452. /**
  19453. * The position of the device, values in array are [x,y,z].
  19454. */
  19455. readonly position: Nullable<Float32Array>;
  19456. /**
  19457. * The linearVelocity of the device, values in array are [x,y,z].
  19458. */
  19459. readonly linearVelocity: Nullable<Float32Array>;
  19460. /**
  19461. * The linearAcceleration of the device, values in array are [x,y,z].
  19462. */
  19463. readonly linearAcceleration: Nullable<Float32Array>;
  19464. /**
  19465. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19466. */
  19467. readonly orientation: Nullable<Float32Array>;
  19468. /**
  19469. * The angularVelocity of the device, values in array are [x,y,z].
  19470. */
  19471. readonly angularVelocity: Nullable<Float32Array>;
  19472. /**
  19473. * The angularAcceleration of the device, values in array are [x,y,z].
  19474. */
  19475. readonly angularAcceleration: Nullable<Float32Array>;
  19476. }
  19477. /**
  19478. * Interface representing a pose controlled object in Babylon.
  19479. * A pose controlled object has both regular pose values as well as pose values
  19480. * from an external device such as a VR head mounted display
  19481. */
  19482. export interface PoseControlled {
  19483. /**
  19484. * The position of the object in babylon space.
  19485. */
  19486. position: Vector3;
  19487. /**
  19488. * The rotation quaternion of the object in babylon space.
  19489. */
  19490. rotationQuaternion: Quaternion;
  19491. /**
  19492. * The position of the device in babylon space.
  19493. */
  19494. devicePosition?: Vector3;
  19495. /**
  19496. * The rotation quaternion of the device in babylon space.
  19497. */
  19498. deviceRotationQuaternion: Quaternion;
  19499. /**
  19500. * The raw pose coming from the device.
  19501. */
  19502. rawPose: Nullable<DevicePose>;
  19503. /**
  19504. * The scale of the device to be used when translating from device space to babylon space.
  19505. */
  19506. deviceScaleFactor: number;
  19507. /**
  19508. * Updates the poseControlled values based on the input device pose.
  19509. * @param poseData the pose data to update the object with
  19510. */
  19511. updateFromDevice(poseData: DevicePose): void;
  19512. }
  19513. /**
  19514. * Set of options to customize the webVRCamera
  19515. */
  19516. export interface WebVROptions {
  19517. /**
  19518. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19519. */
  19520. trackPosition?: boolean;
  19521. /**
  19522. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19523. */
  19524. positionScale?: number;
  19525. /**
  19526. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19527. */
  19528. displayName?: string;
  19529. /**
  19530. * Should the native controller meshes be initialized. (default: true)
  19531. */
  19532. controllerMeshes?: boolean;
  19533. /**
  19534. * Creating a default HemiLight only on controllers. (default: true)
  19535. */
  19536. defaultLightingOnControllers?: boolean;
  19537. /**
  19538. * If you don't want to use the default VR button of the helper. (default: false)
  19539. */
  19540. useCustomVRButton?: boolean;
  19541. /**
  19542. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19543. */
  19544. customVRButton?: HTMLButtonElement;
  19545. /**
  19546. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19547. */
  19548. rayLength?: number;
  19549. /**
  19550. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19551. */
  19552. defaultHeight?: number;
  19553. /**
  19554. * If multiview should be used if availible (default: false)
  19555. */
  19556. useMultiview?: boolean;
  19557. }
  19558. /**
  19559. * This represents a WebVR camera.
  19560. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19561. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19562. */
  19563. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19564. private webVROptions;
  19565. /**
  19566. * @hidden
  19567. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19568. */
  19569. _vrDevice: any;
  19570. /**
  19571. * The rawPose of the vrDevice.
  19572. */
  19573. rawPose: Nullable<DevicePose>;
  19574. private _onVREnabled;
  19575. private _specsVersion;
  19576. private _attached;
  19577. private _frameData;
  19578. protected _descendants: Array<Node>;
  19579. private _deviceRoomPosition;
  19580. /** @hidden */
  19581. _deviceRoomRotationQuaternion: Quaternion;
  19582. private _standingMatrix;
  19583. /**
  19584. * Represents device position in babylon space.
  19585. */
  19586. devicePosition: Vector3;
  19587. /**
  19588. * Represents device rotation in babylon space.
  19589. */
  19590. deviceRotationQuaternion: Quaternion;
  19591. /**
  19592. * The scale of the device to be used when translating from device space to babylon space.
  19593. */
  19594. deviceScaleFactor: number;
  19595. private _deviceToWorld;
  19596. private _worldToDevice;
  19597. /**
  19598. * References to the webVR controllers for the vrDevice.
  19599. */
  19600. controllers: Array<WebVRController>;
  19601. /**
  19602. * Emits an event when a controller is attached.
  19603. */
  19604. onControllersAttachedObservable: Observable<WebVRController[]>;
  19605. /**
  19606. * Emits an event when a controller's mesh has been loaded;
  19607. */
  19608. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19609. /**
  19610. * Emits an event when the HMD's pose has been updated.
  19611. */
  19612. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19613. private _poseSet;
  19614. /**
  19615. * If the rig cameras be used as parent instead of this camera.
  19616. */
  19617. rigParenting: boolean;
  19618. private _lightOnControllers;
  19619. private _defaultHeight?;
  19620. /**
  19621. * Instantiates a WebVRFreeCamera.
  19622. * @param name The name of the WebVRFreeCamera
  19623. * @param position The starting anchor position for the camera
  19624. * @param scene The scene the camera belongs to
  19625. * @param webVROptions a set of customizable options for the webVRCamera
  19626. */
  19627. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19628. /**
  19629. * Gets the device distance from the ground in meters.
  19630. * @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.
  19631. */
  19632. deviceDistanceToRoomGround(): number;
  19633. /**
  19634. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19635. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19636. */
  19637. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19638. /**
  19639. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19640. * @returns A promise with a boolean set to if the standing matrix is supported.
  19641. */
  19642. useStandingMatrixAsync(): Promise<boolean>;
  19643. /**
  19644. * Disposes the camera
  19645. */
  19646. dispose(): void;
  19647. /**
  19648. * Gets a vrController by name.
  19649. * @param name The name of the controller to retreive
  19650. * @returns the controller matching the name specified or null if not found
  19651. */
  19652. getControllerByName(name: string): Nullable<WebVRController>;
  19653. private _leftController;
  19654. /**
  19655. * The controller corresponding to the users left hand.
  19656. */
  19657. get leftController(): Nullable<WebVRController>;
  19658. private _rightController;
  19659. /**
  19660. * The controller corresponding to the users right hand.
  19661. */
  19662. get rightController(): Nullable<WebVRController>;
  19663. /**
  19664. * Casts a ray forward from the vrCamera's gaze.
  19665. * @param length Length of the ray (default: 100)
  19666. * @returns the ray corresponding to the gaze
  19667. */
  19668. getForwardRay(length?: number): Ray;
  19669. /**
  19670. * @hidden
  19671. * Updates the camera based on device's frame data
  19672. */
  19673. _checkInputs(): void;
  19674. /**
  19675. * Updates the poseControlled values based on the input device pose.
  19676. * @param poseData Pose coming from the device
  19677. */
  19678. updateFromDevice(poseData: DevicePose): void;
  19679. private _htmlElementAttached;
  19680. private _detachIfAttached;
  19681. /**
  19682. * WebVR's attach control will start broadcasting frames to the device.
  19683. * Note that in certain browsers (chrome for example) this function must be called
  19684. * within a user-interaction callback. Example:
  19685. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19686. *
  19687. * @param element html element to attach the vrDevice to
  19688. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19689. */
  19690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19691. /**
  19692. * Detaches the camera from the html element and disables VR
  19693. *
  19694. * @param element html element to detach from
  19695. */
  19696. detachControl(element: HTMLElement): void;
  19697. /**
  19698. * @returns the name of this class
  19699. */
  19700. getClassName(): string;
  19701. /**
  19702. * Calls resetPose on the vrDisplay
  19703. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19704. */
  19705. resetToCurrentRotation(): void;
  19706. /**
  19707. * @hidden
  19708. * Updates the rig cameras (left and right eye)
  19709. */
  19710. _updateRigCameras(): void;
  19711. private _workingVector;
  19712. private _oneVector;
  19713. private _workingMatrix;
  19714. private updateCacheCalled;
  19715. private _correctPositionIfNotTrackPosition;
  19716. /**
  19717. * @hidden
  19718. * Updates the cached values of the camera
  19719. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19720. */
  19721. _updateCache(ignoreParentClass?: boolean): void;
  19722. /**
  19723. * @hidden
  19724. * Get current device position in babylon world
  19725. */
  19726. _computeDevicePosition(): void;
  19727. /**
  19728. * Updates the current device position and rotation in the babylon world
  19729. */
  19730. update(): void;
  19731. /**
  19732. * @hidden
  19733. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19734. * @returns an identity matrix
  19735. */
  19736. _getViewMatrix(): Matrix;
  19737. private _tmpMatrix;
  19738. /**
  19739. * This function is called by the two RIG cameras.
  19740. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19741. * @hidden
  19742. */
  19743. _getWebVRViewMatrix(): Matrix;
  19744. /** @hidden */
  19745. _getWebVRProjectionMatrix(): Matrix;
  19746. private _onGamepadConnectedObserver;
  19747. private _onGamepadDisconnectedObserver;
  19748. private _updateCacheWhenTrackingDisabledObserver;
  19749. /**
  19750. * Initializes the controllers and their meshes
  19751. */
  19752. initControllers(): void;
  19753. }
  19754. }
  19755. declare module BABYLON {
  19756. /**
  19757. * Size options for a post process
  19758. */
  19759. export type PostProcessOptions = {
  19760. width: number;
  19761. height: number;
  19762. };
  19763. /**
  19764. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19765. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19766. */
  19767. export class PostProcess {
  19768. /** Name of the PostProcess. */
  19769. name: string;
  19770. /**
  19771. * Gets or sets the unique id of the post process
  19772. */
  19773. uniqueId: number;
  19774. /**
  19775. * Width of the texture to apply the post process on
  19776. */
  19777. width: number;
  19778. /**
  19779. * Height of the texture to apply the post process on
  19780. */
  19781. height: number;
  19782. /**
  19783. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19784. * @hidden
  19785. */
  19786. _outputTexture: Nullable<InternalTexture>;
  19787. /**
  19788. * Sampling mode used by the shader
  19789. * See https://doc.babylonjs.com/classes/3.1/texture
  19790. */
  19791. renderTargetSamplingMode: number;
  19792. /**
  19793. * Clear color to use when screen clearing
  19794. */
  19795. clearColor: Color4;
  19796. /**
  19797. * If the buffer needs to be cleared before applying the post process. (default: true)
  19798. * Should be set to false if shader will overwrite all previous pixels.
  19799. */
  19800. autoClear: boolean;
  19801. /**
  19802. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19803. */
  19804. alphaMode: number;
  19805. /**
  19806. * Sets the setAlphaBlendConstants of the babylon engine
  19807. */
  19808. alphaConstants: Color4;
  19809. /**
  19810. * Animations to be used for the post processing
  19811. */
  19812. animations: Animation[];
  19813. /**
  19814. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19815. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19816. */
  19817. enablePixelPerfectMode: boolean;
  19818. /**
  19819. * Force the postprocess to be applied without taking in account viewport
  19820. */
  19821. forceFullscreenViewport: boolean;
  19822. /**
  19823. * List of inspectable custom properties (used by the Inspector)
  19824. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19825. */
  19826. inspectableCustomProperties: IInspectable[];
  19827. /**
  19828. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19829. *
  19830. * | Value | Type | Description |
  19831. * | ----- | ----------------------------------- | ----------- |
  19832. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19833. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19834. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19835. *
  19836. */
  19837. scaleMode: number;
  19838. /**
  19839. * Force textures to be a power of two (default: false)
  19840. */
  19841. alwaysForcePOT: boolean;
  19842. private _samples;
  19843. /**
  19844. * Number of sample textures (default: 1)
  19845. */
  19846. get samples(): number;
  19847. set samples(n: number);
  19848. /**
  19849. * Modify the scale of the post process to be the same as the viewport (default: false)
  19850. */
  19851. adaptScaleToCurrentViewport: boolean;
  19852. private _camera;
  19853. private _scene;
  19854. private _engine;
  19855. private _options;
  19856. private _reusable;
  19857. private _textureType;
  19858. private _textureFormat;
  19859. /**
  19860. * Smart array of input and output textures for the post process.
  19861. * @hidden
  19862. */
  19863. _textures: SmartArray<InternalTexture>;
  19864. /**
  19865. * The index in _textures that corresponds to the output texture.
  19866. * @hidden
  19867. */
  19868. _currentRenderTextureInd: number;
  19869. private _effect;
  19870. private _samplers;
  19871. private _fragmentUrl;
  19872. private _vertexUrl;
  19873. private _parameters;
  19874. private _scaleRatio;
  19875. protected _indexParameters: any;
  19876. private _shareOutputWithPostProcess;
  19877. private _texelSize;
  19878. private _forcedOutputTexture;
  19879. /**
  19880. * Returns the fragment url or shader name used in the post process.
  19881. * @returns the fragment url or name in the shader store.
  19882. */
  19883. getEffectName(): string;
  19884. /**
  19885. * An event triggered when the postprocess is activated.
  19886. */
  19887. onActivateObservable: Observable<Camera>;
  19888. private _onActivateObserver;
  19889. /**
  19890. * A function that is added to the onActivateObservable
  19891. */
  19892. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19893. /**
  19894. * An event triggered when the postprocess changes its size.
  19895. */
  19896. onSizeChangedObservable: Observable<PostProcess>;
  19897. private _onSizeChangedObserver;
  19898. /**
  19899. * A function that is added to the onSizeChangedObservable
  19900. */
  19901. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19902. /**
  19903. * An event triggered when the postprocess applies its effect.
  19904. */
  19905. onApplyObservable: Observable<Effect>;
  19906. private _onApplyObserver;
  19907. /**
  19908. * A function that is added to the onApplyObservable
  19909. */
  19910. set onApply(callback: (effect: Effect) => void);
  19911. /**
  19912. * An event triggered before rendering the postprocess
  19913. */
  19914. onBeforeRenderObservable: Observable<Effect>;
  19915. private _onBeforeRenderObserver;
  19916. /**
  19917. * A function that is added to the onBeforeRenderObservable
  19918. */
  19919. set onBeforeRender(callback: (effect: Effect) => void);
  19920. /**
  19921. * An event triggered after rendering the postprocess
  19922. */
  19923. onAfterRenderObservable: Observable<Effect>;
  19924. private _onAfterRenderObserver;
  19925. /**
  19926. * A function that is added to the onAfterRenderObservable
  19927. */
  19928. set onAfterRender(callback: (efect: Effect) => void);
  19929. /**
  19930. * 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
  19931. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19932. */
  19933. get inputTexture(): InternalTexture;
  19934. set inputTexture(value: InternalTexture);
  19935. /**
  19936. * Gets the camera which post process is applied to.
  19937. * @returns The camera the post process is applied to.
  19938. */
  19939. getCamera(): Camera;
  19940. /**
  19941. * Gets the texel size of the postprocess.
  19942. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19943. */
  19944. get texelSize(): Vector2;
  19945. /**
  19946. * Creates a new instance PostProcess
  19947. * @param name The name of the PostProcess.
  19948. * @param fragmentUrl The url of the fragment shader to be used.
  19949. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19950. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19951. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19952. * @param camera The camera to apply the render pass to.
  19953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19954. * @param engine The engine which the post process will be applied. (default: current engine)
  19955. * @param reusable If the post process can be reused on the same frame. (default: false)
  19956. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19957. * @param textureType Type of textures used when performing the post process. (default: 0)
  19958. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19959. * @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
  19960. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19961. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19962. */
  19963. constructor(
  19964. /** Name of the PostProcess. */
  19965. 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);
  19966. /**
  19967. * Gets a string idenfifying the name of the class
  19968. * @returns "PostProcess" string
  19969. */
  19970. getClassName(): string;
  19971. /**
  19972. * Gets the engine which this post process belongs to.
  19973. * @returns The engine the post process was enabled with.
  19974. */
  19975. getEngine(): Engine;
  19976. /**
  19977. * The effect that is created when initializing the post process.
  19978. * @returns The created effect corresponding the the postprocess.
  19979. */
  19980. getEffect(): Effect;
  19981. /**
  19982. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19983. * @param postProcess The post process to share the output with.
  19984. * @returns This post process.
  19985. */
  19986. shareOutputWith(postProcess: PostProcess): PostProcess;
  19987. /**
  19988. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19989. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19990. */
  19991. useOwnOutput(): void;
  19992. /**
  19993. * Updates the effect with the current post process compile time values and recompiles the shader.
  19994. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19995. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19996. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19997. * @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
  19998. * @param onCompiled Called when the shader has been compiled.
  19999. * @param onError Called if there is an error when compiling a shader.
  20000. */
  20001. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20002. /**
  20003. * The post process is reusable if it can be used multiple times within one frame.
  20004. * @returns If the post process is reusable
  20005. */
  20006. isReusable(): boolean;
  20007. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20008. markTextureDirty(): void;
  20009. /**
  20010. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20011. * 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.
  20012. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20013. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20014. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20015. * @returns The target texture that was bound to be written to.
  20016. */
  20017. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20018. /**
  20019. * If the post process is supported.
  20020. */
  20021. get isSupported(): boolean;
  20022. /**
  20023. * The aspect ratio of the output texture.
  20024. */
  20025. get aspectRatio(): number;
  20026. /**
  20027. * Get a value indicating if the post-process is ready to be used
  20028. * @returns true if the post-process is ready (shader is compiled)
  20029. */
  20030. isReady(): boolean;
  20031. /**
  20032. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20033. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20034. */
  20035. apply(): Nullable<Effect>;
  20036. private _disposeTextures;
  20037. /**
  20038. * Disposes the post process.
  20039. * @param camera The camera to dispose the post process on.
  20040. */
  20041. dispose(camera?: Camera): void;
  20042. }
  20043. }
  20044. declare module BABYLON {
  20045. /** @hidden */
  20046. export var kernelBlurVaryingDeclaration: {
  20047. name: string;
  20048. shader: string;
  20049. };
  20050. }
  20051. declare module BABYLON {
  20052. /** @hidden */
  20053. export var kernelBlurFragment: {
  20054. name: string;
  20055. shader: string;
  20056. };
  20057. }
  20058. declare module BABYLON {
  20059. /** @hidden */
  20060. export var kernelBlurFragment2: {
  20061. name: string;
  20062. shader: string;
  20063. };
  20064. }
  20065. declare module BABYLON {
  20066. /** @hidden */
  20067. export var kernelBlurPixelShader: {
  20068. name: string;
  20069. shader: string;
  20070. };
  20071. }
  20072. declare module BABYLON {
  20073. /** @hidden */
  20074. export var kernelBlurVertex: {
  20075. name: string;
  20076. shader: string;
  20077. };
  20078. }
  20079. declare module BABYLON {
  20080. /** @hidden */
  20081. export var kernelBlurVertexShader: {
  20082. name: string;
  20083. shader: string;
  20084. };
  20085. }
  20086. declare module BABYLON {
  20087. /**
  20088. * The Blur Post Process which blurs an image based on a kernel and direction.
  20089. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20090. */
  20091. export class BlurPostProcess extends PostProcess {
  20092. /** The direction in which to blur the image. */
  20093. direction: Vector2;
  20094. private blockCompilation;
  20095. protected _kernel: number;
  20096. protected _idealKernel: number;
  20097. protected _packedFloat: boolean;
  20098. private _staticDefines;
  20099. /**
  20100. * Sets the length in pixels of the blur sample region
  20101. */
  20102. set kernel(v: number);
  20103. /**
  20104. * Gets the length in pixels of the blur sample region
  20105. */
  20106. get kernel(): number;
  20107. /**
  20108. * Sets wether or not the blur needs to unpack/repack floats
  20109. */
  20110. set packedFloat(v: boolean);
  20111. /**
  20112. * Gets wether or not the blur is unpacking/repacking floats
  20113. */
  20114. get packedFloat(): boolean;
  20115. /**
  20116. * Creates a new instance BlurPostProcess
  20117. * @param name The name of the effect.
  20118. * @param direction The direction in which to blur the image.
  20119. * @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.
  20120. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20121. * @param camera The camera to apply the render pass to.
  20122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20123. * @param engine The engine which the post process will be applied. (default: current engine)
  20124. * @param reusable If the post process can be reused on the same frame. (default: false)
  20125. * @param textureType Type of textures used when performing the post process. (default: 0)
  20126. * @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)
  20127. */
  20128. constructor(name: string,
  20129. /** The direction in which to blur the image. */
  20130. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20131. /**
  20132. * Updates the effect with the current post process compile time values and recompiles the shader.
  20133. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20134. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20135. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20136. * @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
  20137. * @param onCompiled Called when the shader has been compiled.
  20138. * @param onError Called if there is an error when compiling a shader.
  20139. */
  20140. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20141. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20142. /**
  20143. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20144. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20145. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20146. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20147. * The gaps between physical kernels are compensated for in the weighting of the samples
  20148. * @param idealKernel Ideal blur kernel.
  20149. * @return Nearest best kernel.
  20150. */
  20151. protected _nearestBestKernel(idealKernel: number): number;
  20152. /**
  20153. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20154. * @param x The point on the Gaussian distribution to sample.
  20155. * @return the value of the Gaussian function at x.
  20156. */
  20157. protected _gaussianWeight(x: number): number;
  20158. /**
  20159. * Generates a string that can be used as a floating point number in GLSL.
  20160. * @param x Value to print.
  20161. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20162. * @return GLSL float string.
  20163. */
  20164. protected _glslFloat(x: number, decimalFigures?: number): string;
  20165. }
  20166. }
  20167. declare module BABYLON {
  20168. /**
  20169. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20170. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20171. * You can then easily use it as a reflectionTexture on a flat surface.
  20172. * In case the surface is not a plane, please consider relying on reflection probes.
  20173. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20174. */
  20175. export class MirrorTexture extends RenderTargetTexture {
  20176. private scene;
  20177. /**
  20178. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20179. * 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.
  20180. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20181. */
  20182. mirrorPlane: Plane;
  20183. /**
  20184. * Define the blur ratio used to blur the reflection if needed.
  20185. */
  20186. set blurRatio(value: number);
  20187. get blurRatio(): number;
  20188. /**
  20189. * Define the adaptive blur kernel used to blur the reflection if needed.
  20190. * This will autocompute the closest best match for the `blurKernel`
  20191. */
  20192. set adaptiveBlurKernel(value: number);
  20193. /**
  20194. * Define the blur kernel used to blur the reflection if needed.
  20195. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20196. */
  20197. set blurKernel(value: number);
  20198. /**
  20199. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20200. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20201. */
  20202. set blurKernelX(value: number);
  20203. get blurKernelX(): number;
  20204. /**
  20205. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20206. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20207. */
  20208. set blurKernelY(value: number);
  20209. get blurKernelY(): number;
  20210. private _autoComputeBlurKernel;
  20211. protected _onRatioRescale(): void;
  20212. private _updateGammaSpace;
  20213. private _imageProcessingConfigChangeObserver;
  20214. private _transformMatrix;
  20215. private _mirrorMatrix;
  20216. private _savedViewMatrix;
  20217. private _blurX;
  20218. private _blurY;
  20219. private _adaptiveBlurKernel;
  20220. private _blurKernelX;
  20221. private _blurKernelY;
  20222. private _blurRatio;
  20223. /**
  20224. * Instantiates a Mirror Texture.
  20225. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20226. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20227. * You can then easily use it as a reflectionTexture on a flat surface.
  20228. * In case the surface is not a plane, please consider relying on reflection probes.
  20229. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20230. * @param name
  20231. * @param size
  20232. * @param scene
  20233. * @param generateMipMaps
  20234. * @param type
  20235. * @param samplingMode
  20236. * @param generateDepthBuffer
  20237. */
  20238. constructor(name: string, size: number | {
  20239. width: number;
  20240. height: number;
  20241. } | {
  20242. ratio: number;
  20243. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20244. private _preparePostProcesses;
  20245. /**
  20246. * Clone the mirror texture.
  20247. * @returns the cloned texture
  20248. */
  20249. clone(): MirrorTexture;
  20250. /**
  20251. * Serialize the texture to a JSON representation you could use in Parse later on
  20252. * @returns the serialized JSON representation
  20253. */
  20254. serialize(): any;
  20255. /**
  20256. * Dispose the texture and release its associated resources.
  20257. */
  20258. dispose(): void;
  20259. }
  20260. }
  20261. declare module BABYLON {
  20262. /**
  20263. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20264. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20265. */
  20266. export class Texture extends BaseTexture {
  20267. /**
  20268. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20269. */
  20270. static SerializeBuffers: boolean;
  20271. /** @hidden */
  20272. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20273. /** @hidden */
  20274. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20275. /** @hidden */
  20276. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20277. /** nearest is mag = nearest and min = nearest and mip = linear */
  20278. static readonly NEAREST_SAMPLINGMODE: number;
  20279. /** nearest is mag = nearest and min = nearest and mip = linear */
  20280. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20281. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20282. static readonly BILINEAR_SAMPLINGMODE: number;
  20283. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20284. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20285. /** Trilinear is mag = linear and min = linear and mip = linear */
  20286. static readonly TRILINEAR_SAMPLINGMODE: number;
  20287. /** Trilinear is mag = linear and min = linear and mip = linear */
  20288. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20289. /** mag = nearest and min = nearest and mip = nearest */
  20290. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20291. /** mag = nearest and min = linear and mip = nearest */
  20292. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20293. /** mag = nearest and min = linear and mip = linear */
  20294. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20295. /** mag = nearest and min = linear and mip = none */
  20296. static readonly NEAREST_LINEAR: number;
  20297. /** mag = nearest and min = nearest and mip = none */
  20298. static readonly NEAREST_NEAREST: number;
  20299. /** mag = linear and min = nearest and mip = nearest */
  20300. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20301. /** mag = linear and min = nearest and mip = linear */
  20302. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20303. /** mag = linear and min = linear and mip = none */
  20304. static readonly LINEAR_LINEAR: number;
  20305. /** mag = linear and min = nearest and mip = none */
  20306. static readonly LINEAR_NEAREST: number;
  20307. /** Explicit coordinates mode */
  20308. static readonly EXPLICIT_MODE: number;
  20309. /** Spherical coordinates mode */
  20310. static readonly SPHERICAL_MODE: number;
  20311. /** Planar coordinates mode */
  20312. static readonly PLANAR_MODE: number;
  20313. /** Cubic coordinates mode */
  20314. static readonly CUBIC_MODE: number;
  20315. /** Projection coordinates mode */
  20316. static readonly PROJECTION_MODE: number;
  20317. /** Inverse Cubic coordinates mode */
  20318. static readonly SKYBOX_MODE: number;
  20319. /** Inverse Cubic coordinates mode */
  20320. static readonly INVCUBIC_MODE: number;
  20321. /** Equirectangular coordinates mode */
  20322. static readonly EQUIRECTANGULAR_MODE: number;
  20323. /** Equirectangular Fixed coordinates mode */
  20324. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20325. /** Equirectangular Fixed Mirrored coordinates mode */
  20326. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20327. /** Texture is not repeating outside of 0..1 UVs */
  20328. static readonly CLAMP_ADDRESSMODE: number;
  20329. /** Texture is repeating outside of 0..1 UVs */
  20330. static readonly WRAP_ADDRESSMODE: number;
  20331. /** Texture is repeating and mirrored */
  20332. static readonly MIRROR_ADDRESSMODE: number;
  20333. /**
  20334. * 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
  20335. */
  20336. static UseSerializedUrlIfAny: boolean;
  20337. /**
  20338. * Define the url of the texture.
  20339. */
  20340. url: Nullable<string>;
  20341. /**
  20342. * Define an offset on the texture to offset the u coordinates of the UVs
  20343. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20344. */
  20345. uOffset: number;
  20346. /**
  20347. * Define an offset on the texture to offset the v coordinates of the UVs
  20348. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20349. */
  20350. vOffset: number;
  20351. /**
  20352. * Define an offset on the texture to scale the u coordinates of the UVs
  20353. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20354. */
  20355. uScale: number;
  20356. /**
  20357. * Define an offset on the texture to scale the v coordinates of the UVs
  20358. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20359. */
  20360. vScale: number;
  20361. /**
  20362. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20363. * @see http://doc.babylonjs.com/how_to/more_materials
  20364. */
  20365. uAng: number;
  20366. /**
  20367. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20368. * @see http://doc.babylonjs.com/how_to/more_materials
  20369. */
  20370. vAng: number;
  20371. /**
  20372. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20373. * @see http://doc.babylonjs.com/how_to/more_materials
  20374. */
  20375. wAng: number;
  20376. /**
  20377. * Defines the center of rotation (U)
  20378. */
  20379. uRotationCenter: number;
  20380. /**
  20381. * Defines the center of rotation (V)
  20382. */
  20383. vRotationCenter: number;
  20384. /**
  20385. * Defines the center of rotation (W)
  20386. */
  20387. wRotationCenter: number;
  20388. /**
  20389. * Are mip maps generated for this texture or not.
  20390. */
  20391. get noMipmap(): boolean;
  20392. /**
  20393. * List of inspectable custom properties (used by the Inspector)
  20394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20395. */
  20396. inspectableCustomProperties: Nullable<IInspectable[]>;
  20397. private _noMipmap;
  20398. /** @hidden */
  20399. _invertY: boolean;
  20400. private _rowGenerationMatrix;
  20401. private _cachedTextureMatrix;
  20402. private _projectionModeMatrix;
  20403. private _t0;
  20404. private _t1;
  20405. private _t2;
  20406. private _cachedUOffset;
  20407. private _cachedVOffset;
  20408. private _cachedUScale;
  20409. private _cachedVScale;
  20410. private _cachedUAng;
  20411. private _cachedVAng;
  20412. private _cachedWAng;
  20413. private _cachedProjectionMatrixId;
  20414. private _cachedCoordinatesMode;
  20415. /** @hidden */
  20416. protected _initialSamplingMode: number;
  20417. /** @hidden */
  20418. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20419. private _deleteBuffer;
  20420. protected _format: Nullable<number>;
  20421. private _delayedOnLoad;
  20422. private _delayedOnError;
  20423. private _mimeType?;
  20424. /**
  20425. * Observable triggered once the texture has been loaded.
  20426. */
  20427. onLoadObservable: Observable<Texture>;
  20428. protected _isBlocking: boolean;
  20429. /**
  20430. * Is the texture preventing material to render while loading.
  20431. * If false, a default texture will be used instead of the loading one during the preparation step.
  20432. */
  20433. set isBlocking(value: boolean);
  20434. get isBlocking(): boolean;
  20435. /**
  20436. * Get the current sampling mode associated with the texture.
  20437. */
  20438. get samplingMode(): number;
  20439. /**
  20440. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20441. */
  20442. get invertY(): boolean;
  20443. /**
  20444. * Instantiates a new texture.
  20445. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20446. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20447. * @param url defines the url of the picture to load as a texture
  20448. * @param scene defines the scene or engine the texture will belong to
  20449. * @param noMipmap defines if the texture will require mip maps or not
  20450. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20451. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20452. * @param onLoad defines a callback triggered when the texture has been loaded
  20453. * @param onError defines a callback triggered when an error occurred during the loading session
  20454. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20455. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20456. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20457. * @param mimeType defines an optional mime type information
  20458. */
  20459. 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);
  20460. /**
  20461. * Update the url (and optional buffer) of this texture if url was null during construction.
  20462. * @param url the url of the texture
  20463. * @param buffer the buffer of the texture (defaults to null)
  20464. * @param onLoad callback called when the texture is loaded (defaults to null)
  20465. */
  20466. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20467. /**
  20468. * Finish the loading sequence of a texture flagged as delayed load.
  20469. * @hidden
  20470. */
  20471. delayLoad(): void;
  20472. private _prepareRowForTextureGeneration;
  20473. /**
  20474. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20475. * @returns the transform matrix of the texture.
  20476. */
  20477. getTextureMatrix(uBase?: number): Matrix;
  20478. /**
  20479. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20480. * @returns The reflection texture transform
  20481. */
  20482. getReflectionTextureMatrix(): Matrix;
  20483. /**
  20484. * Clones the texture.
  20485. * @returns the cloned texture
  20486. */
  20487. clone(): Texture;
  20488. /**
  20489. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20490. * @returns The JSON representation of the texture
  20491. */
  20492. serialize(): any;
  20493. /**
  20494. * Get the current class name of the texture useful for serialization or dynamic coding.
  20495. * @returns "Texture"
  20496. */
  20497. getClassName(): string;
  20498. /**
  20499. * Dispose the texture and release its associated resources.
  20500. */
  20501. dispose(): void;
  20502. /**
  20503. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20504. * @param parsedTexture Define the JSON representation of the texture
  20505. * @param scene Define the scene the parsed texture should be instantiated in
  20506. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20507. * @returns The parsed texture if successful
  20508. */
  20509. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20510. /**
  20511. * Creates a texture from its base 64 representation.
  20512. * @param data Define the base64 payload without the data: prefix
  20513. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20514. * @param scene Define the scene the texture should belong to
  20515. * @param noMipmap Forces the texture to not create mip map information if true
  20516. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20517. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20518. * @param onLoad define a callback triggered when the texture has been loaded
  20519. * @param onError define a callback triggered when an error occurred during the loading session
  20520. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20521. * @returns the created texture
  20522. */
  20523. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20524. /**
  20525. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20526. * @param data Define the base64 payload without the data: prefix
  20527. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20528. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20529. * @param scene Define the scene the texture should belong to
  20530. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20531. * @param noMipmap Forces the texture to not create mip map information if true
  20532. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20533. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20534. * @param onLoad define a callback triggered when the texture has been loaded
  20535. * @param onError define a callback triggered when an error occurred during the loading session
  20536. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20537. * @returns the created texture
  20538. */
  20539. 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;
  20540. }
  20541. }
  20542. declare module BABYLON {
  20543. /**
  20544. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20545. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20546. */
  20547. export class PostProcessManager {
  20548. private _scene;
  20549. private _indexBuffer;
  20550. private _vertexBuffers;
  20551. /**
  20552. * Creates a new instance PostProcess
  20553. * @param scene The scene that the post process is associated with.
  20554. */
  20555. constructor(scene: Scene);
  20556. private _prepareBuffers;
  20557. private _buildIndexBuffer;
  20558. /**
  20559. * Rebuilds the vertex buffers of the manager.
  20560. * @hidden
  20561. */
  20562. _rebuild(): void;
  20563. /**
  20564. * Prepares a frame to be run through a post process.
  20565. * @param sourceTexture The input texture to the post procesess. (default: null)
  20566. * @param postProcesses An array of post processes to be run. (default: null)
  20567. * @returns True if the post processes were able to be run.
  20568. * @hidden
  20569. */
  20570. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20571. /**
  20572. * Manually render a set of post processes to a texture.
  20573. * @param postProcesses An array of post processes to be run.
  20574. * @param targetTexture The target texture to render to.
  20575. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20576. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20577. * @param lodLevel defines which lod of the texture to render to
  20578. */
  20579. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20580. /**
  20581. * Finalize the result of the output of the postprocesses.
  20582. * @param doNotPresent If true the result will not be displayed to the screen.
  20583. * @param targetTexture The target texture to render to.
  20584. * @param faceIndex The index of the face to bind the target texture to.
  20585. * @param postProcesses The array of post processes to render.
  20586. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20587. * @hidden
  20588. */
  20589. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20590. /**
  20591. * Disposes of the post process manager.
  20592. */
  20593. dispose(): void;
  20594. }
  20595. }
  20596. declare module BABYLON {
  20597. /**
  20598. * This Helps creating a texture that will be created from a camera in your scene.
  20599. * It is basically a dynamic texture that could be used to create special effects for instance.
  20600. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20601. */
  20602. export class RenderTargetTexture extends Texture {
  20603. isCube: boolean;
  20604. /**
  20605. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20606. */
  20607. static readonly REFRESHRATE_RENDER_ONCE: number;
  20608. /**
  20609. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20610. */
  20611. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20612. /**
  20613. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20614. * the central point of your effect and can save a lot of performances.
  20615. */
  20616. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20617. /**
  20618. * Use this predicate to dynamically define the list of mesh you want to render.
  20619. * If set, the renderList property will be overwritten.
  20620. */
  20621. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20622. private _renderList;
  20623. /**
  20624. * Use this list to define the list of mesh you want to render.
  20625. */
  20626. get renderList(): Nullable<Array<AbstractMesh>>;
  20627. set renderList(value: Nullable<Array<AbstractMesh>>);
  20628. /**
  20629. * Use this function to overload the renderList array at rendering time.
  20630. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20631. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20632. * the cube (if the RTT is a cube, else layerOrFace=0).
  20633. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20634. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20635. * hold dummy elements!
  20636. */
  20637. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20638. private _hookArray;
  20639. /**
  20640. * Define if particles should be rendered in your texture.
  20641. */
  20642. renderParticles: boolean;
  20643. /**
  20644. * Define if sprites should be rendered in your texture.
  20645. */
  20646. renderSprites: boolean;
  20647. /**
  20648. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20649. */
  20650. coordinatesMode: number;
  20651. /**
  20652. * Define the camera used to render the texture.
  20653. */
  20654. activeCamera: Nullable<Camera>;
  20655. /**
  20656. * Override the mesh isReady function with your own one.
  20657. */
  20658. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20659. /**
  20660. * Override the render function of the texture with your own one.
  20661. */
  20662. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20663. /**
  20664. * Define if camera post processes should be use while rendering the texture.
  20665. */
  20666. useCameraPostProcesses: boolean;
  20667. /**
  20668. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20669. */
  20670. ignoreCameraViewport: boolean;
  20671. private _postProcessManager;
  20672. private _postProcesses;
  20673. private _resizeObserver;
  20674. /**
  20675. * An event triggered when the texture is unbind.
  20676. */
  20677. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20678. /**
  20679. * An event triggered when the texture is unbind.
  20680. */
  20681. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20682. private _onAfterUnbindObserver;
  20683. /**
  20684. * Set a after unbind callback in the texture.
  20685. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20686. */
  20687. set onAfterUnbind(callback: () => void);
  20688. /**
  20689. * An event triggered before rendering the texture
  20690. */
  20691. onBeforeRenderObservable: Observable<number>;
  20692. private _onBeforeRenderObserver;
  20693. /**
  20694. * Set a before render callback in the texture.
  20695. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20696. */
  20697. set onBeforeRender(callback: (faceIndex: number) => void);
  20698. /**
  20699. * An event triggered after rendering the texture
  20700. */
  20701. onAfterRenderObservable: Observable<number>;
  20702. private _onAfterRenderObserver;
  20703. /**
  20704. * Set a after render callback in the texture.
  20705. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20706. */
  20707. set onAfterRender(callback: (faceIndex: number) => void);
  20708. /**
  20709. * An event triggered after the texture clear
  20710. */
  20711. onClearObservable: Observable<Engine>;
  20712. private _onClearObserver;
  20713. /**
  20714. * Set a clear callback in the texture.
  20715. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20716. */
  20717. set onClear(callback: (Engine: Engine) => void);
  20718. /**
  20719. * An event triggered when the texture is resized.
  20720. */
  20721. onResizeObservable: Observable<RenderTargetTexture>;
  20722. /**
  20723. * Define the clear color of the Render Target if it should be different from the scene.
  20724. */
  20725. clearColor: Color4;
  20726. protected _size: number | {
  20727. width: number;
  20728. height: number;
  20729. layers?: number;
  20730. };
  20731. protected _initialSizeParameter: number | {
  20732. width: number;
  20733. height: number;
  20734. } | {
  20735. ratio: number;
  20736. };
  20737. protected _sizeRatio: Nullable<number>;
  20738. /** @hidden */
  20739. _generateMipMaps: boolean;
  20740. protected _renderingManager: RenderingManager;
  20741. /** @hidden */
  20742. _waitingRenderList: string[];
  20743. protected _doNotChangeAspectRatio: boolean;
  20744. protected _currentRefreshId: number;
  20745. protected _refreshRate: number;
  20746. protected _textureMatrix: Matrix;
  20747. protected _samples: number;
  20748. protected _renderTargetOptions: RenderTargetCreationOptions;
  20749. /**
  20750. * Gets render target creation options that were used.
  20751. */
  20752. get renderTargetOptions(): RenderTargetCreationOptions;
  20753. protected _engine: Engine;
  20754. protected _onRatioRescale(): void;
  20755. /**
  20756. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20757. * It must define where the camera used to render the texture is set
  20758. */
  20759. boundingBoxPosition: Vector3;
  20760. private _boundingBoxSize;
  20761. /**
  20762. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20763. * When defined, the cubemap will switch to local mode
  20764. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20765. * @example https://www.babylonjs-playground.com/#RNASML
  20766. */
  20767. set boundingBoxSize(value: Vector3);
  20768. get boundingBoxSize(): Vector3;
  20769. /**
  20770. * In case the RTT has been created with a depth texture, get the associated
  20771. * depth texture.
  20772. * Otherwise, return null.
  20773. */
  20774. get depthStencilTexture(): Nullable<InternalTexture>;
  20775. /**
  20776. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20777. * or used a shadow, depth texture...
  20778. * @param name The friendly name of the texture
  20779. * @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)
  20780. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20781. * @param generateMipMaps True if mip maps need to be generated after render.
  20782. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20783. * @param type The type of the buffer in the RTT (int, half float, float...)
  20784. * @param isCube True if a cube texture needs to be created
  20785. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20786. * @param generateDepthBuffer True to generate a depth buffer
  20787. * @param generateStencilBuffer True to generate a stencil buffer
  20788. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20789. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20790. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20791. */
  20792. constructor(name: string, size: number | {
  20793. width: number;
  20794. height: number;
  20795. layers?: number;
  20796. } | {
  20797. ratio: number;
  20798. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20799. /**
  20800. * Creates a depth stencil texture.
  20801. * This is only available in WebGL 2 or with the depth texture extension available.
  20802. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20803. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20804. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20805. */
  20806. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20807. private _processSizeParameter;
  20808. /**
  20809. * Define the number of samples to use in case of MSAA.
  20810. * It defaults to one meaning no MSAA has been enabled.
  20811. */
  20812. get samples(): number;
  20813. set samples(value: number);
  20814. /**
  20815. * Resets the refresh counter of the texture and start bak from scratch.
  20816. * Could be useful to regenerate the texture if it is setup to render only once.
  20817. */
  20818. resetRefreshCounter(): void;
  20819. /**
  20820. * Define the refresh rate of the texture or the rendering frequency.
  20821. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20822. */
  20823. get refreshRate(): number;
  20824. set refreshRate(value: number);
  20825. /**
  20826. * Adds a post process to the render target rendering passes.
  20827. * @param postProcess define the post process to add
  20828. */
  20829. addPostProcess(postProcess: PostProcess): void;
  20830. /**
  20831. * Clear all the post processes attached to the render target
  20832. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20833. */
  20834. clearPostProcesses(dispose?: boolean): void;
  20835. /**
  20836. * Remove one of the post process from the list of attached post processes to the texture
  20837. * @param postProcess define the post process to remove from the list
  20838. */
  20839. removePostProcess(postProcess: PostProcess): void;
  20840. /** @hidden */
  20841. _shouldRender(): boolean;
  20842. /**
  20843. * Gets the actual render size of the texture.
  20844. * @returns the width of the render size
  20845. */
  20846. getRenderSize(): number;
  20847. /**
  20848. * Gets the actual render width of the texture.
  20849. * @returns the width of the render size
  20850. */
  20851. getRenderWidth(): number;
  20852. /**
  20853. * Gets the actual render height of the texture.
  20854. * @returns the height of the render size
  20855. */
  20856. getRenderHeight(): number;
  20857. /**
  20858. * Gets the actual number of layers of the texture.
  20859. * @returns the number of layers
  20860. */
  20861. getRenderLayers(): number;
  20862. /**
  20863. * Get if the texture can be rescaled or not.
  20864. */
  20865. get canRescale(): boolean;
  20866. /**
  20867. * Resize the texture using a ratio.
  20868. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20869. */
  20870. scale(ratio: number): void;
  20871. /**
  20872. * Get the texture reflection matrix used to rotate/transform the reflection.
  20873. * @returns the reflection matrix
  20874. */
  20875. getReflectionTextureMatrix(): Matrix;
  20876. /**
  20877. * Resize the texture to a new desired size.
  20878. * Be carrefull as it will recreate all the data in the new texture.
  20879. * @param size Define the new size. It can be:
  20880. * - a number for squared texture,
  20881. * - an object containing { width: number, height: number }
  20882. * - or an object containing a ratio { ratio: number }
  20883. */
  20884. resize(size: number | {
  20885. width: number;
  20886. height: number;
  20887. } | {
  20888. ratio: number;
  20889. }): void;
  20890. private _defaultRenderListPrepared;
  20891. /**
  20892. * Renders all the objects from the render list into the texture.
  20893. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20894. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20895. */
  20896. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20897. private _bestReflectionRenderTargetDimension;
  20898. private _prepareRenderingManager;
  20899. /**
  20900. * @hidden
  20901. * @param faceIndex face index to bind to if this is a cubetexture
  20902. * @param layer defines the index of the texture to bind in the array
  20903. */
  20904. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20905. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20906. private renderToTarget;
  20907. /**
  20908. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20909. * This allowed control for front to back rendering or reversly depending of the special needs.
  20910. *
  20911. * @param renderingGroupId The rendering group id corresponding to its index
  20912. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20913. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20914. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20915. */
  20916. 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;
  20917. /**
  20918. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20919. *
  20920. * @param renderingGroupId The rendering group id corresponding to its index
  20921. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20922. */
  20923. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20924. /**
  20925. * Clones the texture.
  20926. * @returns the cloned texture
  20927. */
  20928. clone(): RenderTargetTexture;
  20929. /**
  20930. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20931. * @returns The JSON representation of the texture
  20932. */
  20933. serialize(): any;
  20934. /**
  20935. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20936. */
  20937. disposeFramebufferObjects(): void;
  20938. /**
  20939. * Dispose the texture and release its associated resources.
  20940. */
  20941. dispose(): void;
  20942. /** @hidden */
  20943. _rebuild(): void;
  20944. /**
  20945. * Clear the info related to rendering groups preventing retention point in material dispose.
  20946. */
  20947. freeRenderingGroups(): void;
  20948. /**
  20949. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20950. * @returns the view count
  20951. */
  20952. getViewCount(): number;
  20953. }
  20954. }
  20955. declare module BABYLON {
  20956. /**
  20957. * Options for compiling materials.
  20958. */
  20959. export interface IMaterialCompilationOptions {
  20960. /**
  20961. * Defines whether clip planes are enabled.
  20962. */
  20963. clipPlane: boolean;
  20964. /**
  20965. * Defines whether instances are enabled.
  20966. */
  20967. useInstances: boolean;
  20968. }
  20969. /**
  20970. * Base class for the main features of a material in Babylon.js
  20971. */
  20972. export class Material implements IAnimatable {
  20973. /**
  20974. * Returns the triangle fill mode
  20975. */
  20976. static readonly TriangleFillMode: number;
  20977. /**
  20978. * Returns the wireframe mode
  20979. */
  20980. static readonly WireFrameFillMode: number;
  20981. /**
  20982. * Returns the point fill mode
  20983. */
  20984. static readonly PointFillMode: number;
  20985. /**
  20986. * Returns the point list draw mode
  20987. */
  20988. static readonly PointListDrawMode: number;
  20989. /**
  20990. * Returns the line list draw mode
  20991. */
  20992. static readonly LineListDrawMode: number;
  20993. /**
  20994. * Returns the line loop draw mode
  20995. */
  20996. static readonly LineLoopDrawMode: number;
  20997. /**
  20998. * Returns the line strip draw mode
  20999. */
  21000. static readonly LineStripDrawMode: number;
  21001. /**
  21002. * Returns the triangle strip draw mode
  21003. */
  21004. static readonly TriangleStripDrawMode: number;
  21005. /**
  21006. * Returns the triangle fan draw mode
  21007. */
  21008. static readonly TriangleFanDrawMode: number;
  21009. /**
  21010. * Stores the clock-wise side orientation
  21011. */
  21012. static readonly ClockWiseSideOrientation: number;
  21013. /**
  21014. * Stores the counter clock-wise side orientation
  21015. */
  21016. static readonly CounterClockWiseSideOrientation: number;
  21017. /**
  21018. * The dirty texture flag value
  21019. */
  21020. static readonly TextureDirtyFlag: number;
  21021. /**
  21022. * The dirty light flag value
  21023. */
  21024. static readonly LightDirtyFlag: number;
  21025. /**
  21026. * The dirty fresnel flag value
  21027. */
  21028. static readonly FresnelDirtyFlag: number;
  21029. /**
  21030. * The dirty attribute flag value
  21031. */
  21032. static readonly AttributesDirtyFlag: number;
  21033. /**
  21034. * The dirty misc flag value
  21035. */
  21036. static readonly MiscDirtyFlag: number;
  21037. /**
  21038. * The all dirty flag value
  21039. */
  21040. static readonly AllDirtyFlag: number;
  21041. /**
  21042. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21043. */
  21044. static readonly MATERIAL_OPAQUE: number;
  21045. /**
  21046. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21047. */
  21048. static readonly MATERIAL_ALPHATEST: number;
  21049. /**
  21050. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21051. */
  21052. static readonly MATERIAL_ALPHABLEND: number;
  21053. /**
  21054. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21055. * They are also discarded below the alpha cutoff threshold to improve performances.
  21056. */
  21057. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21058. /**
  21059. * The ID of the material
  21060. */
  21061. id: string;
  21062. /**
  21063. * Gets or sets the unique id of the material
  21064. */
  21065. uniqueId: number;
  21066. /**
  21067. * The name of the material
  21068. */
  21069. name: string;
  21070. /**
  21071. * Gets or sets user defined metadata
  21072. */
  21073. metadata: any;
  21074. /**
  21075. * For internal use only. Please do not use.
  21076. */
  21077. reservedDataStore: any;
  21078. /**
  21079. * Specifies if the ready state should be checked on each call
  21080. */
  21081. checkReadyOnEveryCall: boolean;
  21082. /**
  21083. * Specifies if the ready state should be checked once
  21084. */
  21085. checkReadyOnlyOnce: boolean;
  21086. /**
  21087. * The state of the material
  21088. */
  21089. state: string;
  21090. /**
  21091. * The alpha value of the material
  21092. */
  21093. protected _alpha: number;
  21094. /**
  21095. * List of inspectable custom properties (used by the Inspector)
  21096. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21097. */
  21098. inspectableCustomProperties: IInspectable[];
  21099. /**
  21100. * Sets the alpha value of the material
  21101. */
  21102. set alpha(value: number);
  21103. /**
  21104. * Gets the alpha value of the material
  21105. */
  21106. get alpha(): number;
  21107. /**
  21108. * Specifies if back face culling is enabled
  21109. */
  21110. protected _backFaceCulling: boolean;
  21111. /**
  21112. * Sets the back-face culling state
  21113. */
  21114. set backFaceCulling(value: boolean);
  21115. /**
  21116. * Gets the back-face culling state
  21117. */
  21118. get backFaceCulling(): boolean;
  21119. /**
  21120. * Stores the value for side orientation
  21121. */
  21122. sideOrientation: number;
  21123. /**
  21124. * Callback triggered when the material is compiled
  21125. */
  21126. onCompiled: Nullable<(effect: Effect) => void>;
  21127. /**
  21128. * Callback triggered when an error occurs
  21129. */
  21130. onError: Nullable<(effect: Effect, errors: string) => void>;
  21131. /**
  21132. * Callback triggered to get the render target textures
  21133. */
  21134. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21135. /**
  21136. * Gets a boolean indicating that current material needs to register RTT
  21137. */
  21138. get hasRenderTargetTextures(): boolean;
  21139. /**
  21140. * Specifies if the material should be serialized
  21141. */
  21142. doNotSerialize: boolean;
  21143. /**
  21144. * @hidden
  21145. */
  21146. _storeEffectOnSubMeshes: boolean;
  21147. /**
  21148. * Stores the animations for the material
  21149. */
  21150. animations: Nullable<Array<Animation>>;
  21151. /**
  21152. * An event triggered when the material is disposed
  21153. */
  21154. onDisposeObservable: Observable<Material>;
  21155. /**
  21156. * An observer which watches for dispose events
  21157. */
  21158. private _onDisposeObserver;
  21159. private _onUnBindObservable;
  21160. /**
  21161. * Called during a dispose event
  21162. */
  21163. set onDispose(callback: () => void);
  21164. private _onBindObservable;
  21165. /**
  21166. * An event triggered when the material is bound
  21167. */
  21168. get onBindObservable(): Observable<AbstractMesh>;
  21169. /**
  21170. * An observer which watches for bind events
  21171. */
  21172. private _onBindObserver;
  21173. /**
  21174. * Called during a bind event
  21175. */
  21176. set onBind(callback: (Mesh: AbstractMesh) => void);
  21177. /**
  21178. * An event triggered when the material is unbound
  21179. */
  21180. get onUnBindObservable(): Observable<Material>;
  21181. /**
  21182. * Stores the value of the alpha mode
  21183. */
  21184. private _alphaMode;
  21185. /**
  21186. * Sets the value of the alpha mode.
  21187. *
  21188. * | Value | Type | Description |
  21189. * | --- | --- | --- |
  21190. * | 0 | ALPHA_DISABLE | |
  21191. * | 1 | ALPHA_ADD | |
  21192. * | 2 | ALPHA_COMBINE | |
  21193. * | 3 | ALPHA_SUBTRACT | |
  21194. * | 4 | ALPHA_MULTIPLY | |
  21195. * | 5 | ALPHA_MAXIMIZED | |
  21196. * | 6 | ALPHA_ONEONE | |
  21197. * | 7 | ALPHA_PREMULTIPLIED | |
  21198. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21199. * | 9 | ALPHA_INTERPOLATE | |
  21200. * | 10 | ALPHA_SCREENMODE | |
  21201. *
  21202. */
  21203. set alphaMode(value: number);
  21204. /**
  21205. * Gets the value of the alpha mode
  21206. */
  21207. get alphaMode(): number;
  21208. /**
  21209. * Stores the state of the need depth pre-pass value
  21210. */
  21211. private _needDepthPrePass;
  21212. /**
  21213. * Sets the need depth pre-pass value
  21214. */
  21215. set needDepthPrePass(value: boolean);
  21216. /**
  21217. * Gets the depth pre-pass value
  21218. */
  21219. get needDepthPrePass(): boolean;
  21220. /**
  21221. * Specifies if depth writing should be disabled
  21222. */
  21223. disableDepthWrite: boolean;
  21224. /**
  21225. * Specifies if depth writing should be forced
  21226. */
  21227. forceDepthWrite: boolean;
  21228. /**
  21229. * Specifies the depth function that should be used. 0 means the default engine function
  21230. */
  21231. depthFunction: number;
  21232. /**
  21233. * Specifies if there should be a separate pass for culling
  21234. */
  21235. separateCullingPass: boolean;
  21236. /**
  21237. * Stores the state specifing if fog should be enabled
  21238. */
  21239. private _fogEnabled;
  21240. /**
  21241. * Sets the state for enabling fog
  21242. */
  21243. set fogEnabled(value: boolean);
  21244. /**
  21245. * Gets the value of the fog enabled state
  21246. */
  21247. get fogEnabled(): boolean;
  21248. /**
  21249. * Stores the size of points
  21250. */
  21251. pointSize: number;
  21252. /**
  21253. * Stores the z offset value
  21254. */
  21255. zOffset: number;
  21256. /**
  21257. * Gets a value specifying if wireframe mode is enabled
  21258. */
  21259. get wireframe(): boolean;
  21260. /**
  21261. * Sets the state of wireframe mode
  21262. */
  21263. set wireframe(value: boolean);
  21264. /**
  21265. * Gets the value specifying if point clouds are enabled
  21266. */
  21267. get pointsCloud(): boolean;
  21268. /**
  21269. * Sets the state of point cloud mode
  21270. */
  21271. set pointsCloud(value: boolean);
  21272. /**
  21273. * Gets the material fill mode
  21274. */
  21275. get fillMode(): number;
  21276. /**
  21277. * Sets the material fill mode
  21278. */
  21279. set fillMode(value: number);
  21280. /**
  21281. * @hidden
  21282. * Stores the effects for the material
  21283. */
  21284. _effect: Nullable<Effect>;
  21285. /**
  21286. * Specifies if uniform buffers should be used
  21287. */
  21288. private _useUBO;
  21289. /**
  21290. * Stores a reference to the scene
  21291. */
  21292. private _scene;
  21293. /**
  21294. * Stores the fill mode state
  21295. */
  21296. private _fillMode;
  21297. /**
  21298. * Specifies if the depth write state should be cached
  21299. */
  21300. private _cachedDepthWriteState;
  21301. /**
  21302. * Specifies if the depth function state should be cached
  21303. */
  21304. private _cachedDepthFunctionState;
  21305. /**
  21306. * Stores the uniform buffer
  21307. */
  21308. protected _uniformBuffer: UniformBuffer;
  21309. /** @hidden */
  21310. _indexInSceneMaterialArray: number;
  21311. /** @hidden */
  21312. meshMap: Nullable<{
  21313. [id: string]: AbstractMesh | undefined;
  21314. }>;
  21315. /**
  21316. * Creates a material instance
  21317. * @param name defines the name of the material
  21318. * @param scene defines the scene to reference
  21319. * @param doNotAdd specifies if the material should be added to the scene
  21320. */
  21321. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21322. /**
  21323. * Returns a string representation of the current material
  21324. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21325. * @returns a string with material information
  21326. */
  21327. toString(fullDetails?: boolean): string;
  21328. /**
  21329. * Gets the class name of the material
  21330. * @returns a string with the class name of the material
  21331. */
  21332. getClassName(): string;
  21333. /**
  21334. * Specifies if updates for the material been locked
  21335. */
  21336. get isFrozen(): boolean;
  21337. /**
  21338. * Locks updates for the material
  21339. */
  21340. freeze(): void;
  21341. /**
  21342. * Unlocks updates for the material
  21343. */
  21344. unfreeze(): void;
  21345. /**
  21346. * Specifies if the material is ready to be used
  21347. * @param mesh defines the mesh to check
  21348. * @param useInstances specifies if instances should be used
  21349. * @returns a boolean indicating if the material is ready to be used
  21350. */
  21351. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21352. /**
  21353. * Specifies that the submesh is ready to be used
  21354. * @param mesh defines the mesh to check
  21355. * @param subMesh defines which submesh to check
  21356. * @param useInstances specifies that instances should be used
  21357. * @returns a boolean indicating that the submesh is ready or not
  21358. */
  21359. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21360. /**
  21361. * Returns the material effect
  21362. * @returns the effect associated with the material
  21363. */
  21364. getEffect(): Nullable<Effect>;
  21365. /**
  21366. * Returns the current scene
  21367. * @returns a Scene
  21368. */
  21369. getScene(): Scene;
  21370. /**
  21371. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21372. */
  21373. protected _forceAlphaTest: boolean;
  21374. /**
  21375. * The transparency mode of the material.
  21376. */
  21377. protected _transparencyMode: Nullable<number>;
  21378. /**
  21379. * Gets the current transparency mode.
  21380. */
  21381. get transparencyMode(): Nullable<number>;
  21382. /**
  21383. * Sets the transparency mode of the material.
  21384. *
  21385. * | Value | Type | Description |
  21386. * | ----- | ----------------------------------- | ----------- |
  21387. * | 0 | OPAQUE | |
  21388. * | 1 | ALPHATEST | |
  21389. * | 2 | ALPHABLEND | |
  21390. * | 3 | ALPHATESTANDBLEND | |
  21391. *
  21392. */
  21393. set transparencyMode(value: Nullable<number>);
  21394. /**
  21395. * Returns true if alpha blending should be disabled.
  21396. */
  21397. protected get _disableAlphaBlending(): boolean;
  21398. /**
  21399. * Specifies whether or not this material should be rendered in alpha blend mode.
  21400. * @returns a boolean specifying if alpha blending is needed
  21401. */
  21402. needAlphaBlending(): boolean;
  21403. /**
  21404. * Specifies if the mesh will require alpha blending
  21405. * @param mesh defines the mesh to check
  21406. * @returns a boolean specifying if alpha blending is needed for the mesh
  21407. */
  21408. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21409. /**
  21410. * Specifies whether or not this material should be rendered in alpha test mode.
  21411. * @returns a boolean specifying if an alpha test is needed.
  21412. */
  21413. needAlphaTesting(): boolean;
  21414. /**
  21415. * Specifies if material alpha testing should be turned on for the mesh
  21416. * @param mesh defines the mesh to check
  21417. */
  21418. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21419. /**
  21420. * Gets the texture used for the alpha test
  21421. * @returns the texture to use for alpha testing
  21422. */
  21423. getAlphaTestTexture(): Nullable<BaseTexture>;
  21424. /**
  21425. * Marks the material to indicate that it needs to be re-calculated
  21426. */
  21427. markDirty(): void;
  21428. /** @hidden */
  21429. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21430. /**
  21431. * Binds the material to the mesh
  21432. * @param world defines the world transformation matrix
  21433. * @param mesh defines the mesh to bind the material to
  21434. */
  21435. bind(world: Matrix, mesh?: Mesh): void;
  21436. /**
  21437. * Binds the submesh to the material
  21438. * @param world defines the world transformation matrix
  21439. * @param mesh defines the mesh containing the submesh
  21440. * @param subMesh defines the submesh to bind the material to
  21441. */
  21442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21443. /**
  21444. * Binds the world matrix to the material
  21445. * @param world defines the world transformation matrix
  21446. */
  21447. bindOnlyWorldMatrix(world: Matrix): void;
  21448. /**
  21449. * Binds the scene's uniform buffer to the effect.
  21450. * @param effect defines the effect to bind to the scene uniform buffer
  21451. * @param sceneUbo defines the uniform buffer storing scene data
  21452. */
  21453. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21454. /**
  21455. * Binds the view matrix to the effect
  21456. * @param effect defines the effect to bind the view matrix to
  21457. */
  21458. bindView(effect: Effect): void;
  21459. /**
  21460. * Binds the view projection matrix to the effect
  21461. * @param effect defines the effect to bind the view projection matrix to
  21462. */
  21463. bindViewProjection(effect: Effect): void;
  21464. /**
  21465. * Processes to execute after binding the material to a mesh
  21466. * @param mesh defines the rendered mesh
  21467. */
  21468. protected _afterBind(mesh?: Mesh): void;
  21469. /**
  21470. * Unbinds the material from the mesh
  21471. */
  21472. unbind(): void;
  21473. /**
  21474. * Gets the active textures from the material
  21475. * @returns an array of textures
  21476. */
  21477. getActiveTextures(): BaseTexture[];
  21478. /**
  21479. * Specifies if the material uses a texture
  21480. * @param texture defines the texture to check against the material
  21481. * @returns a boolean specifying if the material uses the texture
  21482. */
  21483. hasTexture(texture: BaseTexture): boolean;
  21484. /**
  21485. * Makes a duplicate of the material, and gives it a new name
  21486. * @param name defines the new name for the duplicated material
  21487. * @returns the cloned material
  21488. */
  21489. clone(name: string): Nullable<Material>;
  21490. /**
  21491. * Gets the meshes bound to the material
  21492. * @returns an array of meshes bound to the material
  21493. */
  21494. getBindedMeshes(): AbstractMesh[];
  21495. /**
  21496. * Force shader compilation
  21497. * @param mesh defines the mesh associated with this material
  21498. * @param onCompiled defines a function to execute once the material is compiled
  21499. * @param options defines the options to configure the compilation
  21500. * @param onError defines a function to execute if the material fails compiling
  21501. */
  21502. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21503. /**
  21504. * Force shader compilation
  21505. * @param mesh defines the mesh that will use this material
  21506. * @param options defines additional options for compiling the shaders
  21507. * @returns a promise that resolves when the compilation completes
  21508. */
  21509. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21510. private static readonly _AllDirtyCallBack;
  21511. private static readonly _ImageProcessingDirtyCallBack;
  21512. private static readonly _TextureDirtyCallBack;
  21513. private static readonly _FresnelDirtyCallBack;
  21514. private static readonly _MiscDirtyCallBack;
  21515. private static readonly _LightsDirtyCallBack;
  21516. private static readonly _AttributeDirtyCallBack;
  21517. private static _FresnelAndMiscDirtyCallBack;
  21518. private static _TextureAndMiscDirtyCallBack;
  21519. private static readonly _DirtyCallbackArray;
  21520. private static readonly _RunDirtyCallBacks;
  21521. /**
  21522. * Marks a define in the material to indicate that it needs to be re-computed
  21523. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21524. */
  21525. markAsDirty(flag: number): void;
  21526. /**
  21527. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21528. * @param func defines a function which checks material defines against the submeshes
  21529. */
  21530. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21531. /**
  21532. * Indicates that we need to re-calculated for all submeshes
  21533. */
  21534. protected _markAllSubMeshesAsAllDirty(): void;
  21535. /**
  21536. * Indicates that image processing needs to be re-calculated for all submeshes
  21537. */
  21538. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21539. /**
  21540. * Indicates that textures need to be re-calculated for all submeshes
  21541. */
  21542. protected _markAllSubMeshesAsTexturesDirty(): void;
  21543. /**
  21544. * Indicates that fresnel needs to be re-calculated for all submeshes
  21545. */
  21546. protected _markAllSubMeshesAsFresnelDirty(): void;
  21547. /**
  21548. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21549. */
  21550. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21551. /**
  21552. * Indicates that lights need to be re-calculated for all submeshes
  21553. */
  21554. protected _markAllSubMeshesAsLightsDirty(): void;
  21555. /**
  21556. * Indicates that attributes need to be re-calculated for all submeshes
  21557. */
  21558. protected _markAllSubMeshesAsAttributesDirty(): void;
  21559. /**
  21560. * Indicates that misc needs to be re-calculated for all submeshes
  21561. */
  21562. protected _markAllSubMeshesAsMiscDirty(): void;
  21563. /**
  21564. * Indicates that textures and misc need to be re-calculated for all submeshes
  21565. */
  21566. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21567. /**
  21568. * Disposes the material
  21569. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21570. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21571. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21572. */
  21573. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21574. /** @hidden */
  21575. private releaseVertexArrayObject;
  21576. /**
  21577. * Serializes this material
  21578. * @returns the serialized material object
  21579. */
  21580. serialize(): any;
  21581. /**
  21582. * Creates a material from parsed material data
  21583. * @param parsedMaterial defines parsed material data
  21584. * @param scene defines the hosting scene
  21585. * @param rootUrl defines the root URL to use to load textures
  21586. * @returns a new material
  21587. */
  21588. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21589. }
  21590. }
  21591. declare module BABYLON {
  21592. /**
  21593. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21594. * separate meshes. This can be use to improve performances.
  21595. * @see http://doc.babylonjs.com/how_to/multi_materials
  21596. */
  21597. export class MultiMaterial extends Material {
  21598. private _subMaterials;
  21599. /**
  21600. * Gets or Sets the list of Materials used within the multi material.
  21601. * They need to be ordered according to the submeshes order in the associated mesh
  21602. */
  21603. get subMaterials(): Nullable<Material>[];
  21604. set subMaterials(value: Nullable<Material>[]);
  21605. /**
  21606. * Function used to align with Node.getChildren()
  21607. * @returns the list of Materials used within the multi material
  21608. */
  21609. getChildren(): Nullable<Material>[];
  21610. /**
  21611. * Instantiates a new Multi Material
  21612. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21613. * separate meshes. This can be use to improve performances.
  21614. * @see http://doc.babylonjs.com/how_to/multi_materials
  21615. * @param name Define the name in the scene
  21616. * @param scene Define the scene the material belongs to
  21617. */
  21618. constructor(name: string, scene: Scene);
  21619. private _hookArray;
  21620. /**
  21621. * Get one of the submaterial by its index in the submaterials array
  21622. * @param index The index to look the sub material at
  21623. * @returns The Material if the index has been defined
  21624. */
  21625. getSubMaterial(index: number): Nullable<Material>;
  21626. /**
  21627. * Get the list of active textures for the whole sub materials list.
  21628. * @returns All the textures that will be used during the rendering
  21629. */
  21630. getActiveTextures(): BaseTexture[];
  21631. /**
  21632. * Gets the current class name of the material e.g. "MultiMaterial"
  21633. * Mainly use in serialization.
  21634. * @returns the class name
  21635. */
  21636. getClassName(): string;
  21637. /**
  21638. * Checks if the material is ready to render the requested sub mesh
  21639. * @param mesh Define the mesh the submesh belongs to
  21640. * @param subMesh Define the sub mesh to look readyness for
  21641. * @param useInstances Define whether or not the material is used with instances
  21642. * @returns true if ready, otherwise false
  21643. */
  21644. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21645. /**
  21646. * Clones the current material and its related sub materials
  21647. * @param name Define the name of the newly cloned material
  21648. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21649. * @returns the cloned material
  21650. */
  21651. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21652. /**
  21653. * Serializes the materials into a JSON representation.
  21654. * @returns the JSON representation
  21655. */
  21656. serialize(): any;
  21657. /**
  21658. * Dispose the material and release its associated resources
  21659. * @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)
  21660. * @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)
  21661. * @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)
  21662. */
  21663. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21664. /**
  21665. * Creates a MultiMaterial from parsed MultiMaterial data.
  21666. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21667. * @param scene defines the hosting scene
  21668. * @returns a new MultiMaterial
  21669. */
  21670. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21671. }
  21672. }
  21673. declare module BABYLON {
  21674. /**
  21675. * Base class for submeshes
  21676. */
  21677. export class BaseSubMesh {
  21678. /** @hidden */
  21679. _materialDefines: Nullable<MaterialDefines>;
  21680. /** @hidden */
  21681. _materialEffect: Nullable<Effect>;
  21682. /**
  21683. * Gets material defines used by the effect associated to the sub mesh
  21684. */
  21685. get materialDefines(): Nullable<MaterialDefines>;
  21686. /**
  21687. * Sets material defines used by the effect associated to the sub mesh
  21688. */
  21689. set materialDefines(defines: Nullable<MaterialDefines>);
  21690. /**
  21691. * Gets associated effect
  21692. */
  21693. get effect(): Nullable<Effect>;
  21694. /**
  21695. * Sets associated effect (effect used to render this submesh)
  21696. * @param effect defines the effect to associate with
  21697. * @param defines defines the set of defines used to compile this effect
  21698. */
  21699. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21700. }
  21701. /**
  21702. * Defines a subdivision inside a mesh
  21703. */
  21704. export class SubMesh extends BaseSubMesh implements ICullable {
  21705. /** the material index to use */
  21706. materialIndex: number;
  21707. /** vertex index start */
  21708. verticesStart: number;
  21709. /** vertices count */
  21710. verticesCount: number;
  21711. /** index start */
  21712. indexStart: number;
  21713. /** indices count */
  21714. indexCount: number;
  21715. /** @hidden */
  21716. _linesIndexCount: number;
  21717. private _mesh;
  21718. private _renderingMesh;
  21719. private _boundingInfo;
  21720. private _linesIndexBuffer;
  21721. /** @hidden */
  21722. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21723. /** @hidden */
  21724. _trianglePlanes: Plane[];
  21725. /** @hidden */
  21726. _lastColliderTransformMatrix: Nullable<Matrix>;
  21727. /** @hidden */
  21728. _renderId: number;
  21729. /** @hidden */
  21730. _alphaIndex: number;
  21731. /** @hidden */
  21732. _distanceToCamera: number;
  21733. /** @hidden */
  21734. _id: number;
  21735. private _currentMaterial;
  21736. /**
  21737. * Add a new submesh to a mesh
  21738. * @param materialIndex defines the material index to use
  21739. * @param verticesStart defines vertex index start
  21740. * @param verticesCount defines vertices count
  21741. * @param indexStart defines index start
  21742. * @param indexCount defines indices count
  21743. * @param mesh defines the parent mesh
  21744. * @param renderingMesh defines an optional rendering mesh
  21745. * @param createBoundingBox defines if bounding box should be created for this submesh
  21746. * @returns the new submesh
  21747. */
  21748. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21749. /**
  21750. * Creates a new submesh
  21751. * @param materialIndex defines the material index to use
  21752. * @param verticesStart defines vertex index start
  21753. * @param verticesCount defines vertices count
  21754. * @param indexStart defines index start
  21755. * @param indexCount defines indices count
  21756. * @param mesh defines the parent mesh
  21757. * @param renderingMesh defines an optional rendering mesh
  21758. * @param createBoundingBox defines if bounding box should be created for this submesh
  21759. */
  21760. constructor(
  21761. /** the material index to use */
  21762. materialIndex: number,
  21763. /** vertex index start */
  21764. verticesStart: number,
  21765. /** vertices count */
  21766. verticesCount: number,
  21767. /** index start */
  21768. indexStart: number,
  21769. /** indices count */
  21770. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21771. /**
  21772. * Returns true if this submesh covers the entire parent mesh
  21773. * @ignorenaming
  21774. */
  21775. get IsGlobal(): boolean;
  21776. /**
  21777. * Returns the submesh BoudingInfo object
  21778. * @returns current bounding info (or mesh's one if the submesh is global)
  21779. */
  21780. getBoundingInfo(): BoundingInfo;
  21781. /**
  21782. * Sets the submesh BoundingInfo
  21783. * @param boundingInfo defines the new bounding info to use
  21784. * @returns the SubMesh
  21785. */
  21786. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21787. /**
  21788. * Returns the mesh of the current submesh
  21789. * @return the parent mesh
  21790. */
  21791. getMesh(): AbstractMesh;
  21792. /**
  21793. * Returns the rendering mesh of the submesh
  21794. * @returns the rendering mesh (could be different from parent mesh)
  21795. */
  21796. getRenderingMesh(): Mesh;
  21797. /**
  21798. * Returns the submesh material
  21799. * @returns null or the current material
  21800. */
  21801. getMaterial(): Nullable<Material>;
  21802. /**
  21803. * Sets a new updated BoundingInfo object to the submesh
  21804. * @param data defines an optional position array to use to determine the bounding info
  21805. * @returns the SubMesh
  21806. */
  21807. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21808. /** @hidden */
  21809. _checkCollision(collider: Collider): boolean;
  21810. /**
  21811. * Updates the submesh BoundingInfo
  21812. * @param world defines the world matrix to use to update the bounding info
  21813. * @returns the submesh
  21814. */
  21815. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21816. /**
  21817. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21818. * @param frustumPlanes defines the frustum planes
  21819. * @returns true if the submesh is intersecting with the frustum
  21820. */
  21821. isInFrustum(frustumPlanes: Plane[]): boolean;
  21822. /**
  21823. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21824. * @param frustumPlanes defines the frustum planes
  21825. * @returns true if the submesh is inside the frustum
  21826. */
  21827. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21828. /**
  21829. * Renders the submesh
  21830. * @param enableAlphaMode defines if alpha needs to be used
  21831. * @returns the submesh
  21832. */
  21833. render(enableAlphaMode: boolean): SubMesh;
  21834. /**
  21835. * @hidden
  21836. */
  21837. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21838. /**
  21839. * Checks if the submesh intersects with a ray
  21840. * @param ray defines the ray to test
  21841. * @returns true is the passed ray intersects the submesh bounding box
  21842. */
  21843. canIntersects(ray: Ray): boolean;
  21844. /**
  21845. * Intersects current submesh with a ray
  21846. * @param ray defines the ray to test
  21847. * @param positions defines mesh's positions array
  21848. * @param indices defines mesh's indices array
  21849. * @param fastCheck defines if only bounding info should be used
  21850. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21851. * @returns intersection info or null if no intersection
  21852. */
  21853. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21854. /** @hidden */
  21855. private _intersectLines;
  21856. /** @hidden */
  21857. private _intersectUnIndexedLines;
  21858. /** @hidden */
  21859. private _intersectTriangles;
  21860. /** @hidden */
  21861. private _intersectUnIndexedTriangles;
  21862. /** @hidden */
  21863. _rebuild(): void;
  21864. /**
  21865. * Creates a new submesh from the passed mesh
  21866. * @param newMesh defines the new hosting mesh
  21867. * @param newRenderingMesh defines an optional rendering mesh
  21868. * @returns the new submesh
  21869. */
  21870. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21871. /**
  21872. * Release associated resources
  21873. */
  21874. dispose(): void;
  21875. /**
  21876. * Gets the class name
  21877. * @returns the string "SubMesh".
  21878. */
  21879. getClassName(): string;
  21880. /**
  21881. * Creates a new submesh from indices data
  21882. * @param materialIndex the index of the main mesh material
  21883. * @param startIndex the index where to start the copy in the mesh indices array
  21884. * @param indexCount the number of indices to copy then from the startIndex
  21885. * @param mesh the main mesh to create the submesh from
  21886. * @param renderingMesh the optional rendering mesh
  21887. * @returns a new submesh
  21888. */
  21889. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21890. }
  21891. }
  21892. declare module BABYLON {
  21893. /**
  21894. * Class used to represent data loading progression
  21895. */
  21896. export class SceneLoaderFlags {
  21897. private static _ForceFullSceneLoadingForIncremental;
  21898. private static _ShowLoadingScreen;
  21899. private static _CleanBoneMatrixWeights;
  21900. private static _loggingLevel;
  21901. /**
  21902. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21903. */
  21904. static get ForceFullSceneLoadingForIncremental(): boolean;
  21905. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21906. /**
  21907. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21908. */
  21909. static get ShowLoadingScreen(): boolean;
  21910. static set ShowLoadingScreen(value: boolean);
  21911. /**
  21912. * Defines the current logging level (while loading the scene)
  21913. * @ignorenaming
  21914. */
  21915. static get loggingLevel(): number;
  21916. static set loggingLevel(value: number);
  21917. /**
  21918. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21919. */
  21920. static get CleanBoneMatrixWeights(): boolean;
  21921. static set CleanBoneMatrixWeights(value: boolean);
  21922. }
  21923. }
  21924. declare module BABYLON {
  21925. /**
  21926. * Class used to store geometry data (vertex buffers + index buffer)
  21927. */
  21928. export class Geometry implements IGetSetVerticesData {
  21929. /**
  21930. * Gets or sets the ID of the geometry
  21931. */
  21932. id: string;
  21933. /**
  21934. * Gets or sets the unique ID of the geometry
  21935. */
  21936. uniqueId: number;
  21937. /**
  21938. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21939. */
  21940. delayLoadState: number;
  21941. /**
  21942. * Gets the file containing the data to load when running in delay load state
  21943. */
  21944. delayLoadingFile: Nullable<string>;
  21945. /**
  21946. * Callback called when the geometry is updated
  21947. */
  21948. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21949. private _scene;
  21950. private _engine;
  21951. private _meshes;
  21952. private _totalVertices;
  21953. /** @hidden */
  21954. _indices: IndicesArray;
  21955. /** @hidden */
  21956. _vertexBuffers: {
  21957. [key: string]: VertexBuffer;
  21958. };
  21959. private _isDisposed;
  21960. private _extend;
  21961. private _boundingBias;
  21962. /** @hidden */
  21963. _delayInfo: Array<string>;
  21964. private _indexBuffer;
  21965. private _indexBufferIsUpdatable;
  21966. /** @hidden */
  21967. _boundingInfo: Nullable<BoundingInfo>;
  21968. /** @hidden */
  21969. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21970. /** @hidden */
  21971. _softwareSkinningFrameId: number;
  21972. private _vertexArrayObjects;
  21973. private _updatable;
  21974. /** @hidden */
  21975. _positions: Nullable<Vector3[]>;
  21976. /**
  21977. * 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
  21978. */
  21979. get boundingBias(): Vector2;
  21980. /**
  21981. * 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
  21982. */
  21983. set boundingBias(value: Vector2);
  21984. /**
  21985. * Static function used to attach a new empty geometry to a mesh
  21986. * @param mesh defines the mesh to attach the geometry to
  21987. * @returns the new Geometry
  21988. */
  21989. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21990. /** Get the list of meshes using this geometry */
  21991. get meshes(): Mesh[];
  21992. /**
  21993. * Creates a new geometry
  21994. * @param id defines the unique ID
  21995. * @param scene defines the hosting scene
  21996. * @param vertexData defines the VertexData used to get geometry data
  21997. * @param updatable defines if geometry must be updatable (false by default)
  21998. * @param mesh defines the mesh that will be associated with the geometry
  21999. */
  22000. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22001. /**
  22002. * Gets the current extend of the geometry
  22003. */
  22004. get extend(): {
  22005. minimum: Vector3;
  22006. maximum: Vector3;
  22007. };
  22008. /**
  22009. * Gets the hosting scene
  22010. * @returns the hosting Scene
  22011. */
  22012. getScene(): Scene;
  22013. /**
  22014. * Gets the hosting engine
  22015. * @returns the hosting Engine
  22016. */
  22017. getEngine(): Engine;
  22018. /**
  22019. * Defines if the geometry is ready to use
  22020. * @returns true if the geometry is ready to be used
  22021. */
  22022. isReady(): boolean;
  22023. /**
  22024. * Gets a value indicating that the geometry should not be serialized
  22025. */
  22026. get doNotSerialize(): boolean;
  22027. /** @hidden */
  22028. _rebuild(): void;
  22029. /**
  22030. * Affects all geometry data in one call
  22031. * @param vertexData defines the geometry data
  22032. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22033. */
  22034. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22035. /**
  22036. * Set specific vertex data
  22037. * @param kind defines the data kind (Position, normal, etc...)
  22038. * @param data defines the vertex data to use
  22039. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22040. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22041. */
  22042. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22043. /**
  22044. * Removes a specific vertex data
  22045. * @param kind defines the data kind (Position, normal, etc...)
  22046. */
  22047. removeVerticesData(kind: string): void;
  22048. /**
  22049. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22050. * @param buffer defines the vertex buffer to use
  22051. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22052. */
  22053. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22054. /**
  22055. * Update a specific vertex buffer
  22056. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22057. * It will do nothing if the buffer is not updatable
  22058. * @param kind defines the data kind (Position, normal, etc...)
  22059. * @param data defines the data to use
  22060. * @param offset defines the offset in the target buffer where to store the data
  22061. * @param useBytes set to true if the offset is in bytes
  22062. */
  22063. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22064. /**
  22065. * Update a specific vertex buffer
  22066. * This function will create a new buffer if the current one is not updatable
  22067. * @param kind defines the data kind (Position, normal, etc...)
  22068. * @param data defines the data to use
  22069. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22070. */
  22071. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22072. private _updateBoundingInfo;
  22073. /** @hidden */
  22074. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22075. /**
  22076. * Gets total number of vertices
  22077. * @returns the total number of vertices
  22078. */
  22079. getTotalVertices(): number;
  22080. /**
  22081. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22082. * @param kind defines the data kind (Position, normal, etc...)
  22083. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22084. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22085. * @returns a float array containing vertex data
  22086. */
  22087. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22088. /**
  22089. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @returns true if the vertex buffer with the specified kind is updatable
  22092. */
  22093. isVertexBufferUpdatable(kind: string): boolean;
  22094. /**
  22095. * Gets a specific vertex buffer
  22096. * @param kind defines the data kind (Position, normal, etc...)
  22097. * @returns a VertexBuffer
  22098. */
  22099. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22100. /**
  22101. * Returns all vertex buffers
  22102. * @return an object holding all vertex buffers indexed by kind
  22103. */
  22104. getVertexBuffers(): Nullable<{
  22105. [key: string]: VertexBuffer;
  22106. }>;
  22107. /**
  22108. * Gets a boolean indicating if specific vertex buffer is present
  22109. * @param kind defines the data kind (Position, normal, etc...)
  22110. * @returns true if data is present
  22111. */
  22112. isVerticesDataPresent(kind: string): boolean;
  22113. /**
  22114. * Gets a list of all attached data kinds (Position, normal, etc...)
  22115. * @returns a list of string containing all kinds
  22116. */
  22117. getVerticesDataKinds(): string[];
  22118. /**
  22119. * Update index buffer
  22120. * @param indices defines the indices to store in the index buffer
  22121. * @param offset defines the offset in the target buffer where to store the data
  22122. * @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)
  22123. */
  22124. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22125. /**
  22126. * Creates a new index buffer
  22127. * @param indices defines the indices to store in the index buffer
  22128. * @param totalVertices defines the total number of vertices (could be null)
  22129. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22130. */
  22131. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22132. /**
  22133. * Return the total number of indices
  22134. * @returns the total number of indices
  22135. */
  22136. getTotalIndices(): number;
  22137. /**
  22138. * Gets the index buffer array
  22139. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22140. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22141. * @returns the index buffer array
  22142. */
  22143. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22144. /**
  22145. * Gets the index buffer
  22146. * @return the index buffer
  22147. */
  22148. getIndexBuffer(): Nullable<DataBuffer>;
  22149. /** @hidden */
  22150. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22151. /**
  22152. * Release the associated resources for a specific mesh
  22153. * @param mesh defines the source mesh
  22154. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22155. */
  22156. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22157. /**
  22158. * Apply current geometry to a given mesh
  22159. * @param mesh defines the mesh to apply geometry to
  22160. */
  22161. applyToMesh(mesh: Mesh): void;
  22162. private _updateExtend;
  22163. private _applyToMesh;
  22164. private notifyUpdate;
  22165. /**
  22166. * Load the geometry if it was flagged as delay loaded
  22167. * @param scene defines the hosting scene
  22168. * @param onLoaded defines a callback called when the geometry is loaded
  22169. */
  22170. load(scene: Scene, onLoaded?: () => void): void;
  22171. private _queueLoad;
  22172. /**
  22173. * Invert the geometry to move from a right handed system to a left handed one.
  22174. */
  22175. toLeftHanded(): void;
  22176. /** @hidden */
  22177. _resetPointsArrayCache(): void;
  22178. /** @hidden */
  22179. _generatePointsArray(): boolean;
  22180. /**
  22181. * Gets a value indicating if the geometry is disposed
  22182. * @returns true if the geometry was disposed
  22183. */
  22184. isDisposed(): boolean;
  22185. private _disposeVertexArrayObjects;
  22186. /**
  22187. * Free all associated resources
  22188. */
  22189. dispose(): void;
  22190. /**
  22191. * Clone the current geometry into a new geometry
  22192. * @param id defines the unique ID of the new geometry
  22193. * @returns a new geometry object
  22194. */
  22195. copy(id: string): Geometry;
  22196. /**
  22197. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22198. * @return a JSON representation of the current geometry data (without the vertices data)
  22199. */
  22200. serialize(): any;
  22201. private toNumberArray;
  22202. /**
  22203. * Serialize all vertices data into a JSON oject
  22204. * @returns a JSON representation of the current geometry data
  22205. */
  22206. serializeVerticeData(): any;
  22207. /**
  22208. * Extracts a clone of a mesh geometry
  22209. * @param mesh defines the source mesh
  22210. * @param id defines the unique ID of the new geometry object
  22211. * @returns the new geometry object
  22212. */
  22213. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22214. /**
  22215. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22216. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22217. * Be aware Math.random() could cause collisions, but:
  22218. * "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"
  22219. * @returns a string containing a new GUID
  22220. */
  22221. static RandomId(): string;
  22222. /** @hidden */
  22223. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22224. private static _CleanMatricesWeights;
  22225. /**
  22226. * Create a new geometry from persisted data (Using .babylon file format)
  22227. * @param parsedVertexData defines the persisted data
  22228. * @param scene defines the hosting scene
  22229. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22230. * @returns the new geometry object
  22231. */
  22232. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22233. }
  22234. }
  22235. declare module BABYLON {
  22236. /**
  22237. * Define an interface for all classes that will get and set the data on vertices
  22238. */
  22239. export interface IGetSetVerticesData {
  22240. /**
  22241. * Gets a boolean indicating if specific vertex data is present
  22242. * @param kind defines the vertex data kind to use
  22243. * @returns true is data kind is present
  22244. */
  22245. isVerticesDataPresent(kind: string): boolean;
  22246. /**
  22247. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22248. * @param kind defines the data kind (Position, normal, etc...)
  22249. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22251. * @returns a float array containing vertex data
  22252. */
  22253. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22254. /**
  22255. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22256. * @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.
  22257. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22258. * @returns the indices array or an empty array if the mesh has no geometry
  22259. */
  22260. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22261. /**
  22262. * Set specific vertex data
  22263. * @param kind defines the data kind (Position, normal, etc...)
  22264. * @param data defines the vertex data to use
  22265. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22266. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22267. */
  22268. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22269. /**
  22270. * Update a specific associated vertex buffer
  22271. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22272. * - VertexBuffer.PositionKind
  22273. * - VertexBuffer.UVKind
  22274. * - VertexBuffer.UV2Kind
  22275. * - VertexBuffer.UV3Kind
  22276. * - VertexBuffer.UV4Kind
  22277. * - VertexBuffer.UV5Kind
  22278. * - VertexBuffer.UV6Kind
  22279. * - VertexBuffer.ColorKind
  22280. * - VertexBuffer.MatricesIndicesKind
  22281. * - VertexBuffer.MatricesIndicesExtraKind
  22282. * - VertexBuffer.MatricesWeightsKind
  22283. * - VertexBuffer.MatricesWeightsExtraKind
  22284. * @param data defines the data source
  22285. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22286. * @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)
  22287. */
  22288. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22289. /**
  22290. * Creates a new index buffer
  22291. * @param indices defines the indices to store in the index buffer
  22292. * @param totalVertices defines the total number of vertices (could be null)
  22293. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22294. */
  22295. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22296. }
  22297. /**
  22298. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22299. */
  22300. export class VertexData {
  22301. /**
  22302. * Mesh side orientation : usually the external or front surface
  22303. */
  22304. static readonly FRONTSIDE: number;
  22305. /**
  22306. * Mesh side orientation : usually the internal or back surface
  22307. */
  22308. static readonly BACKSIDE: number;
  22309. /**
  22310. * Mesh side orientation : both internal and external or front and back surfaces
  22311. */
  22312. static readonly DOUBLESIDE: number;
  22313. /**
  22314. * Mesh side orientation : by default, `FRONTSIDE`
  22315. */
  22316. static readonly DEFAULTSIDE: number;
  22317. /**
  22318. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22319. */
  22320. positions: Nullable<FloatArray>;
  22321. /**
  22322. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22323. */
  22324. normals: Nullable<FloatArray>;
  22325. /**
  22326. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22327. */
  22328. tangents: Nullable<FloatArray>;
  22329. /**
  22330. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22331. */
  22332. uvs: Nullable<FloatArray>;
  22333. /**
  22334. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22335. */
  22336. uvs2: Nullable<FloatArray>;
  22337. /**
  22338. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22339. */
  22340. uvs3: Nullable<FloatArray>;
  22341. /**
  22342. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22343. */
  22344. uvs4: Nullable<FloatArray>;
  22345. /**
  22346. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22347. */
  22348. uvs5: Nullable<FloatArray>;
  22349. /**
  22350. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22351. */
  22352. uvs6: Nullable<FloatArray>;
  22353. /**
  22354. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22355. */
  22356. colors: Nullable<FloatArray>;
  22357. /**
  22358. * 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).
  22359. */
  22360. matricesIndices: Nullable<FloatArray>;
  22361. /**
  22362. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22363. */
  22364. matricesWeights: Nullable<FloatArray>;
  22365. /**
  22366. * An array extending the number of possible indices
  22367. */
  22368. matricesIndicesExtra: Nullable<FloatArray>;
  22369. /**
  22370. * An array extending the number of possible weights when the number of indices is extended
  22371. */
  22372. matricesWeightsExtra: Nullable<FloatArray>;
  22373. /**
  22374. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22375. */
  22376. indices: Nullable<IndicesArray>;
  22377. /**
  22378. * Uses the passed data array to set the set the values for the specified kind of data
  22379. * @param data a linear array of floating numbers
  22380. * @param kind the type of data that is being set, eg positions, colors etc
  22381. */
  22382. set(data: FloatArray, kind: string): void;
  22383. /**
  22384. * Associates the vertexData to the passed Mesh.
  22385. * Sets it as updatable or not (default `false`)
  22386. * @param mesh the mesh the vertexData is applied to
  22387. * @param updatable when used and having the value true allows new data to update the vertexData
  22388. * @returns the VertexData
  22389. */
  22390. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22391. /**
  22392. * Associates the vertexData to the passed Geometry.
  22393. * Sets it as updatable or not (default `false`)
  22394. * @param geometry the geometry the vertexData is applied to
  22395. * @param updatable when used and having the value true allows new data to update the vertexData
  22396. * @returns VertexData
  22397. */
  22398. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22399. /**
  22400. * Updates the associated mesh
  22401. * @param mesh the mesh to be updated
  22402. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22403. * @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
  22404. * @returns VertexData
  22405. */
  22406. updateMesh(mesh: Mesh): VertexData;
  22407. /**
  22408. * Updates the associated geometry
  22409. * @param geometry the geometry to be updated
  22410. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22411. * @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
  22412. * @returns VertexData.
  22413. */
  22414. updateGeometry(geometry: Geometry): VertexData;
  22415. private _applyTo;
  22416. private _update;
  22417. /**
  22418. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22419. * @param matrix the transforming matrix
  22420. * @returns the VertexData
  22421. */
  22422. transform(matrix: Matrix): VertexData;
  22423. /**
  22424. * Merges the passed VertexData into the current one
  22425. * @param other the VertexData to be merged into the current one
  22426. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22427. * @returns the modified VertexData
  22428. */
  22429. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22430. private _mergeElement;
  22431. private _validate;
  22432. /**
  22433. * Serializes the VertexData
  22434. * @returns a serialized object
  22435. */
  22436. serialize(): any;
  22437. /**
  22438. * Extracts the vertexData from a mesh
  22439. * @param mesh the mesh from which to extract the VertexData
  22440. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22441. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22442. * @returns the object VertexData associated to the passed mesh
  22443. */
  22444. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22445. /**
  22446. * Extracts the vertexData from the geometry
  22447. * @param geometry the geometry from which to extract the VertexData
  22448. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22449. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22450. * @returns the object VertexData associated to the passed mesh
  22451. */
  22452. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22453. private static _ExtractFrom;
  22454. /**
  22455. * Creates the VertexData for a Ribbon
  22456. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22457. * * pathArray array of paths, each of which an array of successive Vector3
  22458. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22459. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22460. * * 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
  22461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22462. * * 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)
  22463. * * 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)
  22464. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22465. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22466. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22467. * @returns the VertexData of the ribbon
  22468. */
  22469. static CreateRibbon(options: {
  22470. pathArray: Vector3[][];
  22471. closeArray?: boolean;
  22472. closePath?: boolean;
  22473. offset?: number;
  22474. sideOrientation?: number;
  22475. frontUVs?: Vector4;
  22476. backUVs?: Vector4;
  22477. invertUV?: boolean;
  22478. uvs?: Vector2[];
  22479. colors?: Color4[];
  22480. }): VertexData;
  22481. /**
  22482. * Creates the VertexData for a box
  22483. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22484. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22485. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22486. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22487. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22488. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22489. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22491. * * 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)
  22492. * * 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)
  22493. * @returns the VertexData of the box
  22494. */
  22495. static CreateBox(options: {
  22496. size?: number;
  22497. width?: number;
  22498. height?: number;
  22499. depth?: number;
  22500. faceUV?: Vector4[];
  22501. faceColors?: Color4[];
  22502. sideOrientation?: number;
  22503. frontUVs?: Vector4;
  22504. backUVs?: Vector4;
  22505. }): VertexData;
  22506. /**
  22507. * Creates the VertexData for a tiled box
  22508. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22509. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22510. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22511. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22513. * @returns the VertexData of the box
  22514. */
  22515. static CreateTiledBox(options: {
  22516. pattern?: number;
  22517. width?: number;
  22518. height?: number;
  22519. depth?: number;
  22520. tileSize?: number;
  22521. tileWidth?: number;
  22522. tileHeight?: number;
  22523. alignHorizontal?: number;
  22524. alignVertical?: number;
  22525. faceUV?: Vector4[];
  22526. faceColors?: Color4[];
  22527. sideOrientation?: number;
  22528. }): VertexData;
  22529. /**
  22530. * Creates the VertexData for a tiled plane
  22531. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22532. * * pattern a limited pattern arrangement depending on the number
  22533. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22534. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22535. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22537. * * 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)
  22538. * * 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)
  22539. * @returns the VertexData of the tiled plane
  22540. */
  22541. static CreateTiledPlane(options: {
  22542. pattern?: number;
  22543. tileSize?: number;
  22544. tileWidth?: number;
  22545. tileHeight?: number;
  22546. size?: number;
  22547. width?: number;
  22548. height?: number;
  22549. alignHorizontal?: number;
  22550. alignVertical?: number;
  22551. sideOrientation?: number;
  22552. frontUVs?: Vector4;
  22553. backUVs?: Vector4;
  22554. }): VertexData;
  22555. /**
  22556. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22557. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22558. * * segments sets the number of horizontal strips optional, default 32
  22559. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22560. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22561. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22562. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22563. * * 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
  22564. * * 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
  22565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22566. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22567. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22568. * @returns the VertexData of the ellipsoid
  22569. */
  22570. static CreateSphere(options: {
  22571. segments?: number;
  22572. diameter?: number;
  22573. diameterX?: number;
  22574. diameterY?: number;
  22575. diameterZ?: number;
  22576. arc?: number;
  22577. slice?: number;
  22578. sideOrientation?: number;
  22579. frontUVs?: Vector4;
  22580. backUVs?: Vector4;
  22581. }): VertexData;
  22582. /**
  22583. * Creates the VertexData for a cylinder, cone or prism
  22584. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22585. * * height sets the height (y direction) of the cylinder, optional, default 2
  22586. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22587. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22588. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22589. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22590. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22591. * * 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
  22592. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22593. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22594. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22595. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22597. * * 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)
  22598. * * 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)
  22599. * @returns the VertexData of the cylinder, cone or prism
  22600. */
  22601. static CreateCylinder(options: {
  22602. height?: number;
  22603. diameterTop?: number;
  22604. diameterBottom?: number;
  22605. diameter?: number;
  22606. tessellation?: number;
  22607. subdivisions?: number;
  22608. arc?: number;
  22609. faceColors?: Color4[];
  22610. faceUV?: Vector4[];
  22611. hasRings?: boolean;
  22612. enclose?: boolean;
  22613. sideOrientation?: number;
  22614. frontUVs?: Vector4;
  22615. backUVs?: Vector4;
  22616. }): VertexData;
  22617. /**
  22618. * Creates the VertexData for a torus
  22619. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22620. * * diameter the diameter of the torus, optional default 1
  22621. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22622. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22623. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22624. * * 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)
  22625. * * 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)
  22626. * @returns the VertexData of the torus
  22627. */
  22628. static CreateTorus(options: {
  22629. diameter?: number;
  22630. thickness?: number;
  22631. tessellation?: number;
  22632. sideOrientation?: number;
  22633. frontUVs?: Vector4;
  22634. backUVs?: Vector4;
  22635. }): VertexData;
  22636. /**
  22637. * Creates the VertexData of the LineSystem
  22638. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22639. * - lines an array of lines, each line being an array of successive Vector3
  22640. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22641. * @returns the VertexData of the LineSystem
  22642. */
  22643. static CreateLineSystem(options: {
  22644. lines: Vector3[][];
  22645. colors?: Nullable<Color4[][]>;
  22646. }): VertexData;
  22647. /**
  22648. * Create the VertexData for a DashedLines
  22649. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22650. * - points an array successive Vector3
  22651. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22652. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22653. * - dashNb the intended total number of dashes, optional, default 200
  22654. * @returns the VertexData for the DashedLines
  22655. */
  22656. static CreateDashedLines(options: {
  22657. points: Vector3[];
  22658. dashSize?: number;
  22659. gapSize?: number;
  22660. dashNb?: number;
  22661. }): VertexData;
  22662. /**
  22663. * Creates the VertexData for a Ground
  22664. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22665. * - width the width (x direction) of the ground, optional, default 1
  22666. * - height the height (z direction) of the ground, optional, default 1
  22667. * - subdivisions the number of subdivisions per side, optional, default 1
  22668. * @returns the VertexData of the Ground
  22669. */
  22670. static CreateGround(options: {
  22671. width?: number;
  22672. height?: number;
  22673. subdivisions?: number;
  22674. subdivisionsX?: number;
  22675. subdivisionsY?: number;
  22676. }): VertexData;
  22677. /**
  22678. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22679. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22680. * * xmin the ground minimum X coordinate, optional, default -1
  22681. * * zmin the ground minimum Z coordinate, optional, default -1
  22682. * * xmax the ground maximum X coordinate, optional, default 1
  22683. * * zmax the ground maximum Z coordinate, optional, default 1
  22684. * * 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}
  22685. * * 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}
  22686. * @returns the VertexData of the TiledGround
  22687. */
  22688. static CreateTiledGround(options: {
  22689. xmin: number;
  22690. zmin: number;
  22691. xmax: number;
  22692. zmax: number;
  22693. subdivisions?: {
  22694. w: number;
  22695. h: number;
  22696. };
  22697. precision?: {
  22698. w: number;
  22699. h: number;
  22700. };
  22701. }): VertexData;
  22702. /**
  22703. * Creates the VertexData of the Ground designed from a heightmap
  22704. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22705. * * width the width (x direction) of the ground
  22706. * * height the height (z direction) of the ground
  22707. * * subdivisions the number of subdivisions per side
  22708. * * minHeight the minimum altitude on the ground, optional, default 0
  22709. * * maxHeight the maximum altitude on the ground, optional default 1
  22710. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22711. * * buffer the array holding the image color data
  22712. * * bufferWidth the width of image
  22713. * * bufferHeight the height of image
  22714. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22715. * @returns the VertexData of the Ground designed from a heightmap
  22716. */
  22717. static CreateGroundFromHeightMap(options: {
  22718. width: number;
  22719. height: number;
  22720. subdivisions: number;
  22721. minHeight: number;
  22722. maxHeight: number;
  22723. colorFilter: Color3;
  22724. buffer: Uint8Array;
  22725. bufferWidth: number;
  22726. bufferHeight: number;
  22727. alphaFilter: number;
  22728. }): VertexData;
  22729. /**
  22730. * Creates the VertexData for a Plane
  22731. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22732. * * size sets the width and height of the plane to the value of size, optional default 1
  22733. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22734. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22736. * * 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)
  22737. * * 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)
  22738. * @returns the VertexData of the box
  22739. */
  22740. static CreatePlane(options: {
  22741. size?: number;
  22742. width?: number;
  22743. height?: number;
  22744. sideOrientation?: number;
  22745. frontUVs?: Vector4;
  22746. backUVs?: Vector4;
  22747. }): VertexData;
  22748. /**
  22749. * Creates the VertexData of the Disc or regular Polygon
  22750. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22751. * * radius the radius of the disc, optional default 0.5
  22752. * * tessellation the number of polygon sides, optional, default 64
  22753. * * 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
  22754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22755. * * 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)
  22756. * * 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)
  22757. * @returns the VertexData of the box
  22758. */
  22759. static CreateDisc(options: {
  22760. radius?: number;
  22761. tessellation?: number;
  22762. arc?: number;
  22763. sideOrientation?: number;
  22764. frontUVs?: Vector4;
  22765. backUVs?: Vector4;
  22766. }): VertexData;
  22767. /**
  22768. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22769. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22770. * @param polygon a mesh built from polygonTriangulation.build()
  22771. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22772. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22773. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22774. * @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)
  22775. * @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)
  22776. * @returns the VertexData of the Polygon
  22777. */
  22778. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22779. /**
  22780. * Creates the VertexData of the IcoSphere
  22781. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22782. * * radius the radius of the IcoSphere, optional default 1
  22783. * * radiusX allows stretching in the x direction, optional, default radius
  22784. * * radiusY allows stretching in the y direction, optional, default radius
  22785. * * radiusZ allows stretching in the z direction, optional, default radius
  22786. * * flat when true creates a flat shaded mesh, optional, default true
  22787. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22789. * * 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)
  22790. * * 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)
  22791. * @returns the VertexData of the IcoSphere
  22792. */
  22793. static CreateIcoSphere(options: {
  22794. radius?: number;
  22795. radiusX?: number;
  22796. radiusY?: number;
  22797. radiusZ?: number;
  22798. flat?: boolean;
  22799. subdivisions?: number;
  22800. sideOrientation?: number;
  22801. frontUVs?: Vector4;
  22802. backUVs?: Vector4;
  22803. }): VertexData;
  22804. /**
  22805. * Creates the VertexData for a Polyhedron
  22806. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22807. * * type provided types are:
  22808. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22809. * * 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)
  22810. * * size the size of the IcoSphere, optional default 1
  22811. * * sizeX allows stretching in the x direction, optional, default size
  22812. * * sizeY allows stretching in the y direction, optional, default size
  22813. * * sizeZ allows stretching in the z direction, optional, default size
  22814. * * 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
  22815. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22816. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22817. * * flat when true creates a flat shaded mesh, optional, default true
  22818. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22820. * * 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)
  22821. * * 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)
  22822. * @returns the VertexData of the Polyhedron
  22823. */
  22824. static CreatePolyhedron(options: {
  22825. type?: number;
  22826. size?: number;
  22827. sizeX?: number;
  22828. sizeY?: number;
  22829. sizeZ?: number;
  22830. custom?: any;
  22831. faceUV?: Vector4[];
  22832. faceColors?: Color4[];
  22833. flat?: boolean;
  22834. sideOrientation?: number;
  22835. frontUVs?: Vector4;
  22836. backUVs?: Vector4;
  22837. }): VertexData;
  22838. /**
  22839. * Creates the VertexData for a TorusKnot
  22840. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22841. * * radius the radius of the torus knot, optional, default 2
  22842. * * tube the thickness of the tube, optional, default 0.5
  22843. * * radialSegments the number of sides on each tube segments, optional, default 32
  22844. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22845. * * p the number of windings around the z axis, optional, default 2
  22846. * * q the number of windings around the x axis, optional, default 3
  22847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22848. * * 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)
  22849. * * 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)
  22850. * @returns the VertexData of the Torus Knot
  22851. */
  22852. static CreateTorusKnot(options: {
  22853. radius?: number;
  22854. tube?: number;
  22855. radialSegments?: number;
  22856. tubularSegments?: number;
  22857. p?: number;
  22858. q?: number;
  22859. sideOrientation?: number;
  22860. frontUVs?: Vector4;
  22861. backUVs?: Vector4;
  22862. }): VertexData;
  22863. /**
  22864. * Compute normals for given positions and indices
  22865. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22866. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22867. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22868. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22869. * * facetNormals : optional array of facet normals (vector3)
  22870. * * facetPositions : optional array of facet positions (vector3)
  22871. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22872. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22873. * * bInfo : optional bounding info, required for facetPartitioning computation
  22874. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22875. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22876. * * useRightHandedSystem: optional boolean to for right handed system computation
  22877. * * depthSort : optional boolean to enable the facet depth sort computation
  22878. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22879. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22880. */
  22881. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22882. facetNormals?: any;
  22883. facetPositions?: any;
  22884. facetPartitioning?: any;
  22885. ratio?: number;
  22886. bInfo?: any;
  22887. bbSize?: Vector3;
  22888. subDiv?: any;
  22889. useRightHandedSystem?: boolean;
  22890. depthSort?: boolean;
  22891. distanceTo?: Vector3;
  22892. depthSortedFacets?: any;
  22893. }): void;
  22894. /** @hidden */
  22895. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22896. /**
  22897. * Applies VertexData created from the imported parameters to the geometry
  22898. * @param parsedVertexData the parsed data from an imported file
  22899. * @param geometry the geometry to apply the VertexData to
  22900. */
  22901. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22902. }
  22903. }
  22904. declare module BABYLON {
  22905. /**
  22906. * Defines a target to use with MorphTargetManager
  22907. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22908. */
  22909. export class MorphTarget implements IAnimatable {
  22910. /** defines the name of the target */
  22911. name: string;
  22912. /**
  22913. * Gets or sets the list of animations
  22914. */
  22915. animations: Animation[];
  22916. private _scene;
  22917. private _positions;
  22918. private _normals;
  22919. private _tangents;
  22920. private _uvs;
  22921. private _influence;
  22922. private _uniqueId;
  22923. /**
  22924. * Observable raised when the influence changes
  22925. */
  22926. onInfluenceChanged: Observable<boolean>;
  22927. /** @hidden */
  22928. _onDataLayoutChanged: Observable<void>;
  22929. /**
  22930. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22931. */
  22932. get influence(): number;
  22933. set influence(influence: number);
  22934. /**
  22935. * Gets or sets the id of the morph Target
  22936. */
  22937. id: string;
  22938. private _animationPropertiesOverride;
  22939. /**
  22940. * Gets or sets the animation properties override
  22941. */
  22942. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22943. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22944. /**
  22945. * Creates a new MorphTarget
  22946. * @param name defines the name of the target
  22947. * @param influence defines the influence to use
  22948. * @param scene defines the scene the morphtarget belongs to
  22949. */
  22950. constructor(
  22951. /** defines the name of the target */
  22952. name: string, influence?: number, scene?: Nullable<Scene>);
  22953. /**
  22954. * Gets the unique ID of this manager
  22955. */
  22956. get uniqueId(): number;
  22957. /**
  22958. * Gets a boolean defining if the target contains position data
  22959. */
  22960. get hasPositions(): boolean;
  22961. /**
  22962. * Gets a boolean defining if the target contains normal data
  22963. */
  22964. get hasNormals(): boolean;
  22965. /**
  22966. * Gets a boolean defining if the target contains tangent data
  22967. */
  22968. get hasTangents(): boolean;
  22969. /**
  22970. * Gets a boolean defining if the target contains texture coordinates data
  22971. */
  22972. get hasUVs(): boolean;
  22973. /**
  22974. * Affects position data to this target
  22975. * @param data defines the position data to use
  22976. */
  22977. setPositions(data: Nullable<FloatArray>): void;
  22978. /**
  22979. * Gets the position data stored in this target
  22980. * @returns a FloatArray containing the position data (or null if not present)
  22981. */
  22982. getPositions(): Nullable<FloatArray>;
  22983. /**
  22984. * Affects normal data to this target
  22985. * @param data defines the normal data to use
  22986. */
  22987. setNormals(data: Nullable<FloatArray>): void;
  22988. /**
  22989. * Gets the normal data stored in this target
  22990. * @returns a FloatArray containing the normal data (or null if not present)
  22991. */
  22992. getNormals(): Nullable<FloatArray>;
  22993. /**
  22994. * Affects tangent data to this target
  22995. * @param data defines the tangent data to use
  22996. */
  22997. setTangents(data: Nullable<FloatArray>): void;
  22998. /**
  22999. * Gets the tangent data stored in this target
  23000. * @returns a FloatArray containing the tangent data (or null if not present)
  23001. */
  23002. getTangents(): Nullable<FloatArray>;
  23003. /**
  23004. * Affects texture coordinates data to this target
  23005. * @param data defines the texture coordinates data to use
  23006. */
  23007. setUVs(data: Nullable<FloatArray>): void;
  23008. /**
  23009. * Gets the texture coordinates data stored in this target
  23010. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23011. */
  23012. getUVs(): Nullable<FloatArray>;
  23013. /**
  23014. * Clone the current target
  23015. * @returns a new MorphTarget
  23016. */
  23017. clone(): MorphTarget;
  23018. /**
  23019. * Serializes the current target into a Serialization object
  23020. * @returns the serialized object
  23021. */
  23022. serialize(): any;
  23023. /**
  23024. * Returns the string "MorphTarget"
  23025. * @returns "MorphTarget"
  23026. */
  23027. getClassName(): string;
  23028. /**
  23029. * Creates a new target from serialized data
  23030. * @param serializationObject defines the serialized data to use
  23031. * @returns a new MorphTarget
  23032. */
  23033. static Parse(serializationObject: any): MorphTarget;
  23034. /**
  23035. * Creates a MorphTarget from mesh data
  23036. * @param mesh defines the source mesh
  23037. * @param name defines the name to use for the new target
  23038. * @param influence defines the influence to attach to the target
  23039. * @returns a new MorphTarget
  23040. */
  23041. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23042. }
  23043. }
  23044. declare module BABYLON {
  23045. /**
  23046. * This class is used to deform meshes using morphing between different targets
  23047. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23048. */
  23049. export class MorphTargetManager {
  23050. private _targets;
  23051. private _targetInfluenceChangedObservers;
  23052. private _targetDataLayoutChangedObservers;
  23053. private _activeTargets;
  23054. private _scene;
  23055. private _influences;
  23056. private _supportsNormals;
  23057. private _supportsTangents;
  23058. private _supportsUVs;
  23059. private _vertexCount;
  23060. private _uniqueId;
  23061. private _tempInfluences;
  23062. /**
  23063. * Gets or sets a boolean indicating if normals must be morphed
  23064. */
  23065. enableNormalMorphing: boolean;
  23066. /**
  23067. * Gets or sets a boolean indicating if tangents must be morphed
  23068. */
  23069. enableTangentMorphing: boolean;
  23070. /**
  23071. * Gets or sets a boolean indicating if UV must be morphed
  23072. */
  23073. enableUVMorphing: boolean;
  23074. /**
  23075. * Creates a new MorphTargetManager
  23076. * @param scene defines the current scene
  23077. */
  23078. constructor(scene?: Nullable<Scene>);
  23079. /**
  23080. * Gets the unique ID of this manager
  23081. */
  23082. get uniqueId(): number;
  23083. /**
  23084. * Gets the number of vertices handled by this manager
  23085. */
  23086. get vertexCount(): number;
  23087. /**
  23088. * Gets a boolean indicating if this manager supports morphing of normals
  23089. */
  23090. get supportsNormals(): boolean;
  23091. /**
  23092. * Gets a boolean indicating if this manager supports morphing of tangents
  23093. */
  23094. get supportsTangents(): boolean;
  23095. /**
  23096. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23097. */
  23098. get supportsUVs(): boolean;
  23099. /**
  23100. * Gets the number of targets stored in this manager
  23101. */
  23102. get numTargets(): number;
  23103. /**
  23104. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23105. */
  23106. get numInfluencers(): number;
  23107. /**
  23108. * Gets the list of influences (one per target)
  23109. */
  23110. get influences(): Float32Array;
  23111. /**
  23112. * Gets the active target at specified index. An active target is a target with an influence > 0
  23113. * @param index defines the index to check
  23114. * @returns the requested target
  23115. */
  23116. getActiveTarget(index: number): MorphTarget;
  23117. /**
  23118. * Gets the target at specified index
  23119. * @param index defines the index to check
  23120. * @returns the requested target
  23121. */
  23122. getTarget(index: number): MorphTarget;
  23123. /**
  23124. * Add a new target to this manager
  23125. * @param target defines the target to add
  23126. */
  23127. addTarget(target: MorphTarget): void;
  23128. /**
  23129. * Removes a target from the manager
  23130. * @param target defines the target to remove
  23131. */
  23132. removeTarget(target: MorphTarget): void;
  23133. /**
  23134. * Clone the current manager
  23135. * @returns a new MorphTargetManager
  23136. */
  23137. clone(): MorphTargetManager;
  23138. /**
  23139. * Serializes the current manager into a Serialization object
  23140. * @returns the serialized object
  23141. */
  23142. serialize(): any;
  23143. private _syncActiveTargets;
  23144. /**
  23145. * Syncrhonize the targets with all the meshes using this morph target manager
  23146. */
  23147. synchronize(): void;
  23148. /**
  23149. * Creates a new MorphTargetManager from serialized data
  23150. * @param serializationObject defines the serialized data
  23151. * @param scene defines the hosting scene
  23152. * @returns the new MorphTargetManager
  23153. */
  23154. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23155. }
  23156. }
  23157. declare module BABYLON {
  23158. /**
  23159. * Class used to represent a specific level of detail of a mesh
  23160. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23161. */
  23162. export class MeshLODLevel {
  23163. /** Defines the distance where this level should start being displayed */
  23164. distance: number;
  23165. /** Defines the mesh to use to render this level */
  23166. mesh: Nullable<Mesh>;
  23167. /**
  23168. * Creates a new LOD level
  23169. * @param distance defines the distance where this level should star being displayed
  23170. * @param mesh defines the mesh to use to render this level
  23171. */
  23172. constructor(
  23173. /** Defines the distance where this level should start being displayed */
  23174. distance: number,
  23175. /** Defines the mesh to use to render this level */
  23176. mesh: Nullable<Mesh>);
  23177. }
  23178. }
  23179. declare module BABYLON {
  23180. /**
  23181. * Mesh representing the gorund
  23182. */
  23183. export class GroundMesh extends Mesh {
  23184. /** If octree should be generated */
  23185. generateOctree: boolean;
  23186. private _heightQuads;
  23187. /** @hidden */
  23188. _subdivisionsX: number;
  23189. /** @hidden */
  23190. _subdivisionsY: number;
  23191. /** @hidden */
  23192. _width: number;
  23193. /** @hidden */
  23194. _height: number;
  23195. /** @hidden */
  23196. _minX: number;
  23197. /** @hidden */
  23198. _maxX: number;
  23199. /** @hidden */
  23200. _minZ: number;
  23201. /** @hidden */
  23202. _maxZ: number;
  23203. constructor(name: string, scene: Scene);
  23204. /**
  23205. * "GroundMesh"
  23206. * @returns "GroundMesh"
  23207. */
  23208. getClassName(): string;
  23209. /**
  23210. * The minimum of x and y subdivisions
  23211. */
  23212. get subdivisions(): number;
  23213. /**
  23214. * X subdivisions
  23215. */
  23216. get subdivisionsX(): number;
  23217. /**
  23218. * Y subdivisions
  23219. */
  23220. get subdivisionsY(): number;
  23221. /**
  23222. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23223. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23224. * @param chunksCount the number of subdivisions for x and y
  23225. * @param octreeBlocksSize (Default: 32)
  23226. */
  23227. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23228. /**
  23229. * Returns a height (y) value in the Worl system :
  23230. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23231. * @param x x coordinate
  23232. * @param z z coordinate
  23233. * @returns the ground y position if (x, z) are outside the ground surface.
  23234. */
  23235. getHeightAtCoordinates(x: number, z: number): number;
  23236. /**
  23237. * Returns a normalized vector (Vector3) orthogonal to the ground
  23238. * at the ground coordinates (x, z) expressed in the World system.
  23239. * @param x x coordinate
  23240. * @param z z coordinate
  23241. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23242. */
  23243. getNormalAtCoordinates(x: number, z: number): Vector3;
  23244. /**
  23245. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23246. * at the ground coordinates (x, z) expressed in the World system.
  23247. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23248. * @param x x coordinate
  23249. * @param z z coordinate
  23250. * @param ref vector to store the result
  23251. * @returns the GroundMesh.
  23252. */
  23253. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23254. /**
  23255. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23256. * if the ground has been updated.
  23257. * This can be used in the render loop.
  23258. * @returns the GroundMesh.
  23259. */
  23260. updateCoordinateHeights(): GroundMesh;
  23261. private _getFacetAt;
  23262. private _initHeightQuads;
  23263. private _computeHeightQuads;
  23264. /**
  23265. * Serializes this ground mesh
  23266. * @param serializationObject object to write serialization to
  23267. */
  23268. serialize(serializationObject: any): void;
  23269. /**
  23270. * Parses a serialized ground mesh
  23271. * @param parsedMesh the serialized mesh
  23272. * @param scene the scene to create the ground mesh in
  23273. * @returns the created ground mesh
  23274. */
  23275. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23276. }
  23277. }
  23278. declare module BABYLON {
  23279. /**
  23280. * Interface for Physics-Joint data
  23281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23282. */
  23283. export interface PhysicsJointData {
  23284. /**
  23285. * The main pivot of the joint
  23286. */
  23287. mainPivot?: Vector3;
  23288. /**
  23289. * The connected pivot of the joint
  23290. */
  23291. connectedPivot?: Vector3;
  23292. /**
  23293. * The main axis of the joint
  23294. */
  23295. mainAxis?: Vector3;
  23296. /**
  23297. * The connected axis of the joint
  23298. */
  23299. connectedAxis?: Vector3;
  23300. /**
  23301. * The collision of the joint
  23302. */
  23303. collision?: boolean;
  23304. /**
  23305. * Native Oimo/Cannon/Energy data
  23306. */
  23307. nativeParams?: any;
  23308. }
  23309. /**
  23310. * This is a holder class for the physics joint created by the physics plugin
  23311. * It holds a set of functions to control the underlying joint
  23312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23313. */
  23314. export class PhysicsJoint {
  23315. /**
  23316. * The type of the physics joint
  23317. */
  23318. type: number;
  23319. /**
  23320. * The data for the physics joint
  23321. */
  23322. jointData: PhysicsJointData;
  23323. private _physicsJoint;
  23324. protected _physicsPlugin: IPhysicsEnginePlugin;
  23325. /**
  23326. * Initializes the physics joint
  23327. * @param type The type of the physics joint
  23328. * @param jointData The data for the physics joint
  23329. */
  23330. constructor(
  23331. /**
  23332. * The type of the physics joint
  23333. */
  23334. type: number,
  23335. /**
  23336. * The data for the physics joint
  23337. */
  23338. jointData: PhysicsJointData);
  23339. /**
  23340. * Gets the physics joint
  23341. */
  23342. get physicsJoint(): any;
  23343. /**
  23344. * Sets the physics joint
  23345. */
  23346. set physicsJoint(newJoint: any);
  23347. /**
  23348. * Sets the physics plugin
  23349. */
  23350. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23351. /**
  23352. * Execute a function that is physics-plugin specific.
  23353. * @param {Function} func the function that will be executed.
  23354. * It accepts two parameters: the physics world and the physics joint
  23355. */
  23356. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23357. /**
  23358. * Distance-Joint type
  23359. */
  23360. static DistanceJoint: number;
  23361. /**
  23362. * Hinge-Joint type
  23363. */
  23364. static HingeJoint: number;
  23365. /**
  23366. * Ball-and-Socket joint type
  23367. */
  23368. static BallAndSocketJoint: number;
  23369. /**
  23370. * Wheel-Joint type
  23371. */
  23372. static WheelJoint: number;
  23373. /**
  23374. * Slider-Joint type
  23375. */
  23376. static SliderJoint: number;
  23377. /**
  23378. * Prismatic-Joint type
  23379. */
  23380. static PrismaticJoint: number;
  23381. /**
  23382. * Universal-Joint type
  23383. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23384. */
  23385. static UniversalJoint: number;
  23386. /**
  23387. * Hinge-Joint 2 type
  23388. */
  23389. static Hinge2Joint: number;
  23390. /**
  23391. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23392. */
  23393. static PointToPointJoint: number;
  23394. /**
  23395. * Spring-Joint type
  23396. */
  23397. static SpringJoint: number;
  23398. /**
  23399. * Lock-Joint type
  23400. */
  23401. static LockJoint: number;
  23402. }
  23403. /**
  23404. * A class representing a physics distance joint
  23405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23406. */
  23407. export class DistanceJoint extends PhysicsJoint {
  23408. /**
  23409. *
  23410. * @param jointData The data for the Distance-Joint
  23411. */
  23412. constructor(jointData: DistanceJointData);
  23413. /**
  23414. * Update the predefined distance.
  23415. * @param maxDistance The maximum preferred distance
  23416. * @param minDistance The minimum preferred distance
  23417. */
  23418. updateDistance(maxDistance: number, minDistance?: number): void;
  23419. }
  23420. /**
  23421. * Represents a Motor-Enabled Joint
  23422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23423. */
  23424. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23425. /**
  23426. * Initializes the Motor-Enabled Joint
  23427. * @param type The type of the joint
  23428. * @param jointData The physica joint data for the joint
  23429. */
  23430. constructor(type: number, jointData: PhysicsJointData);
  23431. /**
  23432. * Set the motor values.
  23433. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23434. * @param force the force to apply
  23435. * @param maxForce max force for this motor.
  23436. */
  23437. setMotor(force?: number, maxForce?: number): void;
  23438. /**
  23439. * Set the motor's limits.
  23440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23441. * @param upperLimit The upper limit of the motor
  23442. * @param lowerLimit The lower limit of the motor
  23443. */
  23444. setLimit(upperLimit: number, lowerLimit?: number): void;
  23445. }
  23446. /**
  23447. * This class represents a single physics Hinge-Joint
  23448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23449. */
  23450. export class HingeJoint extends MotorEnabledJoint {
  23451. /**
  23452. * Initializes the Hinge-Joint
  23453. * @param jointData The joint data for the Hinge-Joint
  23454. */
  23455. constructor(jointData: PhysicsJointData);
  23456. /**
  23457. * Set the motor values.
  23458. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23459. * @param {number} force the force to apply
  23460. * @param {number} maxForce max force for this motor.
  23461. */
  23462. setMotor(force?: number, maxForce?: number): void;
  23463. /**
  23464. * Set the motor's limits.
  23465. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23466. * @param upperLimit The upper limit of the motor
  23467. * @param lowerLimit The lower limit of the motor
  23468. */
  23469. setLimit(upperLimit: number, lowerLimit?: number): void;
  23470. }
  23471. /**
  23472. * This class represents a dual hinge physics joint (same as wheel joint)
  23473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23474. */
  23475. export class Hinge2Joint extends MotorEnabledJoint {
  23476. /**
  23477. * Initializes the Hinge2-Joint
  23478. * @param jointData The joint data for the Hinge2-Joint
  23479. */
  23480. constructor(jointData: PhysicsJointData);
  23481. /**
  23482. * Set the motor values.
  23483. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23484. * @param {number} targetSpeed the speed the motor is to reach
  23485. * @param {number} maxForce max force for this motor.
  23486. * @param {motorIndex} the motor's index, 0 or 1.
  23487. */
  23488. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23489. /**
  23490. * Set the motor limits.
  23491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23492. * @param {number} upperLimit the upper limit
  23493. * @param {number} lowerLimit lower limit
  23494. * @param {motorIndex} the motor's index, 0 or 1.
  23495. */
  23496. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23497. }
  23498. /**
  23499. * Interface for a motor enabled joint
  23500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23501. */
  23502. export interface IMotorEnabledJoint {
  23503. /**
  23504. * Physics joint
  23505. */
  23506. physicsJoint: any;
  23507. /**
  23508. * Sets the motor of the motor-enabled joint
  23509. * @param force The force of the motor
  23510. * @param maxForce The maximum force of the motor
  23511. * @param motorIndex The index of the motor
  23512. */
  23513. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23514. /**
  23515. * Sets the limit of the motor
  23516. * @param upperLimit The upper limit of the motor
  23517. * @param lowerLimit The lower limit of the motor
  23518. * @param motorIndex The index of the motor
  23519. */
  23520. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23521. }
  23522. /**
  23523. * Joint data for a Distance-Joint
  23524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23525. */
  23526. export interface DistanceJointData extends PhysicsJointData {
  23527. /**
  23528. * Max distance the 2 joint objects can be apart
  23529. */
  23530. maxDistance: number;
  23531. }
  23532. /**
  23533. * Joint data from a spring joint
  23534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23535. */
  23536. export interface SpringJointData extends PhysicsJointData {
  23537. /**
  23538. * Length of the spring
  23539. */
  23540. length: number;
  23541. /**
  23542. * Stiffness of the spring
  23543. */
  23544. stiffness: number;
  23545. /**
  23546. * Damping of the spring
  23547. */
  23548. damping: number;
  23549. /** this callback will be called when applying the force to the impostors. */
  23550. forceApplicationCallback: () => void;
  23551. }
  23552. }
  23553. declare module BABYLON {
  23554. /**
  23555. * Holds the data for the raycast result
  23556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23557. */
  23558. export class PhysicsRaycastResult {
  23559. private _hasHit;
  23560. private _hitDistance;
  23561. private _hitNormalWorld;
  23562. private _hitPointWorld;
  23563. private _rayFromWorld;
  23564. private _rayToWorld;
  23565. /**
  23566. * Gets if there was a hit
  23567. */
  23568. get hasHit(): boolean;
  23569. /**
  23570. * Gets the distance from the hit
  23571. */
  23572. get hitDistance(): number;
  23573. /**
  23574. * Gets the hit normal/direction in the world
  23575. */
  23576. get hitNormalWorld(): Vector3;
  23577. /**
  23578. * Gets the hit point in the world
  23579. */
  23580. get hitPointWorld(): Vector3;
  23581. /**
  23582. * Gets the ray "start point" of the ray in the world
  23583. */
  23584. get rayFromWorld(): Vector3;
  23585. /**
  23586. * Gets the ray "end point" of the ray in the world
  23587. */
  23588. get rayToWorld(): Vector3;
  23589. /**
  23590. * Sets the hit data (normal & point in world space)
  23591. * @param hitNormalWorld defines the normal in world space
  23592. * @param hitPointWorld defines the point in world space
  23593. */
  23594. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23595. /**
  23596. * Sets the distance from the start point to the hit point
  23597. * @param distance
  23598. */
  23599. setHitDistance(distance: number): void;
  23600. /**
  23601. * Calculates the distance manually
  23602. */
  23603. calculateHitDistance(): void;
  23604. /**
  23605. * Resets all the values to default
  23606. * @param from The from point on world space
  23607. * @param to The to point on world space
  23608. */
  23609. reset(from?: Vector3, to?: Vector3): void;
  23610. }
  23611. /**
  23612. * Interface for the size containing width and height
  23613. */
  23614. interface IXYZ {
  23615. /**
  23616. * X
  23617. */
  23618. x: number;
  23619. /**
  23620. * Y
  23621. */
  23622. y: number;
  23623. /**
  23624. * Z
  23625. */
  23626. z: number;
  23627. }
  23628. }
  23629. declare module BABYLON {
  23630. /**
  23631. * Interface used to describe a physics joint
  23632. */
  23633. export interface PhysicsImpostorJoint {
  23634. /** Defines the main impostor to which the joint is linked */
  23635. mainImpostor: PhysicsImpostor;
  23636. /** Defines the impostor that is connected to the main impostor using this joint */
  23637. connectedImpostor: PhysicsImpostor;
  23638. /** Defines the joint itself */
  23639. joint: PhysicsJoint;
  23640. }
  23641. /** @hidden */
  23642. export interface IPhysicsEnginePlugin {
  23643. world: any;
  23644. name: string;
  23645. setGravity(gravity: Vector3): void;
  23646. setTimeStep(timeStep: number): void;
  23647. getTimeStep(): number;
  23648. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23649. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23650. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23651. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23652. removePhysicsBody(impostor: PhysicsImpostor): void;
  23653. generateJoint(joint: PhysicsImpostorJoint): void;
  23654. removeJoint(joint: PhysicsImpostorJoint): void;
  23655. isSupported(): boolean;
  23656. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23657. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23658. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23659. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23660. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23661. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23662. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23663. getBodyMass(impostor: PhysicsImpostor): number;
  23664. getBodyFriction(impostor: PhysicsImpostor): number;
  23665. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23666. getBodyRestitution(impostor: PhysicsImpostor): number;
  23667. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23668. getBodyPressure?(impostor: PhysicsImpostor): number;
  23669. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23670. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23671. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23672. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23673. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23674. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23675. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23676. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23677. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23678. sleepBody(impostor: PhysicsImpostor): void;
  23679. wakeUpBody(impostor: PhysicsImpostor): void;
  23680. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23681. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23682. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23683. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23684. getRadius(impostor: PhysicsImpostor): number;
  23685. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23686. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23687. dispose(): void;
  23688. }
  23689. /**
  23690. * Interface used to define a physics engine
  23691. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23692. */
  23693. export interface IPhysicsEngine {
  23694. /**
  23695. * Gets the gravity vector used by the simulation
  23696. */
  23697. gravity: Vector3;
  23698. /**
  23699. * Sets the gravity vector used by the simulation
  23700. * @param gravity defines the gravity vector to use
  23701. */
  23702. setGravity(gravity: Vector3): void;
  23703. /**
  23704. * Set the time step of the physics engine.
  23705. * Default is 1/60.
  23706. * To slow it down, enter 1/600 for example.
  23707. * To speed it up, 1/30
  23708. * @param newTimeStep the new timestep to apply to this world.
  23709. */
  23710. setTimeStep(newTimeStep: number): void;
  23711. /**
  23712. * Get the time step of the physics engine.
  23713. * @returns the current time step
  23714. */
  23715. getTimeStep(): number;
  23716. /**
  23717. * Set the sub time step of the physics engine.
  23718. * Default is 0 meaning there is no sub steps
  23719. * To increase physics resolution precision, set a small value (like 1 ms)
  23720. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23721. */
  23722. setSubTimeStep(subTimeStep: number): void;
  23723. /**
  23724. * Get the sub time step of the physics engine.
  23725. * @returns the current sub time step
  23726. */
  23727. getSubTimeStep(): number;
  23728. /**
  23729. * Release all resources
  23730. */
  23731. dispose(): void;
  23732. /**
  23733. * Gets the name of the current physics plugin
  23734. * @returns the name of the plugin
  23735. */
  23736. getPhysicsPluginName(): string;
  23737. /**
  23738. * Adding a new impostor for the impostor tracking.
  23739. * This will be done by the impostor itself.
  23740. * @param impostor the impostor to add
  23741. */
  23742. addImpostor(impostor: PhysicsImpostor): void;
  23743. /**
  23744. * Remove an impostor from the engine.
  23745. * This impostor and its mesh will not longer be updated by the physics engine.
  23746. * @param impostor the impostor to remove
  23747. */
  23748. removeImpostor(impostor: PhysicsImpostor): void;
  23749. /**
  23750. * Add a joint to the physics engine
  23751. * @param mainImpostor defines the main impostor to which the joint is added.
  23752. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23753. * @param joint defines the joint that will connect both impostors.
  23754. */
  23755. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23756. /**
  23757. * Removes a joint from the simulation
  23758. * @param mainImpostor defines the impostor used with the joint
  23759. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23760. * @param joint defines the joint to remove
  23761. */
  23762. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23763. /**
  23764. * Gets the current plugin used to run the simulation
  23765. * @returns current plugin
  23766. */
  23767. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23768. /**
  23769. * Gets the list of physic impostors
  23770. * @returns an array of PhysicsImpostor
  23771. */
  23772. getImpostors(): Array<PhysicsImpostor>;
  23773. /**
  23774. * Gets the impostor for a physics enabled object
  23775. * @param object defines the object impersonated by the impostor
  23776. * @returns the PhysicsImpostor or null if not found
  23777. */
  23778. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23779. /**
  23780. * Gets the impostor for a physics body object
  23781. * @param body defines physics body used by the impostor
  23782. * @returns the PhysicsImpostor or null if not found
  23783. */
  23784. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23785. /**
  23786. * Does a raycast in the physics world
  23787. * @param from when should the ray start?
  23788. * @param to when should the ray end?
  23789. * @returns PhysicsRaycastResult
  23790. */
  23791. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23792. /**
  23793. * Called by the scene. No need to call it.
  23794. * @param delta defines the timespam between frames
  23795. */
  23796. _step(delta: number): void;
  23797. }
  23798. }
  23799. declare module BABYLON {
  23800. /**
  23801. * The interface for the physics imposter parameters
  23802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23803. */
  23804. export interface PhysicsImpostorParameters {
  23805. /**
  23806. * The mass of the physics imposter
  23807. */
  23808. mass: number;
  23809. /**
  23810. * The friction of the physics imposter
  23811. */
  23812. friction?: number;
  23813. /**
  23814. * The coefficient of restitution of the physics imposter
  23815. */
  23816. restitution?: number;
  23817. /**
  23818. * The native options of the physics imposter
  23819. */
  23820. nativeOptions?: any;
  23821. /**
  23822. * Specifies if the parent should be ignored
  23823. */
  23824. ignoreParent?: boolean;
  23825. /**
  23826. * Specifies if bi-directional transformations should be disabled
  23827. */
  23828. disableBidirectionalTransformation?: boolean;
  23829. /**
  23830. * The pressure inside the physics imposter, soft object only
  23831. */
  23832. pressure?: number;
  23833. /**
  23834. * The stiffness the physics imposter, soft object only
  23835. */
  23836. stiffness?: number;
  23837. /**
  23838. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23839. */
  23840. velocityIterations?: number;
  23841. /**
  23842. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23843. */
  23844. positionIterations?: number;
  23845. /**
  23846. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23847. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23848. * Add to fix multiple points
  23849. */
  23850. fixedPoints?: number;
  23851. /**
  23852. * The collision margin around a soft object
  23853. */
  23854. margin?: number;
  23855. /**
  23856. * The collision margin around a soft object
  23857. */
  23858. damping?: number;
  23859. /**
  23860. * The path for a rope based on an extrusion
  23861. */
  23862. path?: any;
  23863. /**
  23864. * The shape of an extrusion used for a rope based on an extrusion
  23865. */
  23866. shape?: any;
  23867. }
  23868. /**
  23869. * Interface for a physics-enabled object
  23870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23871. */
  23872. export interface IPhysicsEnabledObject {
  23873. /**
  23874. * The position of the physics-enabled object
  23875. */
  23876. position: Vector3;
  23877. /**
  23878. * The rotation of the physics-enabled object
  23879. */
  23880. rotationQuaternion: Nullable<Quaternion>;
  23881. /**
  23882. * The scale of the physics-enabled object
  23883. */
  23884. scaling: Vector3;
  23885. /**
  23886. * The rotation of the physics-enabled object
  23887. */
  23888. rotation?: Vector3;
  23889. /**
  23890. * The parent of the physics-enabled object
  23891. */
  23892. parent?: any;
  23893. /**
  23894. * The bounding info of the physics-enabled object
  23895. * @returns The bounding info of the physics-enabled object
  23896. */
  23897. getBoundingInfo(): BoundingInfo;
  23898. /**
  23899. * Computes the world matrix
  23900. * @param force Specifies if the world matrix should be computed by force
  23901. * @returns A world matrix
  23902. */
  23903. computeWorldMatrix(force: boolean): Matrix;
  23904. /**
  23905. * Gets the world matrix
  23906. * @returns A world matrix
  23907. */
  23908. getWorldMatrix?(): Matrix;
  23909. /**
  23910. * Gets the child meshes
  23911. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23912. * @returns An array of abstract meshes
  23913. */
  23914. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23915. /**
  23916. * Gets the vertex data
  23917. * @param kind The type of vertex data
  23918. * @returns A nullable array of numbers, or a float32 array
  23919. */
  23920. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23921. /**
  23922. * Gets the indices from the mesh
  23923. * @returns A nullable array of index arrays
  23924. */
  23925. getIndices?(): Nullable<IndicesArray>;
  23926. /**
  23927. * Gets the scene from the mesh
  23928. * @returns the indices array or null
  23929. */
  23930. getScene?(): Scene;
  23931. /**
  23932. * Gets the absolute position from the mesh
  23933. * @returns the absolute position
  23934. */
  23935. getAbsolutePosition(): Vector3;
  23936. /**
  23937. * Gets the absolute pivot point from the mesh
  23938. * @returns the absolute pivot point
  23939. */
  23940. getAbsolutePivotPoint(): Vector3;
  23941. /**
  23942. * Rotates the mesh
  23943. * @param axis The axis of rotation
  23944. * @param amount The amount of rotation
  23945. * @param space The space of the rotation
  23946. * @returns The rotation transform node
  23947. */
  23948. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23949. /**
  23950. * Translates the mesh
  23951. * @param axis The axis of translation
  23952. * @param distance The distance of translation
  23953. * @param space The space of the translation
  23954. * @returns The transform node
  23955. */
  23956. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23957. /**
  23958. * Sets the absolute position of the mesh
  23959. * @param absolutePosition The absolute position of the mesh
  23960. * @returns The transform node
  23961. */
  23962. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23963. /**
  23964. * Gets the class name of the mesh
  23965. * @returns The class name
  23966. */
  23967. getClassName(): string;
  23968. }
  23969. /**
  23970. * Represents a physics imposter
  23971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23972. */
  23973. export class PhysicsImpostor {
  23974. /**
  23975. * The physics-enabled object used as the physics imposter
  23976. */
  23977. object: IPhysicsEnabledObject;
  23978. /**
  23979. * The type of the physics imposter
  23980. */
  23981. type: number;
  23982. private _options;
  23983. private _scene?;
  23984. /**
  23985. * The default object size of the imposter
  23986. */
  23987. static DEFAULT_OBJECT_SIZE: Vector3;
  23988. /**
  23989. * The identity quaternion of the imposter
  23990. */
  23991. static IDENTITY_QUATERNION: Quaternion;
  23992. /** @hidden */
  23993. _pluginData: any;
  23994. private _physicsEngine;
  23995. private _physicsBody;
  23996. private _bodyUpdateRequired;
  23997. private _onBeforePhysicsStepCallbacks;
  23998. private _onAfterPhysicsStepCallbacks;
  23999. /** @hidden */
  24000. _onPhysicsCollideCallbacks: Array<{
  24001. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24002. otherImpostors: Array<PhysicsImpostor>;
  24003. }>;
  24004. private _deltaPosition;
  24005. private _deltaRotation;
  24006. private _deltaRotationConjugated;
  24007. /** @hidden */
  24008. _isFromLine: boolean;
  24009. private _parent;
  24010. private _isDisposed;
  24011. private static _tmpVecs;
  24012. private static _tmpQuat;
  24013. /**
  24014. * Specifies if the physics imposter is disposed
  24015. */
  24016. get isDisposed(): boolean;
  24017. /**
  24018. * Gets the mass of the physics imposter
  24019. */
  24020. get mass(): number;
  24021. set mass(value: number);
  24022. /**
  24023. * Gets the coefficient of friction
  24024. */
  24025. get friction(): number;
  24026. /**
  24027. * Sets the coefficient of friction
  24028. */
  24029. set friction(value: number);
  24030. /**
  24031. * Gets the coefficient of restitution
  24032. */
  24033. get restitution(): number;
  24034. /**
  24035. * Sets the coefficient of restitution
  24036. */
  24037. set restitution(value: number);
  24038. /**
  24039. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24040. */
  24041. get pressure(): number;
  24042. /**
  24043. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24044. */
  24045. set pressure(value: number);
  24046. /**
  24047. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24048. */
  24049. get stiffness(): number;
  24050. /**
  24051. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24052. */
  24053. set stiffness(value: number);
  24054. /**
  24055. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24056. */
  24057. get velocityIterations(): number;
  24058. /**
  24059. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24060. */
  24061. set velocityIterations(value: number);
  24062. /**
  24063. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24064. */
  24065. get positionIterations(): number;
  24066. /**
  24067. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24068. */
  24069. set positionIterations(value: number);
  24070. /**
  24071. * The unique id of the physics imposter
  24072. * set by the physics engine when adding this impostor to the array
  24073. */
  24074. uniqueId: number;
  24075. /**
  24076. * @hidden
  24077. */
  24078. soft: boolean;
  24079. /**
  24080. * @hidden
  24081. */
  24082. segments: number;
  24083. private _joints;
  24084. /**
  24085. * Initializes the physics imposter
  24086. * @param object The physics-enabled object used as the physics imposter
  24087. * @param type The type of the physics imposter
  24088. * @param _options The options for the physics imposter
  24089. * @param _scene The Babylon scene
  24090. */
  24091. constructor(
  24092. /**
  24093. * The physics-enabled object used as the physics imposter
  24094. */
  24095. object: IPhysicsEnabledObject,
  24096. /**
  24097. * The type of the physics imposter
  24098. */
  24099. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24100. /**
  24101. * This function will completly initialize this impostor.
  24102. * It will create a new body - but only if this mesh has no parent.
  24103. * If it has, this impostor will not be used other than to define the impostor
  24104. * of the child mesh.
  24105. * @hidden
  24106. */
  24107. _init(): void;
  24108. private _getPhysicsParent;
  24109. /**
  24110. * Should a new body be generated.
  24111. * @returns boolean specifying if body initialization is required
  24112. */
  24113. isBodyInitRequired(): boolean;
  24114. /**
  24115. * Sets the updated scaling
  24116. * @param updated Specifies if the scaling is updated
  24117. */
  24118. setScalingUpdated(): void;
  24119. /**
  24120. * Force a regeneration of this or the parent's impostor's body.
  24121. * Use under cautious - This will remove all joints already implemented.
  24122. */
  24123. forceUpdate(): void;
  24124. /**
  24125. * Gets the body that holds this impostor. Either its own, or its parent.
  24126. */
  24127. get physicsBody(): any;
  24128. /**
  24129. * Get the parent of the physics imposter
  24130. * @returns Physics imposter or null
  24131. */
  24132. get parent(): Nullable<PhysicsImpostor>;
  24133. /**
  24134. * Sets the parent of the physics imposter
  24135. */
  24136. set parent(value: Nullable<PhysicsImpostor>);
  24137. /**
  24138. * Set the physics body. Used mainly by the physics engine/plugin
  24139. */
  24140. set physicsBody(physicsBody: any);
  24141. /**
  24142. * Resets the update flags
  24143. */
  24144. resetUpdateFlags(): void;
  24145. /**
  24146. * Gets the object extend size
  24147. * @returns the object extend size
  24148. */
  24149. getObjectExtendSize(): Vector3;
  24150. /**
  24151. * Gets the object center
  24152. * @returns The object center
  24153. */
  24154. getObjectCenter(): Vector3;
  24155. /**
  24156. * Get a specific parameter from the options parameters
  24157. * @param paramName The object parameter name
  24158. * @returns The object parameter
  24159. */
  24160. getParam(paramName: string): any;
  24161. /**
  24162. * Sets a specific parameter in the options given to the physics plugin
  24163. * @param paramName The parameter name
  24164. * @param value The value of the parameter
  24165. */
  24166. setParam(paramName: string, value: number): void;
  24167. /**
  24168. * Specifically change the body's mass option. Won't recreate the physics body object
  24169. * @param mass The mass of the physics imposter
  24170. */
  24171. setMass(mass: number): void;
  24172. /**
  24173. * Gets the linear velocity
  24174. * @returns linear velocity or null
  24175. */
  24176. getLinearVelocity(): Nullable<Vector3>;
  24177. /**
  24178. * Sets the linear velocity
  24179. * @param velocity linear velocity or null
  24180. */
  24181. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24182. /**
  24183. * Gets the angular velocity
  24184. * @returns angular velocity or null
  24185. */
  24186. getAngularVelocity(): Nullable<Vector3>;
  24187. /**
  24188. * Sets the angular velocity
  24189. * @param velocity The velocity or null
  24190. */
  24191. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24192. /**
  24193. * Execute a function with the physics plugin native code
  24194. * Provide a function the will have two variables - the world object and the physics body object
  24195. * @param func The function to execute with the physics plugin native code
  24196. */
  24197. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24198. /**
  24199. * Register a function that will be executed before the physics world is stepping forward
  24200. * @param func The function to execute before the physics world is stepped forward
  24201. */
  24202. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24203. /**
  24204. * Unregister a function that will be executed before the physics world is stepping forward
  24205. * @param func The function to execute before the physics world is stepped forward
  24206. */
  24207. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24208. /**
  24209. * Register a function that will be executed after the physics step
  24210. * @param func The function to execute after physics step
  24211. */
  24212. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24213. /**
  24214. * Unregisters a function that will be executed after the physics step
  24215. * @param func The function to execute after physics step
  24216. */
  24217. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24218. /**
  24219. * register a function that will be executed when this impostor collides against a different body
  24220. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24221. * @param func Callback that is executed on collision
  24222. */
  24223. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24224. /**
  24225. * Unregisters the physics imposter on contact
  24226. * @param collideAgainst The physics object to collide against
  24227. * @param func Callback to execute on collision
  24228. */
  24229. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24230. private _tmpQuat;
  24231. private _tmpQuat2;
  24232. /**
  24233. * Get the parent rotation
  24234. * @returns The parent rotation
  24235. */
  24236. getParentsRotation(): Quaternion;
  24237. /**
  24238. * this function is executed by the physics engine.
  24239. */
  24240. beforeStep: () => void;
  24241. /**
  24242. * this function is executed by the physics engine
  24243. */
  24244. afterStep: () => void;
  24245. /**
  24246. * Legacy collision detection event support
  24247. */
  24248. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24249. /**
  24250. * event and body object due to cannon's event-based architecture.
  24251. */
  24252. onCollide: (e: {
  24253. body: any;
  24254. }) => void;
  24255. /**
  24256. * Apply a force
  24257. * @param force The force to apply
  24258. * @param contactPoint The contact point for the force
  24259. * @returns The physics imposter
  24260. */
  24261. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24262. /**
  24263. * Apply an impulse
  24264. * @param force The impulse force
  24265. * @param contactPoint The contact point for the impulse force
  24266. * @returns The physics imposter
  24267. */
  24268. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24269. /**
  24270. * A help function to create a joint
  24271. * @param otherImpostor A physics imposter used to create a joint
  24272. * @param jointType The type of joint
  24273. * @param jointData The data for the joint
  24274. * @returns The physics imposter
  24275. */
  24276. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24277. /**
  24278. * Add a joint to this impostor with a different impostor
  24279. * @param otherImpostor A physics imposter used to add a joint
  24280. * @param joint The joint to add
  24281. * @returns The physics imposter
  24282. */
  24283. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24284. /**
  24285. * Add an anchor to a cloth impostor
  24286. * @param otherImpostor rigid impostor to anchor to
  24287. * @param width ratio across width from 0 to 1
  24288. * @param height ratio up height from 0 to 1
  24289. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24290. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24291. * @returns impostor the soft imposter
  24292. */
  24293. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24294. /**
  24295. * Add a hook to a rope impostor
  24296. * @param otherImpostor rigid impostor to anchor to
  24297. * @param length ratio across rope from 0 to 1
  24298. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24299. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24300. * @returns impostor the rope imposter
  24301. */
  24302. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24303. /**
  24304. * Will keep this body still, in a sleep mode.
  24305. * @returns the physics imposter
  24306. */
  24307. sleep(): PhysicsImpostor;
  24308. /**
  24309. * Wake the body up.
  24310. * @returns The physics imposter
  24311. */
  24312. wakeUp(): PhysicsImpostor;
  24313. /**
  24314. * Clones the physics imposter
  24315. * @param newObject The physics imposter clones to this physics-enabled object
  24316. * @returns A nullable physics imposter
  24317. */
  24318. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24319. /**
  24320. * Disposes the physics imposter
  24321. */
  24322. dispose(): void;
  24323. /**
  24324. * Sets the delta position
  24325. * @param position The delta position amount
  24326. */
  24327. setDeltaPosition(position: Vector3): void;
  24328. /**
  24329. * Sets the delta rotation
  24330. * @param rotation The delta rotation amount
  24331. */
  24332. setDeltaRotation(rotation: Quaternion): void;
  24333. /**
  24334. * Gets the box size of the physics imposter and stores the result in the input parameter
  24335. * @param result Stores the box size
  24336. * @returns The physics imposter
  24337. */
  24338. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24339. /**
  24340. * Gets the radius of the physics imposter
  24341. * @returns Radius of the physics imposter
  24342. */
  24343. getRadius(): number;
  24344. /**
  24345. * Sync a bone with this impostor
  24346. * @param bone The bone to sync to the impostor.
  24347. * @param boneMesh The mesh that the bone is influencing.
  24348. * @param jointPivot The pivot of the joint / bone in local space.
  24349. * @param distToJoint Optional distance from the impostor to the joint.
  24350. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24351. */
  24352. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24353. /**
  24354. * Sync impostor to a bone
  24355. * @param bone The bone that the impostor will be synced to.
  24356. * @param boneMesh The mesh that the bone is influencing.
  24357. * @param jointPivot The pivot of the joint / bone in local space.
  24358. * @param distToJoint Optional distance from the impostor to the joint.
  24359. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24360. * @param boneAxis Optional vector3 axis the bone is aligned with
  24361. */
  24362. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24363. /**
  24364. * No-Imposter type
  24365. */
  24366. static NoImpostor: number;
  24367. /**
  24368. * Sphere-Imposter type
  24369. */
  24370. static SphereImpostor: number;
  24371. /**
  24372. * Box-Imposter type
  24373. */
  24374. static BoxImpostor: number;
  24375. /**
  24376. * Plane-Imposter type
  24377. */
  24378. static PlaneImpostor: number;
  24379. /**
  24380. * Mesh-imposter type
  24381. */
  24382. static MeshImpostor: number;
  24383. /**
  24384. * Capsule-Impostor type (Ammo.js plugin only)
  24385. */
  24386. static CapsuleImpostor: number;
  24387. /**
  24388. * Cylinder-Imposter type
  24389. */
  24390. static CylinderImpostor: number;
  24391. /**
  24392. * Particle-Imposter type
  24393. */
  24394. static ParticleImpostor: number;
  24395. /**
  24396. * Heightmap-Imposter type
  24397. */
  24398. static HeightmapImpostor: number;
  24399. /**
  24400. * ConvexHull-Impostor type (Ammo.js plugin only)
  24401. */
  24402. static ConvexHullImpostor: number;
  24403. /**
  24404. * Custom-Imposter type (Ammo.js plugin only)
  24405. */
  24406. static CustomImpostor: number;
  24407. /**
  24408. * Rope-Imposter type
  24409. */
  24410. static RopeImpostor: number;
  24411. /**
  24412. * Cloth-Imposter type
  24413. */
  24414. static ClothImpostor: number;
  24415. /**
  24416. * Softbody-Imposter type
  24417. */
  24418. static SoftbodyImpostor: number;
  24419. }
  24420. }
  24421. declare module BABYLON {
  24422. /**
  24423. * @hidden
  24424. **/
  24425. export class _CreationDataStorage {
  24426. closePath?: boolean;
  24427. closeArray?: boolean;
  24428. idx: number[];
  24429. dashSize: number;
  24430. gapSize: number;
  24431. path3D: Path3D;
  24432. pathArray: Vector3[][];
  24433. arc: number;
  24434. radius: number;
  24435. cap: number;
  24436. tessellation: number;
  24437. }
  24438. /**
  24439. * @hidden
  24440. **/
  24441. class _InstanceDataStorage {
  24442. visibleInstances: any;
  24443. batchCache: _InstancesBatch;
  24444. instancesBufferSize: number;
  24445. instancesBuffer: Nullable<Buffer>;
  24446. instancesData: Float32Array;
  24447. overridenInstanceCount: number;
  24448. isFrozen: boolean;
  24449. previousBatch: Nullable<_InstancesBatch>;
  24450. hardwareInstancedRendering: boolean;
  24451. sideOrientation: number;
  24452. manualUpdate: boolean;
  24453. }
  24454. /**
  24455. * @hidden
  24456. **/
  24457. export class _InstancesBatch {
  24458. mustReturn: boolean;
  24459. visibleInstances: Nullable<InstancedMesh[]>[];
  24460. renderSelf: boolean[];
  24461. hardwareInstancedRendering: boolean[];
  24462. }
  24463. /**
  24464. * Class used to represent renderable models
  24465. */
  24466. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24467. /**
  24468. * Mesh side orientation : usually the external or front surface
  24469. */
  24470. static readonly FRONTSIDE: number;
  24471. /**
  24472. * Mesh side orientation : usually the internal or back surface
  24473. */
  24474. static readonly BACKSIDE: number;
  24475. /**
  24476. * Mesh side orientation : both internal and external or front and back surfaces
  24477. */
  24478. static readonly DOUBLESIDE: number;
  24479. /**
  24480. * Mesh side orientation : by default, `FRONTSIDE`
  24481. */
  24482. static readonly DEFAULTSIDE: number;
  24483. /**
  24484. * Mesh cap setting : no cap
  24485. */
  24486. static readonly NO_CAP: number;
  24487. /**
  24488. * Mesh cap setting : one cap at the beginning of the mesh
  24489. */
  24490. static readonly CAP_START: number;
  24491. /**
  24492. * Mesh cap setting : one cap at the end of the mesh
  24493. */
  24494. static readonly CAP_END: number;
  24495. /**
  24496. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24497. */
  24498. static readonly CAP_ALL: number;
  24499. /**
  24500. * Mesh pattern setting : no flip or rotate
  24501. */
  24502. static readonly NO_FLIP: number;
  24503. /**
  24504. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24505. */
  24506. static readonly FLIP_TILE: number;
  24507. /**
  24508. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24509. */
  24510. static readonly ROTATE_TILE: number;
  24511. /**
  24512. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24513. */
  24514. static readonly FLIP_ROW: number;
  24515. /**
  24516. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24517. */
  24518. static readonly ROTATE_ROW: number;
  24519. /**
  24520. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24521. */
  24522. static readonly FLIP_N_ROTATE_TILE: number;
  24523. /**
  24524. * Mesh pattern setting : rotate pattern and rotate
  24525. */
  24526. static readonly FLIP_N_ROTATE_ROW: number;
  24527. /**
  24528. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24529. */
  24530. static readonly CENTER: number;
  24531. /**
  24532. * Mesh tile positioning : part tiles on left
  24533. */
  24534. static readonly LEFT: number;
  24535. /**
  24536. * Mesh tile positioning : part tiles on right
  24537. */
  24538. static readonly RIGHT: number;
  24539. /**
  24540. * Mesh tile positioning : part tiles on top
  24541. */
  24542. static readonly TOP: number;
  24543. /**
  24544. * Mesh tile positioning : part tiles on bottom
  24545. */
  24546. static readonly BOTTOM: number;
  24547. /**
  24548. * Gets the default side orientation.
  24549. * @param orientation the orientation to value to attempt to get
  24550. * @returns the default orientation
  24551. * @hidden
  24552. */
  24553. static _GetDefaultSideOrientation(orientation?: number): number;
  24554. private _internalMeshDataInfo;
  24555. /**
  24556. * An event triggered before rendering the mesh
  24557. */
  24558. get onBeforeRenderObservable(): Observable<Mesh>;
  24559. /**
  24560. * An event triggered before binding the mesh
  24561. */
  24562. get onBeforeBindObservable(): Observable<Mesh>;
  24563. /**
  24564. * An event triggered after rendering the mesh
  24565. */
  24566. get onAfterRenderObservable(): Observable<Mesh>;
  24567. /**
  24568. * An event triggered before drawing the mesh
  24569. */
  24570. get onBeforeDrawObservable(): Observable<Mesh>;
  24571. private _onBeforeDrawObserver;
  24572. /**
  24573. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24574. */
  24575. set onBeforeDraw(callback: () => void);
  24576. get hasInstances(): boolean;
  24577. /**
  24578. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24579. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24580. */
  24581. delayLoadState: number;
  24582. /**
  24583. * Gets the list of instances created from this mesh
  24584. * it is not supposed to be modified manually.
  24585. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24586. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24587. */
  24588. instances: InstancedMesh[];
  24589. /**
  24590. * Gets the file containing delay loading data for this mesh
  24591. */
  24592. delayLoadingFile: string;
  24593. /** @hidden */
  24594. _binaryInfo: any;
  24595. /**
  24596. * User defined function used to change how LOD level selection is done
  24597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24598. */
  24599. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24600. /**
  24601. * Gets or sets the morph target manager
  24602. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24603. */
  24604. get morphTargetManager(): Nullable<MorphTargetManager>;
  24605. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24606. /** @hidden */
  24607. _creationDataStorage: Nullable<_CreationDataStorage>;
  24608. /** @hidden */
  24609. _geometry: Nullable<Geometry>;
  24610. /** @hidden */
  24611. _delayInfo: Array<string>;
  24612. /** @hidden */
  24613. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24614. /** @hidden */
  24615. _instanceDataStorage: _InstanceDataStorage;
  24616. private _effectiveMaterial;
  24617. /** @hidden */
  24618. _shouldGenerateFlatShading: boolean;
  24619. /** @hidden */
  24620. _originalBuilderSideOrientation: number;
  24621. /**
  24622. * Use this property to change the original side orientation defined at construction time
  24623. */
  24624. overrideMaterialSideOrientation: Nullable<number>;
  24625. /**
  24626. * Gets the source mesh (the one used to clone this one from)
  24627. */
  24628. get source(): Nullable<Mesh>;
  24629. /**
  24630. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24631. */
  24632. get isUnIndexed(): boolean;
  24633. set isUnIndexed(value: boolean);
  24634. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24635. get worldMatrixInstancedBuffer(): Float32Array;
  24636. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24637. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24638. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24639. /**
  24640. * @constructor
  24641. * @param name The value used by scene.getMeshByName() to do a lookup.
  24642. * @param scene The scene to add this mesh to.
  24643. * @param parent The parent of this mesh, if it has one
  24644. * @param source An optional Mesh from which geometry is shared, cloned.
  24645. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24646. * When false, achieved by calling a clone(), also passing False.
  24647. * This will make creation of children, recursive.
  24648. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24649. */
  24650. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24651. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24652. doNotInstantiate: boolean;
  24653. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24654. /**
  24655. * Gets the class name
  24656. * @returns the string "Mesh".
  24657. */
  24658. getClassName(): string;
  24659. /** @hidden */
  24660. get _isMesh(): boolean;
  24661. /**
  24662. * Returns a description of this mesh
  24663. * @param fullDetails define if full details about this mesh must be used
  24664. * @returns a descriptive string representing this mesh
  24665. */
  24666. toString(fullDetails?: boolean): string;
  24667. /** @hidden */
  24668. _unBindEffect(): void;
  24669. /**
  24670. * Gets a boolean indicating if this mesh has LOD
  24671. */
  24672. get hasLODLevels(): boolean;
  24673. /**
  24674. * Gets the list of MeshLODLevel associated with the current mesh
  24675. * @returns an array of MeshLODLevel
  24676. */
  24677. getLODLevels(): MeshLODLevel[];
  24678. private _sortLODLevels;
  24679. /**
  24680. * Add a mesh as LOD level triggered at the given distance.
  24681. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24682. * @param distance The distance from the center of the object to show this level
  24683. * @param mesh The mesh to be added as LOD level (can be null)
  24684. * @return This mesh (for chaining)
  24685. */
  24686. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24687. /**
  24688. * Returns the LOD level mesh at the passed distance or null if not found.
  24689. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24690. * @param distance The distance from the center of the object to show this level
  24691. * @returns a Mesh or `null`
  24692. */
  24693. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24694. /**
  24695. * Remove a mesh from the LOD array
  24696. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24697. * @param mesh defines the mesh to be removed
  24698. * @return This mesh (for chaining)
  24699. */
  24700. removeLODLevel(mesh: Mesh): Mesh;
  24701. /**
  24702. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24703. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24704. * @param camera defines the camera to use to compute distance
  24705. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24706. * @return This mesh (for chaining)
  24707. */
  24708. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24709. /**
  24710. * Gets the mesh internal Geometry object
  24711. */
  24712. get geometry(): Nullable<Geometry>;
  24713. /**
  24714. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24715. * @returns the total number of vertices
  24716. */
  24717. getTotalVertices(): number;
  24718. /**
  24719. * Returns the content of an associated vertex buffer
  24720. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24721. * - VertexBuffer.PositionKind
  24722. * - VertexBuffer.UVKind
  24723. * - VertexBuffer.UV2Kind
  24724. * - VertexBuffer.UV3Kind
  24725. * - VertexBuffer.UV4Kind
  24726. * - VertexBuffer.UV5Kind
  24727. * - VertexBuffer.UV6Kind
  24728. * - VertexBuffer.ColorKind
  24729. * - VertexBuffer.MatricesIndicesKind
  24730. * - VertexBuffer.MatricesIndicesExtraKind
  24731. * - VertexBuffer.MatricesWeightsKind
  24732. * - VertexBuffer.MatricesWeightsExtraKind
  24733. * @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
  24734. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24735. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24736. */
  24737. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24738. /**
  24739. * Returns the mesh VertexBuffer object from the requested `kind`
  24740. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24741. * - VertexBuffer.PositionKind
  24742. * - VertexBuffer.NormalKind
  24743. * - VertexBuffer.UVKind
  24744. * - VertexBuffer.UV2Kind
  24745. * - VertexBuffer.UV3Kind
  24746. * - VertexBuffer.UV4Kind
  24747. * - VertexBuffer.UV5Kind
  24748. * - VertexBuffer.UV6Kind
  24749. * - VertexBuffer.ColorKind
  24750. * - VertexBuffer.MatricesIndicesKind
  24751. * - VertexBuffer.MatricesIndicesExtraKind
  24752. * - VertexBuffer.MatricesWeightsKind
  24753. * - VertexBuffer.MatricesWeightsExtraKind
  24754. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24755. */
  24756. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24757. /**
  24758. * Tests if a specific vertex buffer is associated with this mesh
  24759. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24760. * - VertexBuffer.PositionKind
  24761. * - VertexBuffer.NormalKind
  24762. * - VertexBuffer.UVKind
  24763. * - VertexBuffer.UV2Kind
  24764. * - VertexBuffer.UV3Kind
  24765. * - VertexBuffer.UV4Kind
  24766. * - VertexBuffer.UV5Kind
  24767. * - VertexBuffer.UV6Kind
  24768. * - VertexBuffer.ColorKind
  24769. * - VertexBuffer.MatricesIndicesKind
  24770. * - VertexBuffer.MatricesIndicesExtraKind
  24771. * - VertexBuffer.MatricesWeightsKind
  24772. * - VertexBuffer.MatricesWeightsExtraKind
  24773. * @returns a boolean
  24774. */
  24775. isVerticesDataPresent(kind: string): boolean;
  24776. /**
  24777. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24778. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24779. * - VertexBuffer.PositionKind
  24780. * - VertexBuffer.UVKind
  24781. * - VertexBuffer.UV2Kind
  24782. * - VertexBuffer.UV3Kind
  24783. * - VertexBuffer.UV4Kind
  24784. * - VertexBuffer.UV5Kind
  24785. * - VertexBuffer.UV6Kind
  24786. * - VertexBuffer.ColorKind
  24787. * - VertexBuffer.MatricesIndicesKind
  24788. * - VertexBuffer.MatricesIndicesExtraKind
  24789. * - VertexBuffer.MatricesWeightsKind
  24790. * - VertexBuffer.MatricesWeightsExtraKind
  24791. * @returns a boolean
  24792. */
  24793. isVertexBufferUpdatable(kind: string): boolean;
  24794. /**
  24795. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24796. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24797. * - VertexBuffer.PositionKind
  24798. * - VertexBuffer.NormalKind
  24799. * - VertexBuffer.UVKind
  24800. * - VertexBuffer.UV2Kind
  24801. * - VertexBuffer.UV3Kind
  24802. * - VertexBuffer.UV4Kind
  24803. * - VertexBuffer.UV5Kind
  24804. * - VertexBuffer.UV6Kind
  24805. * - VertexBuffer.ColorKind
  24806. * - VertexBuffer.MatricesIndicesKind
  24807. * - VertexBuffer.MatricesIndicesExtraKind
  24808. * - VertexBuffer.MatricesWeightsKind
  24809. * - VertexBuffer.MatricesWeightsExtraKind
  24810. * @returns an array of strings
  24811. */
  24812. getVerticesDataKinds(): string[];
  24813. /**
  24814. * Returns a positive integer : the total number of indices in this mesh geometry.
  24815. * @returns the numner of indices or zero if the mesh has no geometry.
  24816. */
  24817. getTotalIndices(): number;
  24818. /**
  24819. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24820. * @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.
  24821. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24822. * @returns the indices array or an empty array if the mesh has no geometry
  24823. */
  24824. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24825. get isBlocked(): boolean;
  24826. /**
  24827. * Determine if the current mesh is ready to be rendered
  24828. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24829. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24830. * @returns true if all associated assets are ready (material, textures, shaders)
  24831. */
  24832. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24833. /**
  24834. * 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.
  24835. */
  24836. get areNormalsFrozen(): boolean;
  24837. /**
  24838. * 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.
  24839. * @returns the current mesh
  24840. */
  24841. freezeNormals(): Mesh;
  24842. /**
  24843. * 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
  24844. * @returns the current mesh
  24845. */
  24846. unfreezeNormals(): Mesh;
  24847. /**
  24848. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24849. */
  24850. set overridenInstanceCount(count: number);
  24851. /** @hidden */
  24852. _preActivate(): Mesh;
  24853. /** @hidden */
  24854. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24855. /** @hidden */
  24856. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24857. /**
  24858. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24859. * This means the mesh underlying bounding box and sphere are recomputed.
  24860. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24861. * @returns the current mesh
  24862. */
  24863. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24864. /** @hidden */
  24865. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24866. /**
  24867. * This function will subdivide the mesh into multiple submeshes
  24868. * @param count defines the expected number of submeshes
  24869. */
  24870. subdivide(count: number): void;
  24871. /**
  24872. * Copy a FloatArray into a specific associated vertex buffer
  24873. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24874. * - VertexBuffer.PositionKind
  24875. * - VertexBuffer.UVKind
  24876. * - VertexBuffer.UV2Kind
  24877. * - VertexBuffer.UV3Kind
  24878. * - VertexBuffer.UV4Kind
  24879. * - VertexBuffer.UV5Kind
  24880. * - VertexBuffer.UV6Kind
  24881. * - VertexBuffer.ColorKind
  24882. * - VertexBuffer.MatricesIndicesKind
  24883. * - VertexBuffer.MatricesIndicesExtraKind
  24884. * - VertexBuffer.MatricesWeightsKind
  24885. * - VertexBuffer.MatricesWeightsExtraKind
  24886. * @param data defines the data source
  24887. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24888. * @param stride defines the data stride size (can be null)
  24889. * @returns the current mesh
  24890. */
  24891. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24892. /**
  24893. * Delete a vertex buffer associated with this mesh
  24894. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24895. * - VertexBuffer.PositionKind
  24896. * - VertexBuffer.UVKind
  24897. * - VertexBuffer.UV2Kind
  24898. * - VertexBuffer.UV3Kind
  24899. * - VertexBuffer.UV4Kind
  24900. * - VertexBuffer.UV5Kind
  24901. * - VertexBuffer.UV6Kind
  24902. * - VertexBuffer.ColorKind
  24903. * - VertexBuffer.MatricesIndicesKind
  24904. * - VertexBuffer.MatricesIndicesExtraKind
  24905. * - VertexBuffer.MatricesWeightsKind
  24906. * - VertexBuffer.MatricesWeightsExtraKind
  24907. */
  24908. removeVerticesData(kind: string): void;
  24909. /**
  24910. * Flags an associated vertex buffer as updatable
  24911. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24912. * - VertexBuffer.PositionKind
  24913. * - VertexBuffer.UVKind
  24914. * - VertexBuffer.UV2Kind
  24915. * - VertexBuffer.UV3Kind
  24916. * - VertexBuffer.UV4Kind
  24917. * - VertexBuffer.UV5Kind
  24918. * - VertexBuffer.UV6Kind
  24919. * - VertexBuffer.ColorKind
  24920. * - VertexBuffer.MatricesIndicesKind
  24921. * - VertexBuffer.MatricesIndicesExtraKind
  24922. * - VertexBuffer.MatricesWeightsKind
  24923. * - VertexBuffer.MatricesWeightsExtraKind
  24924. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24925. */
  24926. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24927. /**
  24928. * Sets the mesh global Vertex Buffer
  24929. * @param buffer defines the buffer to use
  24930. * @returns the current mesh
  24931. */
  24932. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24933. /**
  24934. * Update a specific associated vertex buffer
  24935. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24936. * - VertexBuffer.PositionKind
  24937. * - VertexBuffer.UVKind
  24938. * - VertexBuffer.UV2Kind
  24939. * - VertexBuffer.UV3Kind
  24940. * - VertexBuffer.UV4Kind
  24941. * - VertexBuffer.UV5Kind
  24942. * - VertexBuffer.UV6Kind
  24943. * - VertexBuffer.ColorKind
  24944. * - VertexBuffer.MatricesIndicesKind
  24945. * - VertexBuffer.MatricesIndicesExtraKind
  24946. * - VertexBuffer.MatricesWeightsKind
  24947. * - VertexBuffer.MatricesWeightsExtraKind
  24948. * @param data defines the data source
  24949. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24950. * @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)
  24951. * @returns the current mesh
  24952. */
  24953. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24954. /**
  24955. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24956. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24957. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24958. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24959. * @returns the current mesh
  24960. */
  24961. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24962. /**
  24963. * Creates a un-shared specific occurence of the geometry for the mesh.
  24964. * @returns the current mesh
  24965. */
  24966. makeGeometryUnique(): Mesh;
  24967. /**
  24968. * Set the index buffer of this mesh
  24969. * @param indices defines the source data
  24970. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24971. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24972. * @returns the current mesh
  24973. */
  24974. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24975. /**
  24976. * Update the current index buffer
  24977. * @param indices defines the source data
  24978. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24979. * @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)
  24980. * @returns the current mesh
  24981. */
  24982. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24983. /**
  24984. * Invert the geometry to move from a right handed system to a left handed one.
  24985. * @returns the current mesh
  24986. */
  24987. toLeftHanded(): Mesh;
  24988. /** @hidden */
  24989. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24990. /** @hidden */
  24991. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24992. /**
  24993. * Registers for this mesh a javascript function called just before the rendering process
  24994. * @param func defines the function to call before rendering this mesh
  24995. * @returns the current mesh
  24996. */
  24997. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24998. /**
  24999. * Disposes a previously registered javascript function called before the rendering
  25000. * @param func defines the function to remove
  25001. * @returns the current mesh
  25002. */
  25003. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25004. /**
  25005. * Registers for this mesh a javascript function called just after the rendering is complete
  25006. * @param func defines the function to call after rendering this mesh
  25007. * @returns the current mesh
  25008. */
  25009. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25010. /**
  25011. * Disposes a previously registered javascript function called after the rendering.
  25012. * @param func defines the function to remove
  25013. * @returns the current mesh
  25014. */
  25015. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25016. /** @hidden */
  25017. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25018. /** @hidden */
  25019. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25020. /** @hidden */
  25021. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25022. /** @hidden */
  25023. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25024. /** @hidden */
  25025. _rebuild(): void;
  25026. /** @hidden */
  25027. _freeze(): void;
  25028. /** @hidden */
  25029. _unFreeze(): void;
  25030. /**
  25031. * 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
  25032. * @param subMesh defines the subMesh to render
  25033. * @param enableAlphaMode defines if alpha mode can be changed
  25034. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25035. * @returns the current mesh
  25036. */
  25037. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25038. private _onBeforeDraw;
  25039. /**
  25040. * Renormalize the mesh and patch it up if there are no weights
  25041. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25042. * However in the case of zero weights then we set just a single influence to 1.
  25043. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25044. */
  25045. cleanMatrixWeights(): void;
  25046. private normalizeSkinFourWeights;
  25047. private normalizeSkinWeightsAndExtra;
  25048. /**
  25049. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25050. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25051. * the user know there was an issue with importing the mesh
  25052. * @returns a validation object with skinned, valid and report string
  25053. */
  25054. validateSkinning(): {
  25055. skinned: boolean;
  25056. valid: boolean;
  25057. report: string;
  25058. };
  25059. /** @hidden */
  25060. _checkDelayState(): Mesh;
  25061. private _queueLoad;
  25062. /**
  25063. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25064. * A mesh is in the frustum if its bounding box intersects the frustum
  25065. * @param frustumPlanes defines the frustum to test
  25066. * @returns true if the mesh is in the frustum planes
  25067. */
  25068. isInFrustum(frustumPlanes: Plane[]): boolean;
  25069. /**
  25070. * Sets the mesh material by the material or multiMaterial `id` property
  25071. * @param id is a string identifying the material or the multiMaterial
  25072. * @returns the current mesh
  25073. */
  25074. setMaterialByID(id: string): Mesh;
  25075. /**
  25076. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25077. * @returns an array of IAnimatable
  25078. */
  25079. getAnimatables(): IAnimatable[];
  25080. /**
  25081. * Modifies the mesh geometry according to the passed transformation matrix.
  25082. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25083. * The mesh normals are modified using the same transformation.
  25084. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25085. * @param transform defines the transform matrix to use
  25086. * @see http://doc.babylonjs.com/resources/baking_transformations
  25087. * @returns the current mesh
  25088. */
  25089. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25090. /**
  25091. * Modifies the mesh geometry according to its own current World Matrix.
  25092. * The mesh World Matrix is then reset.
  25093. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25094. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25095. * @see http://doc.babylonjs.com/resources/baking_transformations
  25096. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25097. * @returns the current mesh
  25098. */
  25099. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25100. /** @hidden */
  25101. get _positions(): Nullable<Vector3[]>;
  25102. /** @hidden */
  25103. _resetPointsArrayCache(): Mesh;
  25104. /** @hidden */
  25105. _generatePointsArray(): boolean;
  25106. /**
  25107. * Returns a new Mesh object generated from the current mesh properties.
  25108. * This method must not get confused with createInstance()
  25109. * @param name is a string, the name given to the new mesh
  25110. * @param newParent can be any Node object (default `null`)
  25111. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25112. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25113. * @returns a new mesh
  25114. */
  25115. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25116. /**
  25117. * Releases resources associated with this mesh.
  25118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25120. */
  25121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25122. /** @hidden */
  25123. _disposeInstanceSpecificData(): void;
  25124. /**
  25125. * Modifies the mesh geometry according to a displacement map.
  25126. * 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.
  25127. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25128. * @param url is a string, the URL from the image file is to be downloaded.
  25129. * @param minHeight is the lower limit of the displacement.
  25130. * @param maxHeight is the upper limit of the displacement.
  25131. * @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.
  25132. * @param uvOffset is an optional vector2 used to offset UV.
  25133. * @param uvScale is an optional vector2 used to scale UV.
  25134. * @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.
  25135. * @returns the Mesh.
  25136. */
  25137. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25138. /**
  25139. * Modifies the mesh geometry according to a displacementMap buffer.
  25140. * 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.
  25141. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25142. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25143. * @param heightMapWidth is the width of the buffer image.
  25144. * @param heightMapHeight is the height of the buffer image.
  25145. * @param minHeight is the lower limit of the displacement.
  25146. * @param maxHeight is the upper limit of the displacement.
  25147. * @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.
  25148. * @param uvOffset is an optional vector2 used to offset UV.
  25149. * @param uvScale is an optional vector2 used to scale UV.
  25150. * @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.
  25151. * @returns the Mesh.
  25152. */
  25153. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25154. /**
  25155. * Modify the mesh to get a flat shading rendering.
  25156. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25157. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25158. * @returns current mesh
  25159. */
  25160. convertToFlatShadedMesh(): Mesh;
  25161. /**
  25162. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25163. * In other words, more vertices, no more indices and a single bigger VBO.
  25164. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25165. * @returns current mesh
  25166. */
  25167. convertToUnIndexedMesh(): Mesh;
  25168. /**
  25169. * Inverses facet orientations.
  25170. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25171. * @param flipNormals will also inverts the normals
  25172. * @returns current mesh
  25173. */
  25174. flipFaces(flipNormals?: boolean): Mesh;
  25175. /**
  25176. * Increase the number of facets and hence vertices in a mesh
  25177. * Vertex normals are interpolated from existing vertex normals
  25178. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25179. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25180. */
  25181. increaseVertices(numberPerEdge: number): void;
  25182. /**
  25183. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25184. * This will undo any application of covertToFlatShadedMesh
  25185. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25186. */
  25187. forceSharedVertices(): void;
  25188. /** @hidden */
  25189. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25190. /** @hidden */
  25191. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25192. /**
  25193. * Creates a new InstancedMesh object from the mesh model.
  25194. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25195. * @param name defines the name of the new instance
  25196. * @returns a new InstancedMesh
  25197. */
  25198. createInstance(name: string): InstancedMesh;
  25199. /**
  25200. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25201. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25202. * @returns the current mesh
  25203. */
  25204. synchronizeInstances(): Mesh;
  25205. /**
  25206. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25207. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25208. * This should be used together with the simplification to avoid disappearing triangles.
  25209. * @param successCallback an optional success callback to be called after the optimization finished.
  25210. * @returns the current mesh
  25211. */
  25212. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25213. /**
  25214. * Serialize current mesh
  25215. * @param serializationObject defines the object which will receive the serialization data
  25216. */
  25217. serialize(serializationObject: any): void;
  25218. /** @hidden */
  25219. _syncGeometryWithMorphTargetManager(): void;
  25220. /** @hidden */
  25221. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25222. /**
  25223. * Returns a new Mesh object parsed from the source provided.
  25224. * @param parsedMesh is the source
  25225. * @param scene defines the hosting scene
  25226. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25227. * @returns a new Mesh
  25228. */
  25229. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25230. /**
  25231. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25232. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25233. * @param name defines the name of the mesh to create
  25234. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25235. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25236. * @param closePath creates a seam between the first and the last points of each path of the path array
  25237. * @param offset is taken in account only if the `pathArray` is containing a single path
  25238. * @param scene defines the hosting scene
  25239. * @param updatable defines if the mesh must be flagged as updatable
  25240. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25241. * @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)
  25242. * @returns a new Mesh
  25243. */
  25244. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25245. /**
  25246. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25247. * @param name defines the name of the mesh to create
  25248. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25249. * @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
  25250. * @param scene defines the hosting scene
  25251. * @param updatable defines if the mesh must be flagged as updatable
  25252. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25253. * @returns a new Mesh
  25254. */
  25255. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25256. /**
  25257. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25258. * @param name defines the name of the mesh to create
  25259. * @param size sets the size (float) of each box side (default 1)
  25260. * @param scene defines the hosting scene
  25261. * @param updatable defines if the mesh must be flagged as updatable
  25262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25263. * @returns a new Mesh
  25264. */
  25265. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25266. /**
  25267. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25270. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25271. * @param scene defines the hosting scene
  25272. * @param updatable defines if the mesh must be flagged as updatable
  25273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25274. * @returns a new Mesh
  25275. */
  25276. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25277. /**
  25278. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25279. * @param name defines the name of the mesh to create
  25280. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25281. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25282. * @param scene defines the hosting scene
  25283. * @returns a new Mesh
  25284. */
  25285. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25286. /**
  25287. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25288. * @param name defines the name of the mesh to create
  25289. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25290. * @param diameterTop set the top cap diameter (floats, default 1)
  25291. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25292. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25293. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25294. * @param scene defines the hosting scene
  25295. * @param updatable defines if the mesh must be flagged as updatable
  25296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25297. * @returns a new Mesh
  25298. */
  25299. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25300. /**
  25301. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25302. * @param name defines the name of the mesh to create
  25303. * @param diameter sets the diameter size (float) of the torus (default 1)
  25304. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25305. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25306. * @param scene defines the hosting scene
  25307. * @param updatable defines if the mesh must be flagged as updatable
  25308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25309. * @returns a new Mesh
  25310. */
  25311. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25312. /**
  25313. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25314. * @param name defines the name of the mesh to create
  25315. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25316. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25317. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25318. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25319. * @param p the number of windings on X axis (positive integers, default 2)
  25320. * @param q the number of windings on Y axis (positive integers, default 3)
  25321. * @param scene defines the hosting scene
  25322. * @param updatable defines if the mesh must be flagged as updatable
  25323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25327. /**
  25328. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25329. * @param name defines the name of the mesh to create
  25330. * @param points is an array successive Vector3
  25331. * @param scene defines the hosting scene
  25332. * @param updatable defines if the mesh must be flagged as updatable
  25333. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  25334. * @returns a new Mesh
  25335. */
  25336. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25337. /**
  25338. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25339. * @param name defines the name of the mesh to create
  25340. * @param points is an array successive Vector3
  25341. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25342. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25343. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25344. * @param scene defines the hosting scene
  25345. * @param updatable defines if the mesh must be flagged as updatable
  25346. * @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)
  25347. * @returns a new Mesh
  25348. */
  25349. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25350. /**
  25351. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25352. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25353. * 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.
  25354. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25355. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25356. * Remember you can only change the shape positions, not their number when updating a polygon.
  25357. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25358. * @param name defines the name of the mesh to create
  25359. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25360. * @param scene defines the hosting scene
  25361. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25362. * @param updatable defines if the mesh must be flagged as updatable
  25363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25364. * @param earcutInjection can be used to inject your own earcut reference
  25365. * @returns a new Mesh
  25366. */
  25367. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25368. /**
  25369. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25370. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25371. * @param name defines the name of the mesh to create
  25372. * @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
  25373. * @param depth defines the height of extrusion
  25374. * @param scene defines the hosting scene
  25375. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25376. * @param updatable defines if the mesh must be flagged as updatable
  25377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25378. * @param earcutInjection can be used to inject your own earcut reference
  25379. * @returns a new Mesh
  25380. */
  25381. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25382. /**
  25383. * Creates an extruded shape mesh.
  25384. * 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
  25385. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25386. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25387. * @param name defines the name of the mesh to create
  25388. * @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
  25389. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25390. * @param scale is the value to scale the shape
  25391. * @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
  25392. * @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
  25393. * @param scene defines the hosting scene
  25394. * @param updatable defines if the mesh must be flagged as updatable
  25395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25396. * @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)
  25397. * @returns a new Mesh
  25398. */
  25399. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25400. /**
  25401. * Creates an custom extruded shape mesh.
  25402. * The custom extrusion is a parametric shape.
  25403. * It has no predefined shape. Its final shape will depend on the input parameters.
  25404. * Please consider using the same method from the MeshBuilder class instead
  25405. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25406. * @param name defines the name of the mesh to create
  25407. * @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
  25408. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25409. * @param scaleFunction is a custom Javascript function called on each path point
  25410. * @param rotationFunction is a custom Javascript function called on each path point
  25411. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25412. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25413. * @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
  25414. * @param scene defines the hosting scene
  25415. * @param updatable defines if the mesh must be flagged as updatable
  25416. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25417. * @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)
  25418. * @returns a new Mesh
  25419. */
  25420. 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;
  25421. /**
  25422. * Creates lathe mesh.
  25423. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25424. * Please consider using the same method from the MeshBuilder class instead
  25425. * @param name defines the name of the mesh to create
  25426. * @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
  25427. * @param radius is the radius value of the lathe
  25428. * @param tessellation is the side number of the lathe.
  25429. * @param scene defines the hosting scene
  25430. * @param updatable defines if the mesh must be flagged as updatable
  25431. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25432. * @returns a new Mesh
  25433. */
  25434. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25435. /**
  25436. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25437. * @param name defines the name of the mesh to create
  25438. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25439. * @param scene defines the hosting scene
  25440. * @param updatable defines if the mesh must be flagged as updatable
  25441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25442. * @returns a new Mesh
  25443. */
  25444. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25445. /**
  25446. * Creates a ground mesh.
  25447. * Please consider using the same method from the MeshBuilder class instead
  25448. * @param name defines the name of the mesh to create
  25449. * @param width set the width of the ground
  25450. * @param height set the height of the ground
  25451. * @param subdivisions sets the number of subdivisions per side
  25452. * @param scene defines the hosting scene
  25453. * @param updatable defines if the mesh must be flagged as updatable
  25454. * @returns a new Mesh
  25455. */
  25456. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25457. /**
  25458. * Creates a tiled ground mesh.
  25459. * Please consider using the same method from the MeshBuilder class instead
  25460. * @param name defines the name of the mesh to create
  25461. * @param xmin set the ground minimum X coordinate
  25462. * @param zmin set the ground minimum Y coordinate
  25463. * @param xmax set the ground maximum X coordinate
  25464. * @param zmax set the ground maximum Z coordinate
  25465. * @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
  25466. * @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
  25467. * @param scene defines the hosting scene
  25468. * @param updatable defines if the mesh must be flagged as updatable
  25469. * @returns a new Mesh
  25470. */
  25471. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25472. w: number;
  25473. h: number;
  25474. }, precision: {
  25475. w: number;
  25476. h: number;
  25477. }, scene: Scene, updatable?: boolean): Mesh;
  25478. /**
  25479. * Creates a ground mesh from a height map.
  25480. * Please consider using the same method from the MeshBuilder class instead
  25481. * @see http://doc.babylonjs.com/babylon101/height_map
  25482. * @param name defines the name of the mesh to create
  25483. * @param url sets the URL of the height map image resource
  25484. * @param width set the ground width size
  25485. * @param height set the ground height size
  25486. * @param subdivisions sets the number of subdivision per side
  25487. * @param minHeight is the minimum altitude on the ground
  25488. * @param maxHeight is the maximum altitude on the ground
  25489. * @param scene defines the hosting scene
  25490. * @param updatable defines if the mesh must be flagged as updatable
  25491. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25492. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25493. * @returns a new Mesh
  25494. */
  25495. 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;
  25496. /**
  25497. * Creates a tube mesh.
  25498. * The tube is a parametric shape.
  25499. * It has no predefined shape. Its final shape will depend on the input parameters.
  25500. * Please consider using the same method from the MeshBuilder class instead
  25501. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25502. * @param name defines the name of the mesh to create
  25503. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25504. * @param radius sets the tube radius size
  25505. * @param tessellation is the number of sides on the tubular surface
  25506. * @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
  25507. * @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
  25508. * @param scene defines the hosting scene
  25509. * @param updatable defines if the mesh must be flagged as updatable
  25510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25511. * @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)
  25512. * @returns a new Mesh
  25513. */
  25514. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25515. (i: number, distance: number): number;
  25516. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25517. /**
  25518. * Creates a polyhedron mesh.
  25519. * Please consider using the same method from the MeshBuilder class instead.
  25520. * * 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
  25521. * * The parameter `size` (positive float, default 1) sets the polygon size
  25522. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25523. * * 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`
  25524. * * 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
  25525. * * 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)`)
  25526. * * 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
  25527. * * 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
  25528. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25529. * * 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
  25530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25531. * @param name defines the name of the mesh to create
  25532. * @param options defines the options used to create the mesh
  25533. * @param scene defines the hosting scene
  25534. * @returns a new Mesh
  25535. */
  25536. static CreatePolyhedron(name: string, options: {
  25537. type?: number;
  25538. size?: number;
  25539. sizeX?: number;
  25540. sizeY?: number;
  25541. sizeZ?: number;
  25542. custom?: any;
  25543. faceUV?: Vector4[];
  25544. faceColors?: Color4[];
  25545. updatable?: boolean;
  25546. sideOrientation?: number;
  25547. }, scene: Scene): Mesh;
  25548. /**
  25549. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25550. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25551. * * 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`)
  25552. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25553. * * 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
  25554. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25555. * * 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
  25556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25557. * @param name defines the name of the mesh
  25558. * @param options defines the options used to create the mesh
  25559. * @param scene defines the hosting scene
  25560. * @returns a new Mesh
  25561. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25562. */
  25563. static CreateIcoSphere(name: string, options: {
  25564. radius?: number;
  25565. flat?: boolean;
  25566. subdivisions?: number;
  25567. sideOrientation?: number;
  25568. updatable?: boolean;
  25569. }, scene: Scene): Mesh;
  25570. /**
  25571. * Creates a decal mesh.
  25572. * Please consider using the same method from the MeshBuilder class instead.
  25573. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25574. * @param name defines the name of the mesh
  25575. * @param sourceMesh defines the mesh receiving the decal
  25576. * @param position sets the position of the decal in world coordinates
  25577. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25578. * @param size sets the decal scaling
  25579. * @param angle sets the angle to rotate the decal
  25580. * @returns a new Mesh
  25581. */
  25582. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25583. /**
  25584. * Prepare internal position array for software CPU skinning
  25585. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25586. */
  25587. setPositionsForCPUSkinning(): Float32Array;
  25588. /**
  25589. * Prepare internal normal array for software CPU skinning
  25590. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25591. */
  25592. setNormalsForCPUSkinning(): Float32Array;
  25593. /**
  25594. * Updates the vertex buffer by applying transformation from the bones
  25595. * @param skeleton defines the skeleton to apply to current mesh
  25596. * @returns the current mesh
  25597. */
  25598. applySkeleton(skeleton: Skeleton): Mesh;
  25599. /**
  25600. * 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
  25601. * @param meshes defines the list of meshes to scan
  25602. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25603. */
  25604. static MinMax(meshes: AbstractMesh[]): {
  25605. min: Vector3;
  25606. max: Vector3;
  25607. };
  25608. /**
  25609. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25610. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25611. * @returns a vector3
  25612. */
  25613. static Center(meshesOrMinMaxVector: {
  25614. min: Vector3;
  25615. max: Vector3;
  25616. } | AbstractMesh[]): Vector3;
  25617. /**
  25618. * Merge the array of meshes into a single mesh for performance reasons.
  25619. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25620. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25621. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25622. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25623. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25624. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25625. * @returns a new mesh
  25626. */
  25627. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25628. /** @hidden */
  25629. addInstance(instance: InstancedMesh): void;
  25630. /** @hidden */
  25631. removeInstance(instance: InstancedMesh): void;
  25632. }
  25633. }
  25634. declare module BABYLON {
  25635. /**
  25636. * This is the base class of all the camera used in the application.
  25637. * @see http://doc.babylonjs.com/features/cameras
  25638. */
  25639. export class Camera extends Node {
  25640. /** @hidden */
  25641. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25642. /**
  25643. * This is the default projection mode used by the cameras.
  25644. * It helps recreating a feeling of perspective and better appreciate depth.
  25645. * This is the best way to simulate real life cameras.
  25646. */
  25647. static readonly PERSPECTIVE_CAMERA: number;
  25648. /**
  25649. * This helps creating camera with an orthographic mode.
  25650. * 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.
  25651. */
  25652. static readonly ORTHOGRAPHIC_CAMERA: number;
  25653. /**
  25654. * This is the default FOV mode for perspective cameras.
  25655. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25656. */
  25657. static readonly FOVMODE_VERTICAL_FIXED: number;
  25658. /**
  25659. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25660. */
  25661. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25662. /**
  25663. * This specifies ther is no need for a camera rig.
  25664. * Basically only one eye is rendered corresponding to the camera.
  25665. */
  25666. static readonly RIG_MODE_NONE: number;
  25667. /**
  25668. * Simulates a camera Rig with one blue eye and one red eye.
  25669. * This can be use with 3d blue and red glasses.
  25670. */
  25671. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25672. /**
  25673. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25674. */
  25675. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25676. /**
  25677. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25678. */
  25679. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25680. /**
  25681. * Defines that both eyes of the camera will be rendered over under each other.
  25682. */
  25683. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25684. /**
  25685. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25686. */
  25687. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25688. /**
  25689. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25690. */
  25691. static readonly RIG_MODE_VR: number;
  25692. /**
  25693. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25694. */
  25695. static readonly RIG_MODE_WEBVR: number;
  25696. /**
  25697. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25698. */
  25699. static readonly RIG_MODE_CUSTOM: number;
  25700. /**
  25701. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25702. */
  25703. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25704. /**
  25705. * Define the input manager associated with the camera.
  25706. */
  25707. inputs: CameraInputsManager<Camera>;
  25708. /** @hidden */
  25709. _position: Vector3;
  25710. /**
  25711. * Define the current local position of the camera in the scene
  25712. */
  25713. get position(): Vector3;
  25714. set position(newPosition: Vector3);
  25715. /**
  25716. * The vector the camera should consider as up.
  25717. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25718. */
  25719. upVector: Vector3;
  25720. /**
  25721. * Define the current limit on the left side for an orthographic camera
  25722. * In scene unit
  25723. */
  25724. orthoLeft: Nullable<number>;
  25725. /**
  25726. * Define the current limit on the right side for an orthographic camera
  25727. * In scene unit
  25728. */
  25729. orthoRight: Nullable<number>;
  25730. /**
  25731. * Define the current limit on the bottom side for an orthographic camera
  25732. * In scene unit
  25733. */
  25734. orthoBottom: Nullable<number>;
  25735. /**
  25736. * Define the current limit on the top side for an orthographic camera
  25737. * In scene unit
  25738. */
  25739. orthoTop: Nullable<number>;
  25740. /**
  25741. * Field Of View is set in Radians. (default is 0.8)
  25742. */
  25743. fov: number;
  25744. /**
  25745. * Define the minimum distance the camera can see from.
  25746. * This is important to note that the depth buffer are not infinite and the closer it starts
  25747. * the more your scene might encounter depth fighting issue.
  25748. */
  25749. minZ: number;
  25750. /**
  25751. * Define the maximum distance the camera can see to.
  25752. * This is important to note that the depth buffer are not infinite and the further it end
  25753. * the more your scene might encounter depth fighting issue.
  25754. */
  25755. maxZ: number;
  25756. /**
  25757. * Define the default inertia of the camera.
  25758. * This helps giving a smooth feeling to the camera movement.
  25759. */
  25760. inertia: number;
  25761. /**
  25762. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25763. */
  25764. mode: number;
  25765. /**
  25766. * Define whether the camera is intermediate.
  25767. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25768. */
  25769. isIntermediate: boolean;
  25770. /**
  25771. * Define the viewport of the camera.
  25772. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25773. */
  25774. viewport: Viewport;
  25775. /**
  25776. * Restricts the camera to viewing objects with the same layerMask.
  25777. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25778. */
  25779. layerMask: number;
  25780. /**
  25781. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25782. */
  25783. fovMode: number;
  25784. /**
  25785. * Rig mode of the camera.
  25786. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25787. * This is normally controlled byt the camera themselves as internal use.
  25788. */
  25789. cameraRigMode: number;
  25790. /**
  25791. * Defines the distance between both "eyes" in case of a RIG
  25792. */
  25793. interaxialDistance: number;
  25794. /**
  25795. * Defines if stereoscopic rendering is done side by side or over under.
  25796. */
  25797. isStereoscopicSideBySide: boolean;
  25798. /**
  25799. * 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
  25800. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25801. * else in the scene. (Eg. security camera)
  25802. *
  25803. * 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)
  25804. */
  25805. customRenderTargets: RenderTargetTexture[];
  25806. /**
  25807. * When set, the camera will render to this render target instead of the default canvas
  25808. *
  25809. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25810. */
  25811. outputRenderTarget: Nullable<RenderTargetTexture>;
  25812. /**
  25813. * Observable triggered when the camera view matrix has changed.
  25814. */
  25815. onViewMatrixChangedObservable: Observable<Camera>;
  25816. /**
  25817. * Observable triggered when the camera Projection matrix has changed.
  25818. */
  25819. onProjectionMatrixChangedObservable: Observable<Camera>;
  25820. /**
  25821. * Observable triggered when the inputs have been processed.
  25822. */
  25823. onAfterCheckInputsObservable: Observable<Camera>;
  25824. /**
  25825. * Observable triggered when reset has been called and applied to the camera.
  25826. */
  25827. onRestoreStateObservable: Observable<Camera>;
  25828. /**
  25829. * Is this camera a part of a rig system?
  25830. */
  25831. isRigCamera: boolean;
  25832. /**
  25833. * If isRigCamera set to true this will be set with the parent camera.
  25834. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25835. */
  25836. rigParent?: Camera;
  25837. /** @hidden */
  25838. _cameraRigParams: any;
  25839. /** @hidden */
  25840. _rigCameras: Camera[];
  25841. /** @hidden */
  25842. _rigPostProcess: Nullable<PostProcess>;
  25843. protected _webvrViewMatrix: Matrix;
  25844. /** @hidden */
  25845. _skipRendering: boolean;
  25846. /** @hidden */
  25847. _projectionMatrix: Matrix;
  25848. /** @hidden */
  25849. _postProcesses: Nullable<PostProcess>[];
  25850. /** @hidden */
  25851. _activeMeshes: SmartArray<AbstractMesh>;
  25852. protected _globalPosition: Vector3;
  25853. /** @hidden */
  25854. _computedViewMatrix: Matrix;
  25855. private _doNotComputeProjectionMatrix;
  25856. private _transformMatrix;
  25857. private _frustumPlanes;
  25858. private _refreshFrustumPlanes;
  25859. private _storedFov;
  25860. private _stateStored;
  25861. /**
  25862. * Instantiates a new camera object.
  25863. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25864. * @see http://doc.babylonjs.com/features/cameras
  25865. * @param name Defines the name of the camera in the scene
  25866. * @param position Defines the position of the camera
  25867. * @param scene Defines the scene the camera belongs too
  25868. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25869. */
  25870. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25871. /**
  25872. * Store current camera state (fov, position, etc..)
  25873. * @returns the camera
  25874. */
  25875. storeState(): Camera;
  25876. /**
  25877. * Restores the camera state values if it has been stored. You must call storeState() first
  25878. */
  25879. protected _restoreStateValues(): boolean;
  25880. /**
  25881. * Restored camera state. You must call storeState() first.
  25882. * @returns true if restored and false otherwise
  25883. */
  25884. restoreState(): boolean;
  25885. /**
  25886. * Gets the class name of the camera.
  25887. * @returns the class name
  25888. */
  25889. getClassName(): string;
  25890. /** @hidden */
  25891. readonly _isCamera: boolean;
  25892. /**
  25893. * Gets a string representation of the camera useful for debug purpose.
  25894. * @param fullDetails Defines that a more verboe level of logging is required
  25895. * @returns the string representation
  25896. */
  25897. toString(fullDetails?: boolean): string;
  25898. /**
  25899. * Gets the current world space position of the camera.
  25900. */
  25901. get globalPosition(): Vector3;
  25902. /**
  25903. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25904. * @returns the active meshe list
  25905. */
  25906. getActiveMeshes(): SmartArray<AbstractMesh>;
  25907. /**
  25908. * Check whether a mesh is part of the current active mesh list of the camera
  25909. * @param mesh Defines the mesh to check
  25910. * @returns true if active, false otherwise
  25911. */
  25912. isActiveMesh(mesh: Mesh): boolean;
  25913. /**
  25914. * Is this camera ready to be used/rendered
  25915. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25916. * @return true if the camera is ready
  25917. */
  25918. isReady(completeCheck?: boolean): boolean;
  25919. /** @hidden */
  25920. _initCache(): void;
  25921. /** @hidden */
  25922. _updateCache(ignoreParentClass?: boolean): void;
  25923. /** @hidden */
  25924. _isSynchronized(): boolean;
  25925. /** @hidden */
  25926. _isSynchronizedViewMatrix(): boolean;
  25927. /** @hidden */
  25928. _isSynchronizedProjectionMatrix(): boolean;
  25929. /**
  25930. * Attach the input controls to a specific dom element to get the input from.
  25931. * @param element Defines the element the controls should be listened from
  25932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25933. */
  25934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25935. /**
  25936. * Detach the current controls from the specified dom element.
  25937. * @param element Defines the element to stop listening the inputs from
  25938. */
  25939. detachControl(element: HTMLElement): void;
  25940. /**
  25941. * Update the camera state according to the different inputs gathered during the frame.
  25942. */
  25943. update(): void;
  25944. /** @hidden */
  25945. _checkInputs(): void;
  25946. /** @hidden */
  25947. get rigCameras(): Camera[];
  25948. /**
  25949. * Gets the post process used by the rig cameras
  25950. */
  25951. get rigPostProcess(): Nullable<PostProcess>;
  25952. /**
  25953. * Internal, gets the first post proces.
  25954. * @returns the first post process to be run on this camera.
  25955. */
  25956. _getFirstPostProcess(): Nullable<PostProcess>;
  25957. private _cascadePostProcessesToRigCams;
  25958. /**
  25959. * Attach a post process to the camera.
  25960. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25961. * @param postProcess The post process to attach to the camera
  25962. * @param insertAt The position of the post process in case several of them are in use in the scene
  25963. * @returns the position the post process has been inserted at
  25964. */
  25965. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25966. /**
  25967. * Detach a post process to the camera.
  25968. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25969. * @param postProcess The post process to detach from the camera
  25970. */
  25971. detachPostProcess(postProcess: PostProcess): void;
  25972. /**
  25973. * Gets the current world matrix of the camera
  25974. */
  25975. getWorldMatrix(): Matrix;
  25976. /** @hidden */
  25977. _getViewMatrix(): Matrix;
  25978. /**
  25979. * Gets the current view matrix of the camera.
  25980. * @param force forces the camera to recompute the matrix without looking at the cached state
  25981. * @returns the view matrix
  25982. */
  25983. getViewMatrix(force?: boolean): Matrix;
  25984. /**
  25985. * Freeze the projection matrix.
  25986. * It will prevent the cache check of the camera projection compute and can speed up perf
  25987. * if no parameter of the camera are meant to change
  25988. * @param projection Defines manually a projection if necessary
  25989. */
  25990. freezeProjectionMatrix(projection?: Matrix): void;
  25991. /**
  25992. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25993. */
  25994. unfreezeProjectionMatrix(): void;
  25995. /**
  25996. * Gets the current projection matrix of the camera.
  25997. * @param force forces the camera to recompute the matrix without looking at the cached state
  25998. * @returns the projection matrix
  25999. */
  26000. getProjectionMatrix(force?: boolean): Matrix;
  26001. /**
  26002. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26003. * @returns a Matrix
  26004. */
  26005. getTransformationMatrix(): Matrix;
  26006. private _updateFrustumPlanes;
  26007. /**
  26008. * Checks if a cullable object (mesh...) is in the camera frustum
  26009. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26010. * @param target The object to check
  26011. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26012. * @returns true if the object is in frustum otherwise false
  26013. */
  26014. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26015. /**
  26016. * Checks if a cullable object (mesh...) is in the camera frustum
  26017. * Unlike isInFrustum this cheks the full bounding box
  26018. * @param target The object to check
  26019. * @returns true if the object is in frustum otherwise false
  26020. */
  26021. isCompletelyInFrustum(target: ICullable): boolean;
  26022. /**
  26023. * Gets a ray in the forward direction from the camera.
  26024. * @param length Defines the length of the ray to create
  26025. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26026. * @param origin Defines the start point of the ray which defaults to the camera position
  26027. * @returns the forward ray
  26028. */
  26029. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26030. /**
  26031. * Releases resources associated with this node.
  26032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26034. */
  26035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26036. /** @hidden */
  26037. _isLeftCamera: boolean;
  26038. /**
  26039. * Gets the left camera of a rig setup in case of Rigged Camera
  26040. */
  26041. get isLeftCamera(): boolean;
  26042. /** @hidden */
  26043. _isRightCamera: boolean;
  26044. /**
  26045. * Gets the right camera of a rig setup in case of Rigged Camera
  26046. */
  26047. get isRightCamera(): boolean;
  26048. /**
  26049. * Gets the left camera of a rig setup in case of Rigged Camera
  26050. */
  26051. get leftCamera(): Nullable<FreeCamera>;
  26052. /**
  26053. * Gets the right camera of a rig setup in case of Rigged Camera
  26054. */
  26055. get rightCamera(): Nullable<FreeCamera>;
  26056. /**
  26057. * Gets the left camera target of a rig setup in case of Rigged Camera
  26058. * @returns the target position
  26059. */
  26060. getLeftTarget(): Nullable<Vector3>;
  26061. /**
  26062. * Gets the right camera target of a rig setup in case of Rigged Camera
  26063. * @returns the target position
  26064. */
  26065. getRightTarget(): Nullable<Vector3>;
  26066. /**
  26067. * @hidden
  26068. */
  26069. setCameraRigMode(mode: number, rigParams: any): void;
  26070. /** @hidden */
  26071. static _setStereoscopicRigMode(camera: Camera): void;
  26072. /** @hidden */
  26073. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26074. /** @hidden */
  26075. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26076. /** @hidden */
  26077. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26078. /** @hidden */
  26079. _getVRProjectionMatrix(): Matrix;
  26080. protected _updateCameraRotationMatrix(): void;
  26081. protected _updateWebVRCameraRotationMatrix(): void;
  26082. /**
  26083. * This function MUST be overwritten by the different WebVR cameras available.
  26084. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26085. * @hidden
  26086. */
  26087. _getWebVRProjectionMatrix(): Matrix;
  26088. /**
  26089. * This function MUST be overwritten by the different WebVR cameras available.
  26090. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26091. * @hidden
  26092. */
  26093. _getWebVRViewMatrix(): Matrix;
  26094. /** @hidden */
  26095. setCameraRigParameter(name: string, value: any): void;
  26096. /**
  26097. * needs to be overridden by children so sub has required properties to be copied
  26098. * @hidden
  26099. */
  26100. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26101. /**
  26102. * May need to be overridden by children
  26103. * @hidden
  26104. */
  26105. _updateRigCameras(): void;
  26106. /** @hidden */
  26107. _setupInputs(): void;
  26108. /**
  26109. * Serialiaze the camera setup to a json represention
  26110. * @returns the JSON representation
  26111. */
  26112. serialize(): any;
  26113. /**
  26114. * Clones the current camera.
  26115. * @param name The cloned camera name
  26116. * @returns the cloned camera
  26117. */
  26118. clone(name: string): Camera;
  26119. /**
  26120. * Gets the direction of the camera relative to a given local axis.
  26121. * @param localAxis Defines the reference axis to provide a relative direction.
  26122. * @return the direction
  26123. */
  26124. getDirection(localAxis: Vector3): Vector3;
  26125. /**
  26126. * Returns the current camera absolute rotation
  26127. */
  26128. get absoluteRotation(): Quaternion;
  26129. /**
  26130. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26131. * @param localAxis Defines the reference axis to provide a relative direction.
  26132. * @param result Defines the vector to store the result in
  26133. */
  26134. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26135. /**
  26136. * Gets a camera constructor for a given camera type
  26137. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26138. * @param name The name of the camera the result will be able to instantiate
  26139. * @param scene The scene the result will construct the camera in
  26140. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26141. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26142. * @returns a factory method to construc the camera
  26143. */
  26144. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26145. /**
  26146. * Compute the world matrix of the camera.
  26147. * @returns the camera world matrix
  26148. */
  26149. computeWorldMatrix(): Matrix;
  26150. /**
  26151. * Parse a JSON and creates the camera from the parsed information
  26152. * @param parsedCamera The JSON to parse
  26153. * @param scene The scene to instantiate the camera in
  26154. * @returns the newly constructed camera
  26155. */
  26156. static Parse(parsedCamera: any, scene: Scene): Camera;
  26157. }
  26158. }
  26159. declare module BABYLON {
  26160. /**
  26161. * Class containing static functions to help procedurally build meshes
  26162. */
  26163. export class DiscBuilder {
  26164. /**
  26165. * Creates a plane polygonal mesh. By default, this is a disc
  26166. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26167. * * 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
  26168. * * 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
  26169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26170. * * 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
  26171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26172. * @param name defines the name of the mesh
  26173. * @param options defines the options used to create the mesh
  26174. * @param scene defines the hosting scene
  26175. * @returns the plane polygonal mesh
  26176. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26177. */
  26178. static CreateDisc(name: string, options: {
  26179. radius?: number;
  26180. tessellation?: number;
  26181. arc?: number;
  26182. updatable?: boolean;
  26183. sideOrientation?: number;
  26184. frontUVs?: Vector4;
  26185. backUVs?: Vector4;
  26186. }, scene?: Nullable<Scene>): Mesh;
  26187. }
  26188. }
  26189. declare module BABYLON {
  26190. /**
  26191. * Options to be used when creating a FresnelParameters.
  26192. */
  26193. export type IFresnelParametersCreationOptions = {
  26194. /**
  26195. * Define the color used on edges (grazing angle)
  26196. */
  26197. leftColor?: Color3;
  26198. /**
  26199. * Define the color used on center
  26200. */
  26201. rightColor?: Color3;
  26202. /**
  26203. * Define bias applied to computed fresnel term
  26204. */
  26205. bias?: number;
  26206. /**
  26207. * Defined the power exponent applied to fresnel term
  26208. */
  26209. power?: number;
  26210. /**
  26211. * Define if the fresnel effect is enable or not.
  26212. */
  26213. isEnabled?: boolean;
  26214. };
  26215. /**
  26216. * Serialized format for FresnelParameters.
  26217. */
  26218. export type IFresnelParametersSerialized = {
  26219. /**
  26220. * Define the color used on edges (grazing angle) [as an array]
  26221. */
  26222. leftColor: number[];
  26223. /**
  26224. * Define the color used on center [as an array]
  26225. */
  26226. rightColor: number[];
  26227. /**
  26228. * Define bias applied to computed fresnel term
  26229. */
  26230. bias: number;
  26231. /**
  26232. * Defined the power exponent applied to fresnel term
  26233. */
  26234. power?: number;
  26235. /**
  26236. * Define if the fresnel effect is enable or not.
  26237. */
  26238. isEnabled: boolean;
  26239. };
  26240. /**
  26241. * This represents all the required information to add a fresnel effect on a material:
  26242. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26243. */
  26244. export class FresnelParameters {
  26245. private _isEnabled;
  26246. /**
  26247. * Define if the fresnel effect is enable or not.
  26248. */
  26249. get isEnabled(): boolean;
  26250. set isEnabled(value: boolean);
  26251. /**
  26252. * Define the color used on edges (grazing angle)
  26253. */
  26254. leftColor: Color3;
  26255. /**
  26256. * Define the color used on center
  26257. */
  26258. rightColor: Color3;
  26259. /**
  26260. * Define bias applied to computed fresnel term
  26261. */
  26262. bias: number;
  26263. /**
  26264. * Defined the power exponent applied to fresnel term
  26265. */
  26266. power: number;
  26267. /**
  26268. * Creates a new FresnelParameters object.
  26269. *
  26270. * @param options provide your own settings to optionally to override defaults
  26271. */
  26272. constructor(options?: IFresnelParametersCreationOptions);
  26273. /**
  26274. * Clones the current fresnel and its valuues
  26275. * @returns a clone fresnel configuration
  26276. */
  26277. clone(): FresnelParameters;
  26278. /**
  26279. * Determines equality between FresnelParameters objects
  26280. * @param otherFresnelParameters defines the second operand
  26281. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26282. */
  26283. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26284. /**
  26285. * Serializes the current fresnel parameters to a JSON representation.
  26286. * @return the JSON serialization
  26287. */
  26288. serialize(): IFresnelParametersSerialized;
  26289. /**
  26290. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26291. * @param parsedFresnelParameters Define the JSON representation
  26292. * @returns the parsed parameters
  26293. */
  26294. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26295. }
  26296. }
  26297. declare module BABYLON {
  26298. /**
  26299. * Base class of materials working in push mode in babylon JS
  26300. * @hidden
  26301. */
  26302. export class PushMaterial extends Material {
  26303. protected _activeEffect: Effect;
  26304. protected _normalMatrix: Matrix;
  26305. /**
  26306. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26307. * This means that the material can keep using a previous shader while a new one is being compiled.
  26308. * This is mostly used when shader parallel compilation is supported (true by default)
  26309. */
  26310. allowShaderHotSwapping: boolean;
  26311. constructor(name: string, scene: Scene);
  26312. getEffect(): Effect;
  26313. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26314. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26315. /**
  26316. * Binds the given world matrix to the active effect
  26317. *
  26318. * @param world the matrix to bind
  26319. */
  26320. bindOnlyWorldMatrix(world: Matrix): void;
  26321. /**
  26322. * Binds the given normal matrix to the active effect
  26323. *
  26324. * @param normalMatrix the matrix to bind
  26325. */
  26326. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26327. bind(world: Matrix, mesh?: Mesh): void;
  26328. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26329. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26330. }
  26331. }
  26332. declare module BABYLON {
  26333. /**
  26334. * This groups all the flags used to control the materials channel.
  26335. */
  26336. export class MaterialFlags {
  26337. private static _DiffuseTextureEnabled;
  26338. /**
  26339. * Are diffuse textures enabled in the application.
  26340. */
  26341. static get DiffuseTextureEnabled(): boolean;
  26342. static set DiffuseTextureEnabled(value: boolean);
  26343. private static _AmbientTextureEnabled;
  26344. /**
  26345. * Are ambient textures enabled in the application.
  26346. */
  26347. static get AmbientTextureEnabled(): boolean;
  26348. static set AmbientTextureEnabled(value: boolean);
  26349. private static _OpacityTextureEnabled;
  26350. /**
  26351. * Are opacity textures enabled in the application.
  26352. */
  26353. static get OpacityTextureEnabled(): boolean;
  26354. static set OpacityTextureEnabled(value: boolean);
  26355. private static _ReflectionTextureEnabled;
  26356. /**
  26357. * Are reflection textures enabled in the application.
  26358. */
  26359. static get ReflectionTextureEnabled(): boolean;
  26360. static set ReflectionTextureEnabled(value: boolean);
  26361. private static _EmissiveTextureEnabled;
  26362. /**
  26363. * Are emissive textures enabled in the application.
  26364. */
  26365. static get EmissiveTextureEnabled(): boolean;
  26366. static set EmissiveTextureEnabled(value: boolean);
  26367. private static _SpecularTextureEnabled;
  26368. /**
  26369. * Are specular textures enabled in the application.
  26370. */
  26371. static get SpecularTextureEnabled(): boolean;
  26372. static set SpecularTextureEnabled(value: boolean);
  26373. private static _BumpTextureEnabled;
  26374. /**
  26375. * Are bump textures enabled in the application.
  26376. */
  26377. static get BumpTextureEnabled(): boolean;
  26378. static set BumpTextureEnabled(value: boolean);
  26379. private static _LightmapTextureEnabled;
  26380. /**
  26381. * Are lightmap textures enabled in the application.
  26382. */
  26383. static get LightmapTextureEnabled(): boolean;
  26384. static set LightmapTextureEnabled(value: boolean);
  26385. private static _RefractionTextureEnabled;
  26386. /**
  26387. * Are refraction textures enabled in the application.
  26388. */
  26389. static get RefractionTextureEnabled(): boolean;
  26390. static set RefractionTextureEnabled(value: boolean);
  26391. private static _ColorGradingTextureEnabled;
  26392. /**
  26393. * Are color grading textures enabled in the application.
  26394. */
  26395. static get ColorGradingTextureEnabled(): boolean;
  26396. static set ColorGradingTextureEnabled(value: boolean);
  26397. private static _FresnelEnabled;
  26398. /**
  26399. * Are fresnels enabled in the application.
  26400. */
  26401. static get FresnelEnabled(): boolean;
  26402. static set FresnelEnabled(value: boolean);
  26403. private static _ClearCoatTextureEnabled;
  26404. /**
  26405. * Are clear coat textures enabled in the application.
  26406. */
  26407. static get ClearCoatTextureEnabled(): boolean;
  26408. static set ClearCoatTextureEnabled(value: boolean);
  26409. private static _ClearCoatBumpTextureEnabled;
  26410. /**
  26411. * Are clear coat bump textures enabled in the application.
  26412. */
  26413. static get ClearCoatBumpTextureEnabled(): boolean;
  26414. static set ClearCoatBumpTextureEnabled(value: boolean);
  26415. private static _ClearCoatTintTextureEnabled;
  26416. /**
  26417. * Are clear coat tint textures enabled in the application.
  26418. */
  26419. static get ClearCoatTintTextureEnabled(): boolean;
  26420. static set ClearCoatTintTextureEnabled(value: boolean);
  26421. private static _SheenTextureEnabled;
  26422. /**
  26423. * Are sheen textures enabled in the application.
  26424. */
  26425. static get SheenTextureEnabled(): boolean;
  26426. static set SheenTextureEnabled(value: boolean);
  26427. private static _AnisotropicTextureEnabled;
  26428. /**
  26429. * Are anisotropic textures enabled in the application.
  26430. */
  26431. static get AnisotropicTextureEnabled(): boolean;
  26432. static set AnisotropicTextureEnabled(value: boolean);
  26433. private static _ThicknessTextureEnabled;
  26434. /**
  26435. * Are thickness textures enabled in the application.
  26436. */
  26437. static get ThicknessTextureEnabled(): boolean;
  26438. static set ThicknessTextureEnabled(value: boolean);
  26439. }
  26440. }
  26441. declare module BABYLON {
  26442. /** @hidden */
  26443. export var defaultFragmentDeclaration: {
  26444. name: string;
  26445. shader: string;
  26446. };
  26447. }
  26448. declare module BABYLON {
  26449. /** @hidden */
  26450. export var defaultUboDeclaration: {
  26451. name: string;
  26452. shader: string;
  26453. };
  26454. }
  26455. declare module BABYLON {
  26456. /** @hidden */
  26457. export var lightFragmentDeclaration: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module BABYLON {
  26463. /** @hidden */
  26464. export var lightUboDeclaration: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module BABYLON {
  26470. /** @hidden */
  26471. export var lightsFragmentFunctions: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module BABYLON {
  26477. /** @hidden */
  26478. export var shadowsFragmentFunctions: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module BABYLON {
  26484. /** @hidden */
  26485. export var fresnelFunction: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module BABYLON {
  26491. /** @hidden */
  26492. export var reflectionFunction: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module BABYLON {
  26498. /** @hidden */
  26499. export var bumpFragmentFunctions: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module BABYLON {
  26505. /** @hidden */
  26506. export var logDepthDeclaration: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module BABYLON {
  26512. /** @hidden */
  26513. export var bumpFragment: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module BABYLON {
  26519. /** @hidden */
  26520. export var depthPrePass: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module BABYLON {
  26526. /** @hidden */
  26527. export var lightFragment: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module BABYLON {
  26533. /** @hidden */
  26534. export var logDepthFragment: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module BABYLON {
  26540. /** @hidden */
  26541. export var defaultPixelShader: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module BABYLON {
  26547. /** @hidden */
  26548. export var defaultVertexDeclaration: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module BABYLON {
  26554. /** @hidden */
  26555. export var bumpVertexDeclaration: {
  26556. name: string;
  26557. shader: string;
  26558. };
  26559. }
  26560. declare module BABYLON {
  26561. /** @hidden */
  26562. export var bumpVertex: {
  26563. name: string;
  26564. shader: string;
  26565. };
  26566. }
  26567. declare module BABYLON {
  26568. /** @hidden */
  26569. export var fogVertex: {
  26570. name: string;
  26571. shader: string;
  26572. };
  26573. }
  26574. declare module BABYLON {
  26575. /** @hidden */
  26576. export var shadowsVertex: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module BABYLON {
  26582. /** @hidden */
  26583. export var pointCloudVertex: {
  26584. name: string;
  26585. shader: string;
  26586. };
  26587. }
  26588. declare module BABYLON {
  26589. /** @hidden */
  26590. export var logDepthVertex: {
  26591. name: string;
  26592. shader: string;
  26593. };
  26594. }
  26595. declare module BABYLON {
  26596. /** @hidden */
  26597. export var defaultVertexShader: {
  26598. name: string;
  26599. shader: string;
  26600. };
  26601. }
  26602. declare module BABYLON {
  26603. /** @hidden */
  26604. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26605. MAINUV1: boolean;
  26606. MAINUV2: boolean;
  26607. DIFFUSE: boolean;
  26608. DIFFUSEDIRECTUV: number;
  26609. AMBIENT: boolean;
  26610. AMBIENTDIRECTUV: number;
  26611. OPACITY: boolean;
  26612. OPACITYDIRECTUV: number;
  26613. OPACITYRGB: boolean;
  26614. REFLECTION: boolean;
  26615. EMISSIVE: boolean;
  26616. EMISSIVEDIRECTUV: number;
  26617. SPECULAR: boolean;
  26618. SPECULARDIRECTUV: number;
  26619. BUMP: boolean;
  26620. BUMPDIRECTUV: number;
  26621. PARALLAX: boolean;
  26622. PARALLAXOCCLUSION: boolean;
  26623. SPECULAROVERALPHA: boolean;
  26624. CLIPPLANE: boolean;
  26625. CLIPPLANE2: boolean;
  26626. CLIPPLANE3: boolean;
  26627. CLIPPLANE4: boolean;
  26628. CLIPPLANE5: boolean;
  26629. CLIPPLANE6: boolean;
  26630. ALPHATEST: boolean;
  26631. DEPTHPREPASS: boolean;
  26632. ALPHAFROMDIFFUSE: boolean;
  26633. POINTSIZE: boolean;
  26634. FOG: boolean;
  26635. SPECULARTERM: boolean;
  26636. DIFFUSEFRESNEL: boolean;
  26637. OPACITYFRESNEL: boolean;
  26638. REFLECTIONFRESNEL: boolean;
  26639. REFRACTIONFRESNEL: boolean;
  26640. EMISSIVEFRESNEL: boolean;
  26641. FRESNEL: boolean;
  26642. NORMAL: boolean;
  26643. UV1: boolean;
  26644. UV2: boolean;
  26645. VERTEXCOLOR: boolean;
  26646. VERTEXALPHA: boolean;
  26647. NUM_BONE_INFLUENCERS: number;
  26648. BonesPerMesh: number;
  26649. BONETEXTURE: boolean;
  26650. INSTANCES: boolean;
  26651. GLOSSINESS: boolean;
  26652. ROUGHNESS: boolean;
  26653. EMISSIVEASILLUMINATION: boolean;
  26654. LINKEMISSIVEWITHDIFFUSE: boolean;
  26655. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26656. LIGHTMAP: boolean;
  26657. LIGHTMAPDIRECTUV: number;
  26658. OBJECTSPACE_NORMALMAP: boolean;
  26659. USELIGHTMAPASSHADOWMAP: boolean;
  26660. REFLECTIONMAP_3D: boolean;
  26661. REFLECTIONMAP_SPHERICAL: boolean;
  26662. REFLECTIONMAP_PLANAR: boolean;
  26663. REFLECTIONMAP_CUBIC: boolean;
  26664. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26665. REFLECTIONMAP_PROJECTION: boolean;
  26666. REFLECTIONMAP_SKYBOX: boolean;
  26667. REFLECTIONMAP_EXPLICIT: boolean;
  26668. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26669. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26670. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26671. INVERTCUBICMAP: boolean;
  26672. LOGARITHMICDEPTH: boolean;
  26673. REFRACTION: boolean;
  26674. REFRACTIONMAP_3D: boolean;
  26675. REFLECTIONOVERALPHA: boolean;
  26676. TWOSIDEDLIGHTING: boolean;
  26677. SHADOWFLOAT: boolean;
  26678. MORPHTARGETS: boolean;
  26679. MORPHTARGETS_NORMAL: boolean;
  26680. MORPHTARGETS_TANGENT: boolean;
  26681. MORPHTARGETS_UV: boolean;
  26682. NUM_MORPH_INFLUENCERS: number;
  26683. NONUNIFORMSCALING: boolean;
  26684. PREMULTIPLYALPHA: boolean;
  26685. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26686. ALPHABLEND: boolean;
  26687. IMAGEPROCESSING: boolean;
  26688. VIGNETTE: boolean;
  26689. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26690. VIGNETTEBLENDMODEOPAQUE: boolean;
  26691. TONEMAPPING: boolean;
  26692. TONEMAPPING_ACES: boolean;
  26693. CONTRAST: boolean;
  26694. COLORCURVES: boolean;
  26695. COLORGRADING: boolean;
  26696. COLORGRADING3D: boolean;
  26697. SAMPLER3DGREENDEPTH: boolean;
  26698. SAMPLER3DBGRMAP: boolean;
  26699. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26700. MULTIVIEW: boolean;
  26701. /**
  26702. * If the reflection texture on this material is in linear color space
  26703. * @hidden
  26704. */
  26705. IS_REFLECTION_LINEAR: boolean;
  26706. /**
  26707. * If the refraction texture on this material is in linear color space
  26708. * @hidden
  26709. */
  26710. IS_REFRACTION_LINEAR: boolean;
  26711. EXPOSURE: boolean;
  26712. constructor();
  26713. setReflectionMode(modeToEnable: string): void;
  26714. }
  26715. /**
  26716. * This is the default material used in Babylon. It is the best trade off between quality
  26717. * and performances.
  26718. * @see http://doc.babylonjs.com/babylon101/materials
  26719. */
  26720. export class StandardMaterial extends PushMaterial {
  26721. private _diffuseTexture;
  26722. /**
  26723. * The basic texture of the material as viewed under a light.
  26724. */
  26725. diffuseTexture: Nullable<BaseTexture>;
  26726. private _ambientTexture;
  26727. /**
  26728. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26729. */
  26730. ambientTexture: Nullable<BaseTexture>;
  26731. private _opacityTexture;
  26732. /**
  26733. * Define the transparency of the material from a texture.
  26734. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26735. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26736. */
  26737. opacityTexture: Nullable<BaseTexture>;
  26738. private _reflectionTexture;
  26739. /**
  26740. * Define the texture used to display the reflection.
  26741. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26742. */
  26743. reflectionTexture: Nullable<BaseTexture>;
  26744. private _emissiveTexture;
  26745. /**
  26746. * Define texture of the material as if self lit.
  26747. * This will be mixed in the final result even in the absence of light.
  26748. */
  26749. emissiveTexture: Nullable<BaseTexture>;
  26750. private _specularTexture;
  26751. /**
  26752. * Define how the color and intensity of the highlight given by the light in the material.
  26753. */
  26754. specularTexture: Nullable<BaseTexture>;
  26755. private _bumpTexture;
  26756. /**
  26757. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26758. * 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.
  26759. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26760. */
  26761. bumpTexture: Nullable<BaseTexture>;
  26762. private _lightmapTexture;
  26763. /**
  26764. * Complex lighting can be computationally expensive to compute at runtime.
  26765. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26766. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26767. */
  26768. lightmapTexture: Nullable<BaseTexture>;
  26769. private _refractionTexture;
  26770. /**
  26771. * Define the texture used to display the refraction.
  26772. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26773. */
  26774. refractionTexture: Nullable<BaseTexture>;
  26775. /**
  26776. * The color of the material lit by the environmental background lighting.
  26777. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26778. */
  26779. ambientColor: Color3;
  26780. /**
  26781. * The basic color of the material as viewed under a light.
  26782. */
  26783. diffuseColor: Color3;
  26784. /**
  26785. * Define how the color and intensity of the highlight given by the light in the material.
  26786. */
  26787. specularColor: Color3;
  26788. /**
  26789. * Define the color of the material as if self lit.
  26790. * This will be mixed in the final result even in the absence of light.
  26791. */
  26792. emissiveColor: Color3;
  26793. /**
  26794. * Defines how sharp are the highlights in the material.
  26795. * The bigger the value the sharper giving a more glossy feeling to the result.
  26796. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26797. */
  26798. specularPower: number;
  26799. private _useAlphaFromDiffuseTexture;
  26800. /**
  26801. * Does the transparency come from the diffuse texture alpha channel.
  26802. */
  26803. useAlphaFromDiffuseTexture: boolean;
  26804. private _useEmissiveAsIllumination;
  26805. /**
  26806. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26807. */
  26808. useEmissiveAsIllumination: boolean;
  26809. private _linkEmissiveWithDiffuse;
  26810. /**
  26811. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26812. * the emissive level when the final color is close to one.
  26813. */
  26814. linkEmissiveWithDiffuse: boolean;
  26815. private _useSpecularOverAlpha;
  26816. /**
  26817. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26818. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26819. */
  26820. useSpecularOverAlpha: boolean;
  26821. private _useReflectionOverAlpha;
  26822. /**
  26823. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26824. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26825. */
  26826. useReflectionOverAlpha: boolean;
  26827. private _disableLighting;
  26828. /**
  26829. * Does lights from the scene impacts this material.
  26830. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26831. */
  26832. disableLighting: boolean;
  26833. private _useObjectSpaceNormalMap;
  26834. /**
  26835. * Allows using an object space normal map (instead of tangent space).
  26836. */
  26837. useObjectSpaceNormalMap: boolean;
  26838. private _useParallax;
  26839. /**
  26840. * Is parallax enabled or not.
  26841. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26842. */
  26843. useParallax: boolean;
  26844. private _useParallaxOcclusion;
  26845. /**
  26846. * Is parallax occlusion enabled or not.
  26847. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26848. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26849. */
  26850. useParallaxOcclusion: boolean;
  26851. /**
  26852. * 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.
  26853. */
  26854. parallaxScaleBias: number;
  26855. private _roughness;
  26856. /**
  26857. * Helps to define how blurry the reflections should appears in the material.
  26858. */
  26859. roughness: number;
  26860. /**
  26861. * In case of refraction, define the value of the index of refraction.
  26862. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26863. */
  26864. indexOfRefraction: number;
  26865. /**
  26866. * Invert the refraction texture alongside the y axis.
  26867. * It can be useful with procedural textures or probe for instance.
  26868. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26869. */
  26870. invertRefractionY: boolean;
  26871. /**
  26872. * Defines the alpha limits in alpha test mode.
  26873. */
  26874. alphaCutOff: number;
  26875. private _useLightmapAsShadowmap;
  26876. /**
  26877. * In case of light mapping, define whether the map contains light or shadow informations.
  26878. */
  26879. useLightmapAsShadowmap: boolean;
  26880. private _diffuseFresnelParameters;
  26881. /**
  26882. * Define the diffuse fresnel parameters of the material.
  26883. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26884. */
  26885. diffuseFresnelParameters: FresnelParameters;
  26886. private _opacityFresnelParameters;
  26887. /**
  26888. * Define the opacity fresnel parameters of the material.
  26889. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26890. */
  26891. opacityFresnelParameters: FresnelParameters;
  26892. private _reflectionFresnelParameters;
  26893. /**
  26894. * Define the reflection fresnel parameters of the material.
  26895. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26896. */
  26897. reflectionFresnelParameters: FresnelParameters;
  26898. private _refractionFresnelParameters;
  26899. /**
  26900. * Define the refraction fresnel parameters of the material.
  26901. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26902. */
  26903. refractionFresnelParameters: FresnelParameters;
  26904. private _emissiveFresnelParameters;
  26905. /**
  26906. * Define the emissive fresnel parameters of the material.
  26907. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26908. */
  26909. emissiveFresnelParameters: FresnelParameters;
  26910. private _useReflectionFresnelFromSpecular;
  26911. /**
  26912. * If true automatically deducts the fresnels values from the material specularity.
  26913. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26914. */
  26915. useReflectionFresnelFromSpecular: boolean;
  26916. private _useGlossinessFromSpecularMapAlpha;
  26917. /**
  26918. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26919. */
  26920. useGlossinessFromSpecularMapAlpha: boolean;
  26921. private _maxSimultaneousLights;
  26922. /**
  26923. * Defines the maximum number of lights that can be used in the material
  26924. */
  26925. maxSimultaneousLights: number;
  26926. private _invertNormalMapX;
  26927. /**
  26928. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26929. */
  26930. invertNormalMapX: boolean;
  26931. private _invertNormalMapY;
  26932. /**
  26933. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26934. */
  26935. invertNormalMapY: boolean;
  26936. private _twoSidedLighting;
  26937. /**
  26938. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26939. */
  26940. twoSidedLighting: boolean;
  26941. /**
  26942. * Default configuration related to image processing available in the standard Material.
  26943. */
  26944. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26945. /**
  26946. * Gets the image processing configuration used either in this material.
  26947. */
  26948. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26949. /**
  26950. * Sets the Default image processing configuration used either in the this material.
  26951. *
  26952. * If sets to null, the scene one is in use.
  26953. */
  26954. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26955. /**
  26956. * Keep track of the image processing observer to allow dispose and replace.
  26957. */
  26958. private _imageProcessingObserver;
  26959. /**
  26960. * Attaches a new image processing configuration to the Standard Material.
  26961. * @param configuration
  26962. */
  26963. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26964. /**
  26965. * Gets wether the color curves effect is enabled.
  26966. */
  26967. get cameraColorCurvesEnabled(): boolean;
  26968. /**
  26969. * Sets wether the color curves effect is enabled.
  26970. */
  26971. set cameraColorCurvesEnabled(value: boolean);
  26972. /**
  26973. * Gets wether the color grading effect is enabled.
  26974. */
  26975. get cameraColorGradingEnabled(): boolean;
  26976. /**
  26977. * Gets wether the color grading effect is enabled.
  26978. */
  26979. set cameraColorGradingEnabled(value: boolean);
  26980. /**
  26981. * Gets wether tonemapping is enabled or not.
  26982. */
  26983. get cameraToneMappingEnabled(): boolean;
  26984. /**
  26985. * Sets wether tonemapping is enabled or not
  26986. */
  26987. set cameraToneMappingEnabled(value: boolean);
  26988. /**
  26989. * The camera exposure used on this material.
  26990. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26991. * This corresponds to a photographic exposure.
  26992. */
  26993. get cameraExposure(): number;
  26994. /**
  26995. * The camera exposure used on this material.
  26996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26997. * This corresponds to a photographic exposure.
  26998. */
  26999. set cameraExposure(value: number);
  27000. /**
  27001. * Gets The camera contrast used on this material.
  27002. */
  27003. get cameraContrast(): number;
  27004. /**
  27005. * Sets The camera contrast used on this material.
  27006. */
  27007. set cameraContrast(value: number);
  27008. /**
  27009. * Gets the Color Grading 2D Lookup Texture.
  27010. */
  27011. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27012. /**
  27013. * Sets the Color Grading 2D Lookup Texture.
  27014. */
  27015. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27016. /**
  27017. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27018. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27019. * 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;
  27020. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27021. */
  27022. get cameraColorCurves(): Nullable<ColorCurves>;
  27023. /**
  27024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27026. * 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;
  27027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27028. */
  27029. set cameraColorCurves(value: Nullable<ColorCurves>);
  27030. /**
  27031. * Custom callback helping to override the default shader used in the material.
  27032. */
  27033. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27034. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27035. protected _worldViewProjectionMatrix: Matrix;
  27036. protected _globalAmbientColor: Color3;
  27037. protected _useLogarithmicDepth: boolean;
  27038. protected _rebuildInParallel: boolean;
  27039. /**
  27040. * Instantiates a new standard material.
  27041. * This is the default material used in Babylon. It is the best trade off between quality
  27042. * and performances.
  27043. * @see http://doc.babylonjs.com/babylon101/materials
  27044. * @param name Define the name of the material in the scene
  27045. * @param scene Define the scene the material belong to
  27046. */
  27047. constructor(name: string, scene: Scene);
  27048. /**
  27049. * Gets a boolean indicating that current material needs to register RTT
  27050. */
  27051. get hasRenderTargetTextures(): boolean;
  27052. /**
  27053. * Gets the current class name of the material e.g. "StandardMaterial"
  27054. * Mainly use in serialization.
  27055. * @returns the class name
  27056. */
  27057. getClassName(): string;
  27058. /**
  27059. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27060. * You can try switching to logarithmic depth.
  27061. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27062. */
  27063. get useLogarithmicDepth(): boolean;
  27064. set useLogarithmicDepth(value: boolean);
  27065. /**
  27066. * Specifies if the material will require alpha blending
  27067. * @returns a boolean specifying if alpha blending is needed
  27068. */
  27069. needAlphaBlending(): boolean;
  27070. /**
  27071. * Specifies if this material should be rendered in alpha test mode
  27072. * @returns a boolean specifying if an alpha test is needed.
  27073. */
  27074. needAlphaTesting(): boolean;
  27075. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27076. /**
  27077. * Get the texture used for alpha test purpose.
  27078. * @returns the diffuse texture in case of the standard material.
  27079. */
  27080. getAlphaTestTexture(): Nullable<BaseTexture>;
  27081. /**
  27082. * Get if the submesh is ready to be used and all its information available.
  27083. * Child classes can use it to update shaders
  27084. * @param mesh defines the mesh to check
  27085. * @param subMesh defines which submesh to check
  27086. * @param useInstances specifies that instances should be used
  27087. * @returns a boolean indicating that the submesh is ready or not
  27088. */
  27089. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27090. /**
  27091. * Builds the material UBO layouts.
  27092. * Used internally during the effect preparation.
  27093. */
  27094. buildUniformLayout(): void;
  27095. /**
  27096. * Unbinds the material from the mesh
  27097. */
  27098. unbind(): void;
  27099. /**
  27100. * Binds the submesh to this material by preparing the effect and shader to draw
  27101. * @param world defines the world transformation matrix
  27102. * @param mesh defines the mesh containing the submesh
  27103. * @param subMesh defines the submesh to bind the material to
  27104. */
  27105. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27106. /**
  27107. * Get the list of animatables in the material.
  27108. * @returns the list of animatables object used in the material
  27109. */
  27110. getAnimatables(): IAnimatable[];
  27111. /**
  27112. * Gets the active textures from the material
  27113. * @returns an array of textures
  27114. */
  27115. getActiveTextures(): BaseTexture[];
  27116. /**
  27117. * Specifies if the material uses a texture
  27118. * @param texture defines the texture to check against the material
  27119. * @returns a boolean specifying if the material uses the texture
  27120. */
  27121. hasTexture(texture: BaseTexture): boolean;
  27122. /**
  27123. * Disposes the material
  27124. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27125. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27126. */
  27127. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27128. /**
  27129. * Makes a duplicate of the material, and gives it a new name
  27130. * @param name defines the new name for the duplicated material
  27131. * @returns the cloned material
  27132. */
  27133. clone(name: string): StandardMaterial;
  27134. /**
  27135. * Serializes this material in a JSON representation
  27136. * @returns the serialized material object
  27137. */
  27138. serialize(): any;
  27139. /**
  27140. * Creates a standard material from parsed material data
  27141. * @param source defines the JSON representation of the material
  27142. * @param scene defines the hosting scene
  27143. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27144. * @returns a new standard material
  27145. */
  27146. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27147. /**
  27148. * Are diffuse textures enabled in the application.
  27149. */
  27150. static get DiffuseTextureEnabled(): boolean;
  27151. static set DiffuseTextureEnabled(value: boolean);
  27152. /**
  27153. * Are ambient textures enabled in the application.
  27154. */
  27155. static get AmbientTextureEnabled(): boolean;
  27156. static set AmbientTextureEnabled(value: boolean);
  27157. /**
  27158. * Are opacity textures enabled in the application.
  27159. */
  27160. static get OpacityTextureEnabled(): boolean;
  27161. static set OpacityTextureEnabled(value: boolean);
  27162. /**
  27163. * Are reflection textures enabled in the application.
  27164. */
  27165. static get ReflectionTextureEnabled(): boolean;
  27166. static set ReflectionTextureEnabled(value: boolean);
  27167. /**
  27168. * Are emissive textures enabled in the application.
  27169. */
  27170. static get EmissiveTextureEnabled(): boolean;
  27171. static set EmissiveTextureEnabled(value: boolean);
  27172. /**
  27173. * Are specular textures enabled in the application.
  27174. */
  27175. static get SpecularTextureEnabled(): boolean;
  27176. static set SpecularTextureEnabled(value: boolean);
  27177. /**
  27178. * Are bump textures enabled in the application.
  27179. */
  27180. static get BumpTextureEnabled(): boolean;
  27181. static set BumpTextureEnabled(value: boolean);
  27182. /**
  27183. * Are lightmap textures enabled in the application.
  27184. */
  27185. static get LightmapTextureEnabled(): boolean;
  27186. static set LightmapTextureEnabled(value: boolean);
  27187. /**
  27188. * Are refraction textures enabled in the application.
  27189. */
  27190. static get RefractionTextureEnabled(): boolean;
  27191. static set RefractionTextureEnabled(value: boolean);
  27192. /**
  27193. * Are color grading textures enabled in the application.
  27194. */
  27195. static get ColorGradingTextureEnabled(): boolean;
  27196. static set ColorGradingTextureEnabled(value: boolean);
  27197. /**
  27198. * Are fresnels enabled in the application.
  27199. */
  27200. static get FresnelEnabled(): boolean;
  27201. static set FresnelEnabled(value: boolean);
  27202. }
  27203. }
  27204. declare module BABYLON {
  27205. /**
  27206. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27207. *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.
  27208. * The SPS is also a particle system. It provides some methods to manage the particles.
  27209. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27210. *
  27211. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27212. */
  27213. export class SolidParticleSystem implements IDisposable {
  27214. /**
  27215. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27216. * Example : var p = SPS.particles[i];
  27217. */
  27218. particles: SolidParticle[];
  27219. /**
  27220. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27221. */
  27222. nbParticles: number;
  27223. /**
  27224. * If the particles must ever face the camera (default false). Useful for planar particles.
  27225. */
  27226. billboard: boolean;
  27227. /**
  27228. * Recompute normals when adding a shape
  27229. */
  27230. recomputeNormals: boolean;
  27231. /**
  27232. * This a counter ofr your own usage. It's not set by any SPS functions.
  27233. */
  27234. counter: number;
  27235. /**
  27236. * The SPS name. This name is also given to the underlying mesh.
  27237. */
  27238. name: string;
  27239. /**
  27240. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27241. */
  27242. mesh: Mesh;
  27243. /**
  27244. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27245. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27246. */
  27247. vars: any;
  27248. /**
  27249. * This array is populated when the SPS is set as 'pickable'.
  27250. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27251. * Each element of this array is an object `{idx: int, faceId: int}`.
  27252. * `idx` is the picked particle index in the `SPS.particles` array
  27253. * `faceId` is the picked face index counted within this particle.
  27254. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27255. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27256. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27257. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27258. */
  27259. pickedParticles: {
  27260. idx: number;
  27261. faceId: number;
  27262. }[];
  27263. /**
  27264. * This array is populated when the SPS is set as 'pickable'
  27265. * Each key of this array is a submesh index.
  27266. * Each element of this array is a second array defined like this :
  27267. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27268. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27269. * `idx` is the picked particle index in the `SPS.particles` array
  27270. * `faceId` is the picked face index counted within this particle.
  27271. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27272. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27273. */
  27274. pickedBySubMesh: {
  27275. idx: number;
  27276. faceId: number;
  27277. }[][];
  27278. /**
  27279. * This array is populated when `enableDepthSort` is set to true.
  27280. * Each element of this array is an instance of the class DepthSortedParticle.
  27281. */
  27282. depthSortedParticles: DepthSortedParticle[];
  27283. /**
  27284. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27285. * @hidden
  27286. */
  27287. _bSphereOnly: boolean;
  27288. /**
  27289. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27290. * @hidden
  27291. */
  27292. _bSphereRadiusFactor: number;
  27293. private _scene;
  27294. private _positions;
  27295. private _indices;
  27296. private _normals;
  27297. private _colors;
  27298. private _uvs;
  27299. private _indices32;
  27300. private _positions32;
  27301. private _normals32;
  27302. private _fixedNormal32;
  27303. private _colors32;
  27304. private _uvs32;
  27305. private _index;
  27306. private _updatable;
  27307. private _pickable;
  27308. private _isVisibilityBoxLocked;
  27309. private _alwaysVisible;
  27310. private _depthSort;
  27311. private _expandable;
  27312. private _shapeCounter;
  27313. private _copy;
  27314. private _color;
  27315. private _computeParticleColor;
  27316. private _computeParticleTexture;
  27317. private _computeParticleRotation;
  27318. private _computeParticleVertex;
  27319. private _computeBoundingBox;
  27320. private _depthSortParticles;
  27321. private _camera;
  27322. private _mustUnrotateFixedNormals;
  27323. private _particlesIntersect;
  27324. private _needs32Bits;
  27325. private _isNotBuilt;
  27326. private _lastParticleId;
  27327. private _idxOfId;
  27328. private _multimaterialEnabled;
  27329. private _useModelMaterial;
  27330. private _indicesByMaterial;
  27331. private _materialIndexes;
  27332. private _depthSortFunction;
  27333. private _materialSortFunction;
  27334. private _materials;
  27335. private _multimaterial;
  27336. private _materialIndexesById;
  27337. private _defaultMaterial;
  27338. private _autoUpdateSubMeshes;
  27339. /**
  27340. * Creates a SPS (Solid Particle System) object.
  27341. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27342. * @param scene (Scene) is the scene in which the SPS is added.
  27343. * @param options defines the options of the sps e.g.
  27344. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27345. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27346. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27347. * * 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.
  27348. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27349. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27350. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27351. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27352. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27353. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27354. */
  27355. constructor(name: string, scene: Scene, options?: {
  27356. updatable?: boolean;
  27357. isPickable?: boolean;
  27358. enableDepthSort?: boolean;
  27359. particleIntersection?: boolean;
  27360. boundingSphereOnly?: boolean;
  27361. bSphereRadiusFactor?: number;
  27362. expandable?: boolean;
  27363. useModelMaterial?: boolean;
  27364. enableMultiMaterial?: boolean;
  27365. });
  27366. /**
  27367. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27368. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27369. * @returns the created mesh
  27370. */
  27371. buildMesh(): Mesh;
  27372. /**
  27373. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27374. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27375. * Thus the particles generated from `digest()` have their property `position` set yet.
  27376. * @param mesh ( Mesh ) is the mesh to be digested
  27377. * @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
  27378. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27379. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27380. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27381. * @returns the current SPS
  27382. */
  27383. digest(mesh: Mesh, options?: {
  27384. facetNb?: number;
  27385. number?: number;
  27386. delta?: number;
  27387. storage?: [];
  27388. }): SolidParticleSystem;
  27389. /**
  27390. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27391. * @hidden
  27392. */
  27393. private _unrotateFixedNormals;
  27394. /**
  27395. * Resets the temporary working copy particle
  27396. * @hidden
  27397. */
  27398. private _resetCopy;
  27399. /**
  27400. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27401. * @param p the current index in the positions array to be updated
  27402. * @param ind the current index in the indices array
  27403. * @param shape a Vector3 array, the shape geometry
  27404. * @param positions the positions array to be updated
  27405. * @param meshInd the shape indices array
  27406. * @param indices the indices array to be updated
  27407. * @param meshUV the shape uv array
  27408. * @param uvs the uv array to be updated
  27409. * @param meshCol the shape color array
  27410. * @param colors the color array to be updated
  27411. * @param meshNor the shape normals array
  27412. * @param normals the normals array to be updated
  27413. * @param idx the particle index
  27414. * @param idxInShape the particle index in its shape
  27415. * @param options the addShape() method passed options
  27416. * @model the particle model
  27417. * @hidden
  27418. */
  27419. private _meshBuilder;
  27420. /**
  27421. * Returns a shape Vector3 array from positions float array
  27422. * @param positions float array
  27423. * @returns a vector3 array
  27424. * @hidden
  27425. */
  27426. private _posToShape;
  27427. /**
  27428. * Returns a shapeUV array from a float uvs (array deep copy)
  27429. * @param uvs as a float array
  27430. * @returns a shapeUV array
  27431. * @hidden
  27432. */
  27433. private _uvsToShapeUV;
  27434. /**
  27435. * Adds a new particle object in the particles array
  27436. * @param idx particle index in particles array
  27437. * @param id particle id
  27438. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27439. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27440. * @param model particle ModelShape object
  27441. * @param shapeId model shape identifier
  27442. * @param idxInShape index of the particle in the current model
  27443. * @param bInfo model bounding info object
  27444. * @param storage target storage array, if any
  27445. * @hidden
  27446. */
  27447. private _addParticle;
  27448. /**
  27449. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27450. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27451. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27452. * @param nb (positive integer) the number of particles to be created from this model
  27453. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27454. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27455. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27456. * @returns the number of shapes in the system
  27457. */
  27458. addShape(mesh: Mesh, nb: number, options?: {
  27459. positionFunction?: any;
  27460. vertexFunction?: any;
  27461. storage?: [];
  27462. }): number;
  27463. /**
  27464. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27465. * @hidden
  27466. */
  27467. private _rebuildParticle;
  27468. /**
  27469. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27470. * @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.
  27471. * @returns the SPS.
  27472. */
  27473. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27474. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27475. * Returns an array with the removed particles.
  27476. * 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.
  27477. * The SPS can't be empty so at least one particle needs to remain in place.
  27478. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27479. * @param start index of the first particle to remove
  27480. * @param end index of the last particle to remove (included)
  27481. * @returns an array populated with the removed particles
  27482. */
  27483. removeParticles(start: number, end: number): SolidParticle[];
  27484. /**
  27485. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27486. * @param solidParticleArray an array populated with Solid Particles objects
  27487. * @returns the SPS
  27488. */
  27489. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27490. /**
  27491. * Creates a new particle and modifies the SPS mesh geometry :
  27492. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27493. * - calls _addParticle() to populate the particle array
  27494. * factorized code from addShape() and insertParticlesFromArray()
  27495. * @param idx particle index in the particles array
  27496. * @param i particle index in its shape
  27497. * @param modelShape particle ModelShape object
  27498. * @param shape shape vertex array
  27499. * @param meshInd shape indices array
  27500. * @param meshUV shape uv array
  27501. * @param meshCol shape color array
  27502. * @param meshNor shape normals array
  27503. * @param bbInfo shape bounding info
  27504. * @param storage target particle storage
  27505. * @options addShape() passed options
  27506. * @hidden
  27507. */
  27508. private _insertNewParticle;
  27509. /**
  27510. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27511. * This method calls `updateParticle()` for each particle of the SPS.
  27512. * For an animated SPS, it is usually called within the render loop.
  27513. * 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.
  27514. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27515. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27516. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27517. * @returns the SPS.
  27518. */
  27519. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27520. /**
  27521. * Disposes the SPS.
  27522. */
  27523. dispose(): void;
  27524. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27525. * idx is the particle index in the SPS
  27526. * faceId is the picked face index counted within this particle.
  27527. * Returns null if the pickInfo can't identify a picked particle.
  27528. * @param pickingInfo (PickingInfo object)
  27529. * @returns {idx: number, faceId: number} or null
  27530. */
  27531. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27532. idx: number;
  27533. faceId: number;
  27534. }>;
  27535. /**
  27536. * Returns a SolidParticle object from its identifier : particle.id
  27537. * @param id (integer) the particle Id
  27538. * @returns the searched particle or null if not found in the SPS.
  27539. */
  27540. getParticleById(id: number): Nullable<SolidParticle>;
  27541. /**
  27542. * Returns a new array populated with the particles having the passed shapeId.
  27543. * @param shapeId (integer) the shape identifier
  27544. * @returns a new solid particle array
  27545. */
  27546. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27547. /**
  27548. * Populates the passed array "ref" with the particles having the passed shapeId.
  27549. * @param shapeId the shape identifier
  27550. * @returns the SPS
  27551. * @param ref
  27552. */
  27553. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27554. /**
  27555. * Computes the required SubMeshes according the materials assigned to the particles.
  27556. * @returns the solid particle system.
  27557. * Does nothing if called before the SPS mesh is built.
  27558. */
  27559. computeSubMeshes(): SolidParticleSystem;
  27560. /**
  27561. * Sorts the solid particles by material when MultiMaterial is enabled.
  27562. * Updates the indices32 array.
  27563. * Updates the indicesByMaterial array.
  27564. * Updates the mesh indices array.
  27565. * @returns the SPS
  27566. * @hidden
  27567. */
  27568. private _sortParticlesByMaterial;
  27569. /**
  27570. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27571. * @hidden
  27572. */
  27573. private _setMaterialIndexesById;
  27574. /**
  27575. * Returns an array with unique values of Materials from the passed array
  27576. * @param array the material array to be checked and filtered
  27577. * @hidden
  27578. */
  27579. private _filterUniqueMaterialId;
  27580. /**
  27581. * Sets a new Standard Material as _defaultMaterial if not already set.
  27582. * @hidden
  27583. */
  27584. private _setDefaultMaterial;
  27585. /**
  27586. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27587. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27588. * @returns the SPS.
  27589. */
  27590. refreshVisibleSize(): SolidParticleSystem;
  27591. /**
  27592. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27593. * @param size the size (float) of the visibility box
  27594. * note : this doesn't lock the SPS mesh bounding box.
  27595. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27596. */
  27597. setVisibilityBox(size: number): void;
  27598. /**
  27599. * Gets whether the SPS as always visible or not
  27600. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27601. */
  27602. get isAlwaysVisible(): boolean;
  27603. /**
  27604. * Sets the SPS as always visible or not
  27605. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27606. */
  27607. set isAlwaysVisible(val: boolean);
  27608. /**
  27609. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27610. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27611. */
  27612. set isVisibilityBoxLocked(val: boolean);
  27613. /**
  27614. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27615. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27616. */
  27617. get isVisibilityBoxLocked(): boolean;
  27618. /**
  27619. * Tells to `setParticles()` to compute the particle rotations or not.
  27620. * Default value : true. The SPS is faster when it's set to false.
  27621. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27622. */
  27623. set computeParticleRotation(val: boolean);
  27624. /**
  27625. * Tells to `setParticles()` to compute the particle colors or not.
  27626. * Default value : true. The SPS is faster when it's set to false.
  27627. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27628. */
  27629. set computeParticleColor(val: boolean);
  27630. set computeParticleTexture(val: boolean);
  27631. /**
  27632. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27633. * Default value : false. The SPS is faster when it's set to false.
  27634. * Note : the particle custom vertex positions aren't stored values.
  27635. */
  27636. set computeParticleVertex(val: boolean);
  27637. /**
  27638. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27639. */
  27640. set computeBoundingBox(val: boolean);
  27641. /**
  27642. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27643. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27644. * Default : `true`
  27645. */
  27646. set depthSortParticles(val: boolean);
  27647. /**
  27648. * Gets if `setParticles()` computes the particle rotations or not.
  27649. * Default value : true. The SPS is faster when it's set to false.
  27650. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27651. */
  27652. get computeParticleRotation(): boolean;
  27653. /**
  27654. * Gets if `setParticles()` computes the particle colors or not.
  27655. * Default value : true. The SPS is faster when it's set to false.
  27656. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27657. */
  27658. get computeParticleColor(): boolean;
  27659. /**
  27660. * Gets if `setParticles()` computes the particle textures or not.
  27661. * Default value : true. The SPS is faster when it's set to false.
  27662. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27663. */
  27664. get computeParticleTexture(): boolean;
  27665. /**
  27666. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27667. * Default value : false. The SPS is faster when it's set to false.
  27668. * Note : the particle custom vertex positions aren't stored values.
  27669. */
  27670. get computeParticleVertex(): boolean;
  27671. /**
  27672. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27673. */
  27674. get computeBoundingBox(): boolean;
  27675. /**
  27676. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27677. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27678. * Default : `true`
  27679. */
  27680. get depthSortParticles(): boolean;
  27681. /**
  27682. * Gets if the SPS is created as expandable at construction time.
  27683. * Default : `false`
  27684. */
  27685. get expandable(): boolean;
  27686. /**
  27687. * Gets if the SPS supports the Multi Materials
  27688. */
  27689. get multimaterialEnabled(): boolean;
  27690. /**
  27691. * Gets if the SPS uses the model materials for its own multimaterial.
  27692. */
  27693. get useModelMaterial(): boolean;
  27694. /**
  27695. * The SPS used material array.
  27696. */
  27697. get materials(): Material[];
  27698. /**
  27699. * Sets the SPS MultiMaterial from the passed materials.
  27700. * Note : the passed array is internally copied and not used then by reference.
  27701. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27702. */
  27703. setMultiMaterial(materials: Material[]): void;
  27704. /**
  27705. * The SPS computed multimaterial object
  27706. */
  27707. get multimaterial(): MultiMaterial;
  27708. set multimaterial(mm: MultiMaterial);
  27709. /**
  27710. * If the subMeshes must be updated on the next call to setParticles()
  27711. */
  27712. get autoUpdateSubMeshes(): boolean;
  27713. set autoUpdateSubMeshes(val: boolean);
  27714. /**
  27715. * This function does nothing. It may be overwritten to set all the particle first values.
  27716. * The SPS doesn't call this function, you may have to call it by your own.
  27717. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27718. */
  27719. initParticles(): void;
  27720. /**
  27721. * This function does nothing. It may be overwritten to recycle a particle.
  27722. * The SPS doesn't call this function, you may have to call it by your own.
  27723. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27724. * @param particle The particle to recycle
  27725. * @returns the recycled particle
  27726. */
  27727. recycleParticle(particle: SolidParticle): SolidParticle;
  27728. /**
  27729. * Updates a particle : this function should be overwritten by the user.
  27730. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27731. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27732. * @example : just set a particle position or velocity and recycle conditions
  27733. * @param particle The particle to update
  27734. * @returns the updated particle
  27735. */
  27736. updateParticle(particle: SolidParticle): SolidParticle;
  27737. /**
  27738. * Updates a vertex of a particle : it can be overwritten by the user.
  27739. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27740. * @param particle the current particle
  27741. * @param vertex the current index of the current particle
  27742. * @param pt the index of the current vertex in the particle shape
  27743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27744. * @example : just set a vertex particle position
  27745. * @returns the updated vertex
  27746. */
  27747. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27748. /**
  27749. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27750. * This does nothing and may be overwritten by the user.
  27751. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27752. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27753. * @param update the boolean update value actually passed to setParticles()
  27754. */
  27755. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27756. /**
  27757. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27758. * This will be passed three parameters.
  27759. * This does nothing and may be overwritten by the user.
  27760. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27761. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27762. * @param update the boolean update value actually passed to setParticles()
  27763. */
  27764. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27765. }
  27766. }
  27767. declare module BABYLON {
  27768. /**
  27769. * Represents one particle of a solid particle system.
  27770. */
  27771. export class SolidParticle {
  27772. /**
  27773. * particle global index
  27774. */
  27775. idx: number;
  27776. /**
  27777. * particle identifier
  27778. */
  27779. id: number;
  27780. /**
  27781. * The color of the particle
  27782. */
  27783. color: Nullable<Color4>;
  27784. /**
  27785. * The world space position of the particle.
  27786. */
  27787. position: Vector3;
  27788. /**
  27789. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27790. */
  27791. rotation: Vector3;
  27792. /**
  27793. * The world space rotation quaternion of the particle.
  27794. */
  27795. rotationQuaternion: Nullable<Quaternion>;
  27796. /**
  27797. * The scaling of the particle.
  27798. */
  27799. scaling: Vector3;
  27800. /**
  27801. * The uvs of the particle.
  27802. */
  27803. uvs: Vector4;
  27804. /**
  27805. * The current speed of the particle.
  27806. */
  27807. velocity: Vector3;
  27808. /**
  27809. * The pivot point in the particle local space.
  27810. */
  27811. pivot: Vector3;
  27812. /**
  27813. * Must the particle be translated from its pivot point in its local space ?
  27814. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27815. * Default : false
  27816. */
  27817. translateFromPivot: boolean;
  27818. /**
  27819. * Is the particle active or not ?
  27820. */
  27821. alive: boolean;
  27822. /**
  27823. * Is the particle visible or not ?
  27824. */
  27825. isVisible: boolean;
  27826. /**
  27827. * Index of this particle in the global "positions" array (Internal use)
  27828. * @hidden
  27829. */
  27830. _pos: number;
  27831. /**
  27832. * @hidden Index of this particle in the global "indices" array (Internal use)
  27833. */
  27834. _ind: number;
  27835. /**
  27836. * @hidden ModelShape of this particle (Internal use)
  27837. */
  27838. _model: ModelShape;
  27839. /**
  27840. * ModelShape id of this particle
  27841. */
  27842. shapeId: number;
  27843. /**
  27844. * Index of the particle in its shape id
  27845. */
  27846. idxInShape: number;
  27847. /**
  27848. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27849. */
  27850. _modelBoundingInfo: BoundingInfo;
  27851. /**
  27852. * @hidden Particle BoundingInfo object (Internal use)
  27853. */
  27854. _boundingInfo: BoundingInfo;
  27855. /**
  27856. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27857. */
  27858. _sps: SolidParticleSystem;
  27859. /**
  27860. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27861. */
  27862. _stillInvisible: boolean;
  27863. /**
  27864. * @hidden Last computed particle rotation matrix
  27865. */
  27866. _rotationMatrix: number[];
  27867. /**
  27868. * Parent particle Id, if any.
  27869. * Default null.
  27870. */
  27871. parentId: Nullable<number>;
  27872. /**
  27873. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27874. */
  27875. materialIndex: Nullable<number>;
  27876. /**
  27877. * Custom object or properties.
  27878. */
  27879. props: Nullable<any>;
  27880. /**
  27881. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27882. * The possible values are :
  27883. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27884. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27885. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27886. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27887. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27888. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27889. * */
  27890. cullingStrategy: number;
  27891. /**
  27892. * @hidden Internal global position in the SPS.
  27893. */
  27894. _globalPosition: Vector3;
  27895. /**
  27896. * Creates a Solid Particle object.
  27897. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27898. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27899. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27900. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27901. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27902. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27903. * @param shapeId (integer) is the model shape identifier in the SPS.
  27904. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27905. * @param sps defines the sps it is associated to
  27906. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27907. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27908. */
  27909. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27910. /**
  27911. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27912. * @param target the particle target
  27913. * @returns the current particle
  27914. */
  27915. copyToRef(target: SolidParticle): SolidParticle;
  27916. /**
  27917. * Legacy support, changed scale to scaling
  27918. */
  27919. get scale(): Vector3;
  27920. /**
  27921. * Legacy support, changed scale to scaling
  27922. */
  27923. set scale(scale: Vector3);
  27924. /**
  27925. * Legacy support, changed quaternion to rotationQuaternion
  27926. */
  27927. get quaternion(): Nullable<Quaternion>;
  27928. /**
  27929. * Legacy support, changed quaternion to rotationQuaternion
  27930. */
  27931. set quaternion(q: Nullable<Quaternion>);
  27932. /**
  27933. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27934. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27935. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27936. * @returns true if it intersects
  27937. */
  27938. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27939. /**
  27940. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27941. * A particle is in the frustum if its bounding box intersects the frustum
  27942. * @param frustumPlanes defines the frustum to test
  27943. * @returns true if the particle is in the frustum planes
  27944. */
  27945. isInFrustum(frustumPlanes: Plane[]): boolean;
  27946. /**
  27947. * get the rotation matrix of the particle
  27948. * @hidden
  27949. */
  27950. getRotationMatrix(m: Matrix): void;
  27951. }
  27952. /**
  27953. * Represents the shape of the model used by one particle of a solid particle system.
  27954. * SPS internal tool, don't use it manually.
  27955. */
  27956. export class ModelShape {
  27957. /**
  27958. * The shape id
  27959. * @hidden
  27960. */
  27961. shapeID: number;
  27962. /**
  27963. * flat array of model positions (internal use)
  27964. * @hidden
  27965. */
  27966. _shape: Vector3[];
  27967. /**
  27968. * flat array of model UVs (internal use)
  27969. * @hidden
  27970. */
  27971. _shapeUV: number[];
  27972. /**
  27973. * color array of the model
  27974. * @hidden
  27975. */
  27976. _shapeColors: number[];
  27977. /**
  27978. * indices array of the model
  27979. * @hidden
  27980. */
  27981. _indices: number[];
  27982. /**
  27983. * normals array of the model
  27984. * @hidden
  27985. */
  27986. _normals: number[];
  27987. /**
  27988. * length of the shape in the model indices array (internal use)
  27989. * @hidden
  27990. */
  27991. _indicesLength: number;
  27992. /**
  27993. * Custom position function (internal use)
  27994. * @hidden
  27995. */
  27996. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27997. /**
  27998. * Custom vertex function (internal use)
  27999. * @hidden
  28000. */
  28001. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28002. /**
  28003. * Model material (internal use)
  28004. * @hidden
  28005. */
  28006. _material: Nullable<Material>;
  28007. /**
  28008. * 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.
  28009. * SPS internal tool, don't use it manually.
  28010. * @hidden
  28011. */
  28012. 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>);
  28013. }
  28014. /**
  28015. * Represents a Depth Sorted Particle in the solid particle system.
  28016. * @hidden
  28017. */
  28018. export class DepthSortedParticle {
  28019. /**
  28020. * Particle index
  28021. */
  28022. idx: number;
  28023. /**
  28024. * Index of the particle in the "indices" array
  28025. */
  28026. ind: number;
  28027. /**
  28028. * Length of the particle shape in the "indices" array
  28029. */
  28030. indicesLength: number;
  28031. /**
  28032. * Squared distance from the particle to the camera
  28033. */
  28034. sqDistance: number;
  28035. /**
  28036. * Material index when used with MultiMaterials
  28037. */
  28038. materialIndex: number;
  28039. /**
  28040. * Creates a new sorted particle
  28041. * @param materialIndex
  28042. */
  28043. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28044. }
  28045. }
  28046. declare module BABYLON {
  28047. /**
  28048. * @hidden
  28049. */
  28050. export class _MeshCollisionData {
  28051. _checkCollisions: boolean;
  28052. _collisionMask: number;
  28053. _collisionGroup: number;
  28054. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28055. _collider: Nullable<Collider>;
  28056. _oldPositionForCollisions: Vector3;
  28057. _diffPositionForCollisions: Vector3;
  28058. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28059. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28060. }
  28061. }
  28062. declare module BABYLON {
  28063. /** @hidden */
  28064. class _FacetDataStorage {
  28065. facetPositions: Vector3[];
  28066. facetNormals: Vector3[];
  28067. facetPartitioning: number[][];
  28068. facetNb: number;
  28069. partitioningSubdivisions: number;
  28070. partitioningBBoxRatio: number;
  28071. facetDataEnabled: boolean;
  28072. facetParameters: any;
  28073. bbSize: Vector3;
  28074. subDiv: {
  28075. max: number;
  28076. X: number;
  28077. Y: number;
  28078. Z: number;
  28079. };
  28080. facetDepthSort: boolean;
  28081. facetDepthSortEnabled: boolean;
  28082. depthSortedIndices: IndicesArray;
  28083. depthSortedFacets: {
  28084. ind: number;
  28085. sqDistance: number;
  28086. }[];
  28087. facetDepthSortFunction: (f1: {
  28088. ind: number;
  28089. sqDistance: number;
  28090. }, f2: {
  28091. ind: number;
  28092. sqDistance: number;
  28093. }) => number;
  28094. facetDepthSortFrom: Vector3;
  28095. facetDepthSortOrigin: Vector3;
  28096. invertedMatrix: Matrix;
  28097. }
  28098. /**
  28099. * @hidden
  28100. **/
  28101. class _InternalAbstractMeshDataInfo {
  28102. _hasVertexAlpha: boolean;
  28103. _useVertexColors: boolean;
  28104. _numBoneInfluencers: number;
  28105. _applyFog: boolean;
  28106. _receiveShadows: boolean;
  28107. _facetData: _FacetDataStorage;
  28108. _visibility: number;
  28109. _skeleton: Nullable<Skeleton>;
  28110. _layerMask: number;
  28111. _computeBonesUsingShaders: boolean;
  28112. _isActive: boolean;
  28113. _onlyForInstances: boolean;
  28114. _isActiveIntermediate: boolean;
  28115. _onlyForInstancesIntermediate: boolean;
  28116. _actAsRegularMesh: boolean;
  28117. }
  28118. /**
  28119. * Class used to store all common mesh properties
  28120. */
  28121. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28122. /** No occlusion */
  28123. static OCCLUSION_TYPE_NONE: number;
  28124. /** Occlusion set to optimisitic */
  28125. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28126. /** Occlusion set to strict */
  28127. static OCCLUSION_TYPE_STRICT: number;
  28128. /** Use an accurante occlusion algorithm */
  28129. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28130. /** Use a conservative occlusion algorithm */
  28131. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28132. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28133. * Test order :
  28134. * Is the bounding sphere outside the frustum ?
  28135. * If not, are the bounding box vertices outside the frustum ?
  28136. * It not, then the cullable object is in the frustum.
  28137. */
  28138. static readonly CULLINGSTRATEGY_STANDARD: number;
  28139. /** Culling strategy : Bounding Sphere Only.
  28140. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28141. * It's also less accurate than the standard because some not visible objects can still be selected.
  28142. * Test : is the bounding sphere outside the frustum ?
  28143. * If not, then the cullable object is in the frustum.
  28144. */
  28145. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28146. /** Culling strategy : Optimistic Inclusion.
  28147. * This in an inclusion test first, then the standard exclusion test.
  28148. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28149. * 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.
  28150. * Anyway, it's as accurate as the standard strategy.
  28151. * Test :
  28152. * Is the cullable object bounding sphere center in the frustum ?
  28153. * If not, apply the default culling strategy.
  28154. */
  28155. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28156. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28157. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28158. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28159. * 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.
  28160. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28161. * Test :
  28162. * Is the cullable object bounding sphere center in the frustum ?
  28163. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28164. */
  28165. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28166. /**
  28167. * No billboard
  28168. */
  28169. static get BILLBOARDMODE_NONE(): number;
  28170. /** Billboard on X axis */
  28171. static get BILLBOARDMODE_X(): number;
  28172. /** Billboard on Y axis */
  28173. static get BILLBOARDMODE_Y(): number;
  28174. /** Billboard on Z axis */
  28175. static get BILLBOARDMODE_Z(): number;
  28176. /** Billboard on all axes */
  28177. static get BILLBOARDMODE_ALL(): number;
  28178. /** Billboard on using position instead of orientation */
  28179. static get BILLBOARDMODE_USE_POSITION(): number;
  28180. /** @hidden */
  28181. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28182. /**
  28183. * The culling strategy to use to check whether the mesh must be rendered or not.
  28184. * This value can be changed at any time and will be used on the next render mesh selection.
  28185. * The possible values are :
  28186. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28187. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28188. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28190. * Please read each static variable documentation to get details about the culling process.
  28191. * */
  28192. cullingStrategy: number;
  28193. /**
  28194. * Gets the number of facets in the mesh
  28195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28196. */
  28197. get facetNb(): number;
  28198. /**
  28199. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28200. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28201. */
  28202. get partitioningSubdivisions(): number;
  28203. set partitioningSubdivisions(nb: number);
  28204. /**
  28205. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28206. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28208. */
  28209. get partitioningBBoxRatio(): number;
  28210. set partitioningBBoxRatio(ratio: number);
  28211. /**
  28212. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28213. * Works only for updatable meshes.
  28214. * Doesn't work with multi-materials
  28215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28216. */
  28217. get mustDepthSortFacets(): boolean;
  28218. set mustDepthSortFacets(sort: boolean);
  28219. /**
  28220. * The location (Vector3) where the facet depth sort must be computed from.
  28221. * By default, the active camera position.
  28222. * Used only when facet depth sort is enabled
  28223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28224. */
  28225. get facetDepthSortFrom(): Vector3;
  28226. set facetDepthSortFrom(location: Vector3);
  28227. /**
  28228. * gets a boolean indicating if facetData is enabled
  28229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28230. */
  28231. get isFacetDataEnabled(): boolean;
  28232. /** @hidden */
  28233. _updateNonUniformScalingState(value: boolean): boolean;
  28234. /**
  28235. * An event triggered when this mesh collides with another one
  28236. */
  28237. onCollideObservable: Observable<AbstractMesh>;
  28238. /** Set a function to call when this mesh collides with another one */
  28239. set onCollide(callback: () => void);
  28240. /**
  28241. * An event triggered when the collision's position changes
  28242. */
  28243. onCollisionPositionChangeObservable: Observable<Vector3>;
  28244. /** Set a function to call when the collision's position changes */
  28245. set onCollisionPositionChange(callback: () => void);
  28246. /**
  28247. * An event triggered when material is changed
  28248. */
  28249. onMaterialChangedObservable: Observable<AbstractMesh>;
  28250. /**
  28251. * Gets or sets the orientation for POV movement & rotation
  28252. */
  28253. definedFacingForward: boolean;
  28254. /** @hidden */
  28255. _occlusionQuery: Nullable<WebGLQuery>;
  28256. /** @hidden */
  28257. _renderingGroup: Nullable<RenderingGroup>;
  28258. /**
  28259. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28260. */
  28261. get visibility(): number;
  28262. /**
  28263. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28264. */
  28265. set visibility(value: number);
  28266. /** Gets or sets the alpha index used to sort transparent meshes
  28267. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28268. */
  28269. alphaIndex: number;
  28270. /**
  28271. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28272. */
  28273. isVisible: boolean;
  28274. /**
  28275. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28276. */
  28277. isPickable: boolean;
  28278. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28279. showSubMeshesBoundingBox: boolean;
  28280. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28281. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28282. */
  28283. isBlocker: boolean;
  28284. /**
  28285. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28286. */
  28287. enablePointerMoveEvents: boolean;
  28288. /**
  28289. * Specifies the rendering group id for this mesh (0 by default)
  28290. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28291. */
  28292. renderingGroupId: number;
  28293. private _material;
  28294. /** Gets or sets current material */
  28295. get material(): Nullable<Material>;
  28296. set material(value: Nullable<Material>);
  28297. /**
  28298. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28299. * @see http://doc.babylonjs.com/babylon101/shadows
  28300. */
  28301. get receiveShadows(): boolean;
  28302. set receiveShadows(value: boolean);
  28303. /** Defines color to use when rendering outline */
  28304. outlineColor: Color3;
  28305. /** Define width to use when rendering outline */
  28306. outlineWidth: number;
  28307. /** Defines color to use when rendering overlay */
  28308. overlayColor: Color3;
  28309. /** Defines alpha to use when rendering overlay */
  28310. overlayAlpha: number;
  28311. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28312. get hasVertexAlpha(): boolean;
  28313. set hasVertexAlpha(value: boolean);
  28314. /** 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) */
  28315. get useVertexColors(): boolean;
  28316. set useVertexColors(value: boolean);
  28317. /**
  28318. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28319. */
  28320. get computeBonesUsingShaders(): boolean;
  28321. set computeBonesUsingShaders(value: boolean);
  28322. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28323. get numBoneInfluencers(): number;
  28324. set numBoneInfluencers(value: number);
  28325. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28326. get applyFog(): boolean;
  28327. set applyFog(value: boolean);
  28328. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28329. useOctreeForRenderingSelection: boolean;
  28330. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28331. useOctreeForPicking: boolean;
  28332. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28333. useOctreeForCollisions: boolean;
  28334. /**
  28335. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28336. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28337. */
  28338. get layerMask(): number;
  28339. set layerMask(value: number);
  28340. /**
  28341. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28342. */
  28343. alwaysSelectAsActiveMesh: boolean;
  28344. /**
  28345. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28346. */
  28347. doNotSyncBoundingInfo: boolean;
  28348. /**
  28349. * Gets or sets the current action manager
  28350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28351. */
  28352. actionManager: Nullable<AbstractActionManager>;
  28353. private _meshCollisionData;
  28354. /**
  28355. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28357. */
  28358. ellipsoid: Vector3;
  28359. /**
  28360. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28361. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28362. */
  28363. ellipsoidOffset: Vector3;
  28364. /**
  28365. * Gets or sets a collision mask used to mask collisions (default is -1).
  28366. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28367. */
  28368. get collisionMask(): number;
  28369. set collisionMask(mask: number);
  28370. /**
  28371. * Gets or sets the current collision group mask (-1 by default).
  28372. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28373. */
  28374. get collisionGroup(): number;
  28375. set collisionGroup(mask: number);
  28376. /**
  28377. * Gets or sets current surrounding meshes (null by default).
  28378. *
  28379. * By default collision detection is tested against every mesh in the scene.
  28380. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28381. * meshes will be tested for the collision.
  28382. *
  28383. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28384. */
  28385. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28386. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28387. /**
  28388. * Defines edge width used when edgesRenderer is enabled
  28389. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28390. */
  28391. edgesWidth: number;
  28392. /**
  28393. * Defines edge color used when edgesRenderer is enabled
  28394. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28395. */
  28396. edgesColor: Color4;
  28397. /** @hidden */
  28398. _edgesRenderer: Nullable<IEdgesRenderer>;
  28399. /** @hidden */
  28400. _masterMesh: Nullable<AbstractMesh>;
  28401. /** @hidden */
  28402. _boundingInfo: Nullable<BoundingInfo>;
  28403. /** @hidden */
  28404. _renderId: number;
  28405. /**
  28406. * Gets or sets the list of subMeshes
  28407. * @see http://doc.babylonjs.com/how_to/multi_materials
  28408. */
  28409. subMeshes: SubMesh[];
  28410. /** @hidden */
  28411. _intersectionsInProgress: AbstractMesh[];
  28412. /** @hidden */
  28413. _unIndexed: boolean;
  28414. /** @hidden */
  28415. _lightSources: Light[];
  28416. /** Gets the list of lights affecting that mesh */
  28417. get lightSources(): Light[];
  28418. /** @hidden */
  28419. get _positions(): Nullable<Vector3[]>;
  28420. /** @hidden */
  28421. _waitingData: {
  28422. lods: Nullable<any>;
  28423. actions: Nullable<any>;
  28424. freezeWorldMatrix: Nullable<boolean>;
  28425. };
  28426. /** @hidden */
  28427. _bonesTransformMatrices: Nullable<Float32Array>;
  28428. /** @hidden */
  28429. _transformMatrixTexture: Nullable<RawTexture>;
  28430. /**
  28431. * Gets or sets a skeleton to apply skining transformations
  28432. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28433. */
  28434. set skeleton(value: Nullable<Skeleton>);
  28435. get skeleton(): Nullable<Skeleton>;
  28436. /**
  28437. * An event triggered when the mesh is rebuilt.
  28438. */
  28439. onRebuildObservable: Observable<AbstractMesh>;
  28440. /**
  28441. * Creates a new AbstractMesh
  28442. * @param name defines the name of the mesh
  28443. * @param scene defines the hosting scene
  28444. */
  28445. constructor(name: string, scene?: Nullable<Scene>);
  28446. /**
  28447. * Returns the string "AbstractMesh"
  28448. * @returns "AbstractMesh"
  28449. */
  28450. getClassName(): string;
  28451. /**
  28452. * Gets a string representation of the current mesh
  28453. * @param fullDetails defines a boolean indicating if full details must be included
  28454. * @returns a string representation of the current mesh
  28455. */
  28456. toString(fullDetails?: boolean): string;
  28457. /**
  28458. * @hidden
  28459. */
  28460. protected _getEffectiveParent(): Nullable<Node>;
  28461. /** @hidden */
  28462. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28463. /** @hidden */
  28464. _rebuild(): void;
  28465. /** @hidden */
  28466. _resyncLightSources(): void;
  28467. /** @hidden */
  28468. _resyncLightSource(light: Light): void;
  28469. /** @hidden */
  28470. _unBindEffect(): void;
  28471. /** @hidden */
  28472. _removeLightSource(light: Light, dispose: boolean): void;
  28473. private _markSubMeshesAsDirty;
  28474. /** @hidden */
  28475. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28476. /** @hidden */
  28477. _markSubMeshesAsAttributesDirty(): void;
  28478. /** @hidden */
  28479. _markSubMeshesAsMiscDirty(): void;
  28480. /**
  28481. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28482. */
  28483. get scaling(): Vector3;
  28484. set scaling(newScaling: Vector3);
  28485. /**
  28486. * Returns true if the mesh is blocked. Implemented by child classes
  28487. */
  28488. get isBlocked(): boolean;
  28489. /**
  28490. * Returns the mesh itself by default. Implemented by child classes
  28491. * @param camera defines the camera to use to pick the right LOD level
  28492. * @returns the currentAbstractMesh
  28493. */
  28494. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28495. /**
  28496. * Returns 0 by default. Implemented by child classes
  28497. * @returns an integer
  28498. */
  28499. getTotalVertices(): number;
  28500. /**
  28501. * Returns a positive integer : the total number of indices in this mesh geometry.
  28502. * @returns the numner of indices or zero if the mesh has no geometry.
  28503. */
  28504. getTotalIndices(): number;
  28505. /**
  28506. * Returns null by default. Implemented by child classes
  28507. * @returns null
  28508. */
  28509. getIndices(): Nullable<IndicesArray>;
  28510. /**
  28511. * Returns the array of the requested vertex data kind. Implemented by child classes
  28512. * @param kind defines the vertex data kind to use
  28513. * @returns null
  28514. */
  28515. getVerticesData(kind: string): Nullable<FloatArray>;
  28516. /**
  28517. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28518. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28519. * Note that a new underlying VertexBuffer object is created each call.
  28520. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28521. * @param kind defines vertex data kind:
  28522. * * VertexBuffer.PositionKind
  28523. * * VertexBuffer.UVKind
  28524. * * VertexBuffer.UV2Kind
  28525. * * VertexBuffer.UV3Kind
  28526. * * VertexBuffer.UV4Kind
  28527. * * VertexBuffer.UV5Kind
  28528. * * VertexBuffer.UV6Kind
  28529. * * VertexBuffer.ColorKind
  28530. * * VertexBuffer.MatricesIndicesKind
  28531. * * VertexBuffer.MatricesIndicesExtraKind
  28532. * * VertexBuffer.MatricesWeightsKind
  28533. * * VertexBuffer.MatricesWeightsExtraKind
  28534. * @param data defines the data source
  28535. * @param updatable defines if the data must be flagged as updatable (or static)
  28536. * @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
  28537. * @returns the current mesh
  28538. */
  28539. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28540. /**
  28541. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28542. * If the mesh has no geometry, it is simply returned as it is.
  28543. * @param kind defines vertex data kind:
  28544. * * VertexBuffer.PositionKind
  28545. * * VertexBuffer.UVKind
  28546. * * VertexBuffer.UV2Kind
  28547. * * VertexBuffer.UV3Kind
  28548. * * VertexBuffer.UV4Kind
  28549. * * VertexBuffer.UV5Kind
  28550. * * VertexBuffer.UV6Kind
  28551. * * VertexBuffer.ColorKind
  28552. * * VertexBuffer.MatricesIndicesKind
  28553. * * VertexBuffer.MatricesIndicesExtraKind
  28554. * * VertexBuffer.MatricesWeightsKind
  28555. * * VertexBuffer.MatricesWeightsExtraKind
  28556. * @param data defines the data source
  28557. * @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
  28558. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28559. * @returns the current mesh
  28560. */
  28561. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28562. /**
  28563. * Sets the mesh indices,
  28564. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28565. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28566. * @param totalVertices Defines the total number of vertices
  28567. * @returns the current mesh
  28568. */
  28569. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28570. /**
  28571. * Gets a boolean indicating if specific vertex data is present
  28572. * @param kind defines the vertex data kind to use
  28573. * @returns true is data kind is present
  28574. */
  28575. isVerticesDataPresent(kind: string): boolean;
  28576. /**
  28577. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28578. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28579. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28580. * @returns a BoundingInfo
  28581. */
  28582. getBoundingInfo(): BoundingInfo;
  28583. /**
  28584. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28585. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28586. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28587. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28588. * @returns the current mesh
  28589. */
  28590. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28591. /**
  28592. * Overwrite the current bounding info
  28593. * @param boundingInfo defines the new bounding info
  28594. * @returns the current mesh
  28595. */
  28596. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28597. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28598. get useBones(): boolean;
  28599. /** @hidden */
  28600. _preActivate(): void;
  28601. /** @hidden */
  28602. _preActivateForIntermediateRendering(renderId: number): void;
  28603. /** @hidden */
  28604. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28605. /** @hidden */
  28606. _postActivate(): void;
  28607. /** @hidden */
  28608. _freeze(): void;
  28609. /** @hidden */
  28610. _unFreeze(): void;
  28611. /**
  28612. * Gets the current world matrix
  28613. * @returns a Matrix
  28614. */
  28615. getWorldMatrix(): Matrix;
  28616. /** @hidden */
  28617. _getWorldMatrixDeterminant(): number;
  28618. /**
  28619. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28620. */
  28621. get isAnInstance(): boolean;
  28622. /**
  28623. * Gets a boolean indicating if this mesh has instances
  28624. */
  28625. get hasInstances(): boolean;
  28626. /**
  28627. * Perform relative position change from the point of view of behind the front of the mesh.
  28628. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28629. * Supports definition of mesh facing forward or backward
  28630. * @param amountRight defines the distance on the right axis
  28631. * @param amountUp defines the distance on the up axis
  28632. * @param amountForward defines the distance on the forward axis
  28633. * @returns the current mesh
  28634. */
  28635. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28636. /**
  28637. * Calculate relative position change from the point of view of behind the front of the mesh.
  28638. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28639. * Supports definition of mesh facing forward or backward
  28640. * @param amountRight defines the distance on the right axis
  28641. * @param amountUp defines the distance on the up axis
  28642. * @param amountForward defines the distance on the forward axis
  28643. * @returns the new displacement vector
  28644. */
  28645. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28646. /**
  28647. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28648. * Supports definition of mesh facing forward or backward
  28649. * @param flipBack defines the flip
  28650. * @param twirlClockwise defines the twirl
  28651. * @param tiltRight defines the tilt
  28652. * @returns the current mesh
  28653. */
  28654. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28655. /**
  28656. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28657. * Supports definition of mesh facing forward or backward.
  28658. * @param flipBack defines the flip
  28659. * @param twirlClockwise defines the twirl
  28660. * @param tiltRight defines the tilt
  28661. * @returns the new rotation vector
  28662. */
  28663. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28664. /**
  28665. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28666. * This means the mesh underlying bounding box and sphere are recomputed.
  28667. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28668. * @returns the current mesh
  28669. */
  28670. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28671. /** @hidden */
  28672. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28673. /** @hidden */
  28674. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28675. /** @hidden */
  28676. _updateBoundingInfo(): AbstractMesh;
  28677. /** @hidden */
  28678. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28679. /** @hidden */
  28680. protected _afterComputeWorldMatrix(): void;
  28681. /** @hidden */
  28682. get _effectiveMesh(): AbstractMesh;
  28683. /**
  28684. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28685. * A mesh is in the frustum if its bounding box intersects the frustum
  28686. * @param frustumPlanes defines the frustum to test
  28687. * @returns true if the mesh is in the frustum planes
  28688. */
  28689. isInFrustum(frustumPlanes: Plane[]): boolean;
  28690. /**
  28691. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28692. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28693. * @param frustumPlanes defines the frustum to test
  28694. * @returns true if the mesh is completely in the frustum planes
  28695. */
  28696. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28697. /**
  28698. * True if the mesh intersects another mesh or a SolidParticle object
  28699. * @param mesh defines a target mesh or SolidParticle to test
  28700. * @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)
  28701. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28702. * @returns true if there is an intersection
  28703. */
  28704. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28705. /**
  28706. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28707. * @param point defines the point to test
  28708. * @returns true if there is an intersection
  28709. */
  28710. intersectsPoint(point: Vector3): boolean;
  28711. /**
  28712. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28713. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28714. */
  28715. get checkCollisions(): boolean;
  28716. set checkCollisions(collisionEnabled: boolean);
  28717. /**
  28718. * Gets Collider object used to compute collisions (not physics)
  28719. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28720. */
  28721. get collider(): Nullable<Collider>;
  28722. /**
  28723. * Move the mesh using collision engine
  28724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28725. * @param displacement defines the requested displacement vector
  28726. * @returns the current mesh
  28727. */
  28728. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28729. private _onCollisionPositionChange;
  28730. /** @hidden */
  28731. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28732. /** @hidden */
  28733. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28734. /** @hidden */
  28735. _checkCollision(collider: Collider): AbstractMesh;
  28736. /** @hidden */
  28737. _generatePointsArray(): boolean;
  28738. /**
  28739. * Checks if the passed Ray intersects with the mesh
  28740. * @param ray defines the ray to use
  28741. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28742. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28743. * @returns the picking info
  28744. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28745. */
  28746. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28747. /**
  28748. * Clones the current mesh
  28749. * @param name defines the mesh name
  28750. * @param newParent defines the new mesh parent
  28751. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28752. * @returns the new mesh
  28753. */
  28754. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28755. /**
  28756. * Disposes all the submeshes of the current meshnp
  28757. * @returns the current mesh
  28758. */
  28759. releaseSubMeshes(): AbstractMesh;
  28760. /**
  28761. * Releases resources associated with this abstract mesh.
  28762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28764. */
  28765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28766. /**
  28767. * Adds the passed mesh as a child to the current mesh
  28768. * @param mesh defines the child mesh
  28769. * @returns the current mesh
  28770. */
  28771. addChild(mesh: AbstractMesh): AbstractMesh;
  28772. /**
  28773. * Removes the passed mesh from the current mesh children list
  28774. * @param mesh defines the child mesh
  28775. * @returns the current mesh
  28776. */
  28777. removeChild(mesh: AbstractMesh): AbstractMesh;
  28778. /** @hidden */
  28779. private _initFacetData;
  28780. /**
  28781. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28782. * This method can be called within the render loop.
  28783. * 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
  28784. * @returns the current mesh
  28785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28786. */
  28787. updateFacetData(): AbstractMesh;
  28788. /**
  28789. * Returns the facetLocalNormals array.
  28790. * The normals are expressed in the mesh local spac
  28791. * @returns an array of Vector3
  28792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28793. */
  28794. getFacetLocalNormals(): Vector3[];
  28795. /**
  28796. * Returns the facetLocalPositions array.
  28797. * The facet positions are expressed in the mesh local space
  28798. * @returns an array of Vector3
  28799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28800. */
  28801. getFacetLocalPositions(): Vector3[];
  28802. /**
  28803. * Returns the facetLocalPartioning array
  28804. * @returns an array of array of numbers
  28805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28806. */
  28807. getFacetLocalPartitioning(): number[][];
  28808. /**
  28809. * Returns the i-th facet position in the world system.
  28810. * This method allocates a new Vector3 per call
  28811. * @param i defines the facet index
  28812. * @returns a new Vector3
  28813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28814. */
  28815. getFacetPosition(i: number): Vector3;
  28816. /**
  28817. * Sets the reference Vector3 with the i-th facet position in the world system
  28818. * @param i defines the facet index
  28819. * @param ref defines the target vector
  28820. * @returns the current mesh
  28821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28822. */
  28823. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28824. /**
  28825. * Returns the i-th facet normal in the world system.
  28826. * This method allocates a new Vector3 per call
  28827. * @param i defines the facet index
  28828. * @returns a new Vector3
  28829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28830. */
  28831. getFacetNormal(i: number): Vector3;
  28832. /**
  28833. * Sets the reference Vector3 with the i-th facet normal in the world system
  28834. * @param i defines the facet index
  28835. * @param ref defines the target vector
  28836. * @returns the current mesh
  28837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28838. */
  28839. getFacetNormalToRef(i: number, ref: Vector3): this;
  28840. /**
  28841. * 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)
  28842. * @param x defines x coordinate
  28843. * @param y defines y coordinate
  28844. * @param z defines z coordinate
  28845. * @returns the array of facet indexes
  28846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28847. */
  28848. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28849. /**
  28850. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28851. * @param projected sets as the (x,y,z) world projection on the facet
  28852. * @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
  28853. * @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
  28854. * @param x defines x coordinate
  28855. * @param y defines y coordinate
  28856. * @param z defines z coordinate
  28857. * @returns the face index if found (or null instead)
  28858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28859. */
  28860. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28861. /**
  28862. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28863. * @param projected sets as the (x,y,z) local projection on the facet
  28864. * @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
  28865. * @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
  28866. * @param x defines x coordinate
  28867. * @param y defines y coordinate
  28868. * @param z defines z coordinate
  28869. * @returns the face index if found (or null instead)
  28870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28871. */
  28872. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28873. /**
  28874. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28875. * @returns the parameters
  28876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28877. */
  28878. getFacetDataParameters(): any;
  28879. /**
  28880. * Disables the feature FacetData and frees the related memory
  28881. * @returns the current mesh
  28882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28883. */
  28884. disableFacetData(): AbstractMesh;
  28885. /**
  28886. * Updates the AbstractMesh indices array
  28887. * @param indices defines the data source
  28888. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28889. * @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)
  28890. * @returns the current mesh
  28891. */
  28892. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28893. /**
  28894. * Creates new normals data for the mesh
  28895. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28896. * @returns the current mesh
  28897. */
  28898. createNormals(updatable: boolean): AbstractMesh;
  28899. /**
  28900. * Align the mesh with a normal
  28901. * @param normal defines the normal to use
  28902. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28903. * @returns the current mesh
  28904. */
  28905. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28906. /** @hidden */
  28907. _checkOcclusionQuery(): boolean;
  28908. /**
  28909. * Disables the mesh edge rendering mode
  28910. * @returns the currentAbstractMesh
  28911. */
  28912. disableEdgesRendering(): AbstractMesh;
  28913. /**
  28914. * Enables the edge rendering mode on the mesh.
  28915. * This mode makes the mesh edges visible
  28916. * @param epsilon defines the maximal distance between two angles to detect a face
  28917. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28918. * @returns the currentAbstractMesh
  28919. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28920. */
  28921. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28922. }
  28923. }
  28924. declare module BABYLON {
  28925. /**
  28926. * Interface used to define ActionEvent
  28927. */
  28928. export interface IActionEvent {
  28929. /** The mesh or sprite that triggered the action */
  28930. source: any;
  28931. /** The X mouse cursor position at the time of the event */
  28932. pointerX: number;
  28933. /** The Y mouse cursor position at the time of the event */
  28934. pointerY: number;
  28935. /** The mesh that is currently pointed at (can be null) */
  28936. meshUnderPointer: Nullable<AbstractMesh>;
  28937. /** the original (browser) event that triggered the ActionEvent */
  28938. sourceEvent?: any;
  28939. /** additional data for the event */
  28940. additionalData?: any;
  28941. }
  28942. /**
  28943. * ActionEvent is the event being sent when an action is triggered.
  28944. */
  28945. export class ActionEvent implements IActionEvent {
  28946. /** The mesh or sprite that triggered the action */
  28947. source: any;
  28948. /** The X mouse cursor position at the time of the event */
  28949. pointerX: number;
  28950. /** The Y mouse cursor position at the time of the event */
  28951. pointerY: number;
  28952. /** The mesh that is currently pointed at (can be null) */
  28953. meshUnderPointer: Nullable<AbstractMesh>;
  28954. /** the original (browser) event that triggered the ActionEvent */
  28955. sourceEvent?: any;
  28956. /** additional data for the event */
  28957. additionalData?: any;
  28958. /**
  28959. * Creates a new ActionEvent
  28960. * @param source The mesh or sprite that triggered the action
  28961. * @param pointerX The X mouse cursor position at the time of the event
  28962. * @param pointerY The Y mouse cursor position at the time of the event
  28963. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28964. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28965. * @param additionalData additional data for the event
  28966. */
  28967. constructor(
  28968. /** The mesh or sprite that triggered the action */
  28969. source: any,
  28970. /** The X mouse cursor position at the time of the event */
  28971. pointerX: number,
  28972. /** The Y mouse cursor position at the time of the event */
  28973. pointerY: number,
  28974. /** The mesh that is currently pointed at (can be null) */
  28975. meshUnderPointer: Nullable<AbstractMesh>,
  28976. /** the original (browser) event that triggered the ActionEvent */
  28977. sourceEvent?: any,
  28978. /** additional data for the event */
  28979. additionalData?: any);
  28980. /**
  28981. * Helper function to auto-create an ActionEvent from a source mesh.
  28982. * @param source The source mesh that triggered the event
  28983. * @param evt The original (browser) event
  28984. * @param additionalData additional data for the event
  28985. * @returns the new ActionEvent
  28986. */
  28987. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28988. /**
  28989. * Helper function to auto-create an ActionEvent from a source sprite
  28990. * @param source The source sprite that triggered the event
  28991. * @param scene Scene associated with the sprite
  28992. * @param evt The original (browser) event
  28993. * @param additionalData additional data for the event
  28994. * @returns the new ActionEvent
  28995. */
  28996. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28997. /**
  28998. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28999. * @param scene the scene where the event occurred
  29000. * @param evt The original (browser) event
  29001. * @returns the new ActionEvent
  29002. */
  29003. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29004. /**
  29005. * Helper function to auto-create an ActionEvent from a primitive
  29006. * @param prim defines the target primitive
  29007. * @param pointerPos defines the pointer position
  29008. * @param evt The original (browser) event
  29009. * @param additionalData additional data for the event
  29010. * @returns the new ActionEvent
  29011. */
  29012. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29013. }
  29014. }
  29015. declare module BABYLON {
  29016. /**
  29017. * Abstract class used to decouple action Manager from scene and meshes.
  29018. * Do not instantiate.
  29019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29020. */
  29021. export abstract class AbstractActionManager implements IDisposable {
  29022. /** Gets the list of active triggers */
  29023. static Triggers: {
  29024. [key: string]: number;
  29025. };
  29026. /** Gets the cursor to use when hovering items */
  29027. hoverCursor: string;
  29028. /** Gets the list of actions */
  29029. actions: IAction[];
  29030. /**
  29031. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29032. */
  29033. isRecursive: boolean;
  29034. /**
  29035. * Releases all associated resources
  29036. */
  29037. abstract dispose(): void;
  29038. /**
  29039. * Does this action manager has pointer triggers
  29040. */
  29041. abstract get hasPointerTriggers(): boolean;
  29042. /**
  29043. * Does this action manager has pick triggers
  29044. */
  29045. abstract get hasPickTriggers(): boolean;
  29046. /**
  29047. * Process a specific trigger
  29048. * @param trigger defines the trigger to process
  29049. * @param evt defines the event details to be processed
  29050. */
  29051. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29052. /**
  29053. * Does this action manager handles actions of any of the given triggers
  29054. * @param triggers defines the triggers to be tested
  29055. * @return a boolean indicating whether one (or more) of the triggers is handled
  29056. */
  29057. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29058. /**
  29059. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29060. * speed.
  29061. * @param triggerA defines the trigger to be tested
  29062. * @param triggerB defines the trigger to be tested
  29063. * @return a boolean indicating whether one (or more) of the triggers is handled
  29064. */
  29065. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29066. /**
  29067. * Does this action manager handles actions of a given trigger
  29068. * @param trigger defines the trigger to be tested
  29069. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29070. * @return whether the trigger is handled
  29071. */
  29072. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29073. /**
  29074. * Serialize this manager to a JSON object
  29075. * @param name defines the property name to store this manager
  29076. * @returns a JSON representation of this manager
  29077. */
  29078. abstract serialize(name: string): any;
  29079. /**
  29080. * Registers an action to this action manager
  29081. * @param action defines the action to be registered
  29082. * @return the action amended (prepared) after registration
  29083. */
  29084. abstract registerAction(action: IAction): Nullable<IAction>;
  29085. /**
  29086. * Unregisters an action to this action manager
  29087. * @param action defines the action to be unregistered
  29088. * @return a boolean indicating whether the action has been unregistered
  29089. */
  29090. abstract unregisterAction(action: IAction): Boolean;
  29091. /**
  29092. * Does exist one action manager with at least one trigger
  29093. **/
  29094. static get HasTriggers(): boolean;
  29095. /**
  29096. * Does exist one action manager with at least one pick trigger
  29097. **/
  29098. static get HasPickTriggers(): boolean;
  29099. /**
  29100. * Does exist one action manager that handles actions of a given trigger
  29101. * @param trigger defines the trigger to be tested
  29102. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29103. **/
  29104. static HasSpecificTrigger(trigger: number): boolean;
  29105. }
  29106. }
  29107. declare module BABYLON {
  29108. /**
  29109. * Defines how a node can be built from a string name.
  29110. */
  29111. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29112. /**
  29113. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29114. */
  29115. export class Node implements IBehaviorAware<Node> {
  29116. /** @hidden */
  29117. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29118. private static _NodeConstructors;
  29119. /**
  29120. * Add a new node constructor
  29121. * @param type defines the type name of the node to construct
  29122. * @param constructorFunc defines the constructor function
  29123. */
  29124. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29125. /**
  29126. * Returns a node constructor based on type name
  29127. * @param type defines the type name
  29128. * @param name defines the new node name
  29129. * @param scene defines the hosting scene
  29130. * @param options defines optional options to transmit to constructors
  29131. * @returns the new constructor or null
  29132. */
  29133. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29134. /**
  29135. * Gets or sets the name of the node
  29136. */
  29137. name: string;
  29138. /**
  29139. * Gets or sets the id of the node
  29140. */
  29141. id: string;
  29142. /**
  29143. * Gets or sets the unique id of the node
  29144. */
  29145. uniqueId: number;
  29146. /**
  29147. * Gets or sets a string used to store user defined state for the node
  29148. */
  29149. state: string;
  29150. /**
  29151. * Gets or sets an object used to store user defined information for the node
  29152. */
  29153. metadata: any;
  29154. /**
  29155. * For internal use only. Please do not use.
  29156. */
  29157. reservedDataStore: any;
  29158. /**
  29159. * List of inspectable custom properties (used by the Inspector)
  29160. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29161. */
  29162. inspectableCustomProperties: IInspectable[];
  29163. private _doNotSerialize;
  29164. /**
  29165. * Gets or sets a boolean used to define if the node must be serialized
  29166. */
  29167. get doNotSerialize(): boolean;
  29168. set doNotSerialize(value: boolean);
  29169. /** @hidden */
  29170. _isDisposed: boolean;
  29171. /**
  29172. * Gets a list of Animations associated with the node
  29173. */
  29174. animations: Animation[];
  29175. protected _ranges: {
  29176. [name: string]: Nullable<AnimationRange>;
  29177. };
  29178. /**
  29179. * Callback raised when the node is ready to be used
  29180. */
  29181. onReady: Nullable<(node: Node) => void>;
  29182. private _isEnabled;
  29183. private _isParentEnabled;
  29184. private _isReady;
  29185. /** @hidden */
  29186. _currentRenderId: number;
  29187. private _parentUpdateId;
  29188. /** @hidden */
  29189. _childUpdateId: number;
  29190. /** @hidden */
  29191. _waitingParentId: Nullable<string>;
  29192. /** @hidden */
  29193. _scene: Scene;
  29194. /** @hidden */
  29195. _cache: any;
  29196. private _parentNode;
  29197. private _children;
  29198. /** @hidden */
  29199. _worldMatrix: Matrix;
  29200. /** @hidden */
  29201. _worldMatrixDeterminant: number;
  29202. /** @hidden */
  29203. _worldMatrixDeterminantIsDirty: boolean;
  29204. /** @hidden */
  29205. private _sceneRootNodesIndex;
  29206. /**
  29207. * Gets a boolean indicating if the node has been disposed
  29208. * @returns true if the node was disposed
  29209. */
  29210. isDisposed(): boolean;
  29211. /**
  29212. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29213. * @see https://doc.babylonjs.com/how_to/parenting
  29214. */
  29215. set parent(parent: Nullable<Node>);
  29216. get parent(): Nullable<Node>;
  29217. /** @hidden */
  29218. _addToSceneRootNodes(): void;
  29219. /** @hidden */
  29220. _removeFromSceneRootNodes(): void;
  29221. private _animationPropertiesOverride;
  29222. /**
  29223. * Gets or sets the animation properties override
  29224. */
  29225. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29226. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29227. /**
  29228. * Gets a string idenfifying the name of the class
  29229. * @returns "Node" string
  29230. */
  29231. getClassName(): string;
  29232. /** @hidden */
  29233. readonly _isNode: boolean;
  29234. /**
  29235. * An event triggered when the mesh is disposed
  29236. */
  29237. onDisposeObservable: Observable<Node>;
  29238. private _onDisposeObserver;
  29239. /**
  29240. * Sets a callback that will be raised when the node will be disposed
  29241. */
  29242. set onDispose(callback: () => void);
  29243. /**
  29244. * Creates a new Node
  29245. * @param name the name and id to be given to this node
  29246. * @param scene the scene this node will be added to
  29247. */
  29248. constructor(name: string, scene?: Nullable<Scene>);
  29249. /**
  29250. * Gets the scene of the node
  29251. * @returns a scene
  29252. */
  29253. getScene(): Scene;
  29254. /**
  29255. * Gets the engine of the node
  29256. * @returns a Engine
  29257. */
  29258. getEngine(): Engine;
  29259. private _behaviors;
  29260. /**
  29261. * Attach a behavior to the node
  29262. * @see http://doc.babylonjs.com/features/behaviour
  29263. * @param behavior defines the behavior to attach
  29264. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29265. * @returns the current Node
  29266. */
  29267. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29268. /**
  29269. * Remove an attached behavior
  29270. * @see http://doc.babylonjs.com/features/behaviour
  29271. * @param behavior defines the behavior to attach
  29272. * @returns the current Node
  29273. */
  29274. removeBehavior(behavior: Behavior<Node>): Node;
  29275. /**
  29276. * Gets the list of attached behaviors
  29277. * @see http://doc.babylonjs.com/features/behaviour
  29278. */
  29279. get behaviors(): Behavior<Node>[];
  29280. /**
  29281. * Gets an attached behavior by name
  29282. * @param name defines the name of the behavior to look for
  29283. * @see http://doc.babylonjs.com/features/behaviour
  29284. * @returns null if behavior was not found else the requested behavior
  29285. */
  29286. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29287. /**
  29288. * Returns the latest update of the World matrix
  29289. * @returns a Matrix
  29290. */
  29291. getWorldMatrix(): Matrix;
  29292. /** @hidden */
  29293. _getWorldMatrixDeterminant(): number;
  29294. /**
  29295. * Returns directly the latest state of the mesh World matrix.
  29296. * A Matrix is returned.
  29297. */
  29298. get worldMatrixFromCache(): Matrix;
  29299. /** @hidden */
  29300. _initCache(): void;
  29301. /** @hidden */
  29302. updateCache(force?: boolean): void;
  29303. /** @hidden */
  29304. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29305. /** @hidden */
  29306. _updateCache(ignoreParentClass?: boolean): void;
  29307. /** @hidden */
  29308. _isSynchronized(): boolean;
  29309. /** @hidden */
  29310. _markSyncedWithParent(): void;
  29311. /** @hidden */
  29312. isSynchronizedWithParent(): boolean;
  29313. /** @hidden */
  29314. isSynchronized(): boolean;
  29315. /**
  29316. * Is this node ready to be used/rendered
  29317. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29318. * @return true if the node is ready
  29319. */
  29320. isReady(completeCheck?: boolean): boolean;
  29321. /**
  29322. * Is this node enabled?
  29323. * 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
  29324. * @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
  29325. * @return whether this node (and its parent) is enabled
  29326. */
  29327. isEnabled(checkAncestors?: boolean): boolean;
  29328. /** @hidden */
  29329. protected _syncParentEnabledState(): void;
  29330. /**
  29331. * Set the enabled state of this node
  29332. * @param value defines the new enabled state
  29333. */
  29334. setEnabled(value: boolean): void;
  29335. /**
  29336. * Is this node a descendant of the given node?
  29337. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29338. * @param ancestor defines the parent node to inspect
  29339. * @returns a boolean indicating if this node is a descendant of the given node
  29340. */
  29341. isDescendantOf(ancestor: Node): boolean;
  29342. /** @hidden */
  29343. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29344. /**
  29345. * Will return all nodes that have this node as ascendant
  29346. * @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
  29347. * @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
  29348. * @return all children nodes of all types
  29349. */
  29350. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29351. /**
  29352. * Get all child-meshes of this node
  29353. * @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)
  29354. * @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
  29355. * @returns an array of AbstractMesh
  29356. */
  29357. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29358. /**
  29359. * Get all direct children of this node
  29360. * @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
  29361. * @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)
  29362. * @returns an array of Node
  29363. */
  29364. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29365. /** @hidden */
  29366. _setReady(state: boolean): void;
  29367. /**
  29368. * Get an animation by name
  29369. * @param name defines the name of the animation to look for
  29370. * @returns null if not found else the requested animation
  29371. */
  29372. getAnimationByName(name: string): Nullable<Animation>;
  29373. /**
  29374. * Creates an animation range for this node
  29375. * @param name defines the name of the range
  29376. * @param from defines the starting key
  29377. * @param to defines the end key
  29378. */
  29379. createAnimationRange(name: string, from: number, to: number): void;
  29380. /**
  29381. * Delete a specific animation range
  29382. * @param name defines the name of the range to delete
  29383. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29384. */
  29385. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29386. /**
  29387. * Get an animation range by name
  29388. * @param name defines the name of the animation range to look for
  29389. * @returns null if not found else the requested animation range
  29390. */
  29391. getAnimationRange(name: string): Nullable<AnimationRange>;
  29392. /**
  29393. * Gets the list of all animation ranges defined on this node
  29394. * @returns an array
  29395. */
  29396. getAnimationRanges(): Nullable<AnimationRange>[];
  29397. /**
  29398. * Will start the animation sequence
  29399. * @param name defines the range frames for animation sequence
  29400. * @param loop defines if the animation should loop (false by default)
  29401. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29402. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29403. * @returns the object created for this animation. If range does not exist, it will return null
  29404. */
  29405. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29406. /**
  29407. * Serialize animation ranges into a JSON compatible object
  29408. * @returns serialization object
  29409. */
  29410. serializeAnimationRanges(): any;
  29411. /**
  29412. * Computes the world matrix of the node
  29413. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29414. * @returns the world matrix
  29415. */
  29416. computeWorldMatrix(force?: boolean): Matrix;
  29417. /**
  29418. * Releases resources associated with this node.
  29419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29421. */
  29422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29423. /**
  29424. * Parse animation range data from a serialization object and store them into a given node
  29425. * @param node defines where to store the animation ranges
  29426. * @param parsedNode defines the serialization object to read data from
  29427. * @param scene defines the hosting scene
  29428. */
  29429. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29430. /**
  29431. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29432. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29433. * @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
  29434. * @returns the new bounding vectors
  29435. */
  29436. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29437. min: Vector3;
  29438. max: Vector3;
  29439. };
  29440. }
  29441. }
  29442. declare module BABYLON {
  29443. /**
  29444. * @hidden
  29445. */
  29446. export class _IAnimationState {
  29447. key: number;
  29448. repeatCount: number;
  29449. workValue?: any;
  29450. loopMode?: number;
  29451. offsetValue?: any;
  29452. highLimitValue?: any;
  29453. }
  29454. /**
  29455. * Class used to store any kind of animation
  29456. */
  29457. export class Animation {
  29458. /**Name of the animation */
  29459. name: string;
  29460. /**Property to animate */
  29461. targetProperty: string;
  29462. /**The frames per second of the animation */
  29463. framePerSecond: number;
  29464. /**The data type of the animation */
  29465. dataType: number;
  29466. /**The loop mode of the animation */
  29467. loopMode?: number | undefined;
  29468. /**Specifies if blending should be enabled */
  29469. enableBlending?: boolean | undefined;
  29470. /**
  29471. * Use matrix interpolation instead of using direct key value when animating matrices
  29472. */
  29473. static AllowMatricesInterpolation: boolean;
  29474. /**
  29475. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29476. */
  29477. static AllowMatrixDecomposeForInterpolation: boolean;
  29478. /**
  29479. * Stores the key frames of the animation
  29480. */
  29481. private _keys;
  29482. /**
  29483. * Stores the easing function of the animation
  29484. */
  29485. private _easingFunction;
  29486. /**
  29487. * @hidden Internal use only
  29488. */
  29489. _runtimeAnimations: RuntimeAnimation[];
  29490. /**
  29491. * The set of event that will be linked to this animation
  29492. */
  29493. private _events;
  29494. /**
  29495. * Stores an array of target property paths
  29496. */
  29497. targetPropertyPath: string[];
  29498. /**
  29499. * Stores the blending speed of the animation
  29500. */
  29501. blendingSpeed: number;
  29502. /**
  29503. * Stores the animation ranges for the animation
  29504. */
  29505. private _ranges;
  29506. /**
  29507. * @hidden Internal use
  29508. */
  29509. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29510. /**
  29511. * Sets up an animation
  29512. * @param property The property to animate
  29513. * @param animationType The animation type to apply
  29514. * @param framePerSecond The frames per second of the animation
  29515. * @param easingFunction The easing function used in the animation
  29516. * @returns The created animation
  29517. */
  29518. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29519. /**
  29520. * Create and start an animation on a node
  29521. * @param name defines the name of the global animation that will be run on all nodes
  29522. * @param node defines the root node where the animation will take place
  29523. * @param targetProperty defines property to animate
  29524. * @param framePerSecond defines the number of frame per second yo use
  29525. * @param totalFrame defines the number of frames in total
  29526. * @param from defines the initial value
  29527. * @param to defines the final value
  29528. * @param loopMode defines which loop mode you want to use (off by default)
  29529. * @param easingFunction defines the easing function to use (linear by default)
  29530. * @param onAnimationEnd defines the callback to call when animation end
  29531. * @returns the animatable created for this animation
  29532. */
  29533. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29534. /**
  29535. * Create and start an animation on a node and its descendants
  29536. * @param name defines the name of the global animation that will be run on all nodes
  29537. * @param node defines the root node where the animation will take place
  29538. * @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
  29539. * @param targetProperty defines property to animate
  29540. * @param framePerSecond defines the number of frame per second to use
  29541. * @param totalFrame defines the number of frames in total
  29542. * @param from defines the initial value
  29543. * @param to defines the final value
  29544. * @param loopMode defines which loop mode you want to use (off by default)
  29545. * @param easingFunction defines the easing function to use (linear by default)
  29546. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29547. * @returns the list of animatables created for all nodes
  29548. * @example https://www.babylonjs-playground.com/#MH0VLI
  29549. */
  29550. 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[]>;
  29551. /**
  29552. * Creates a new animation, merges it with the existing animations and starts it
  29553. * @param name Name of the animation
  29554. * @param node Node which contains the scene that begins the animations
  29555. * @param targetProperty Specifies which property to animate
  29556. * @param framePerSecond The frames per second of the animation
  29557. * @param totalFrame The total number of frames
  29558. * @param from The frame at the beginning of the animation
  29559. * @param to The frame at the end of the animation
  29560. * @param loopMode Specifies the loop mode of the animation
  29561. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29562. * @param onAnimationEnd Callback to run once the animation is complete
  29563. * @returns Nullable animation
  29564. */
  29565. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29566. /**
  29567. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29568. * @param sourceAnimation defines the Animation containing keyframes to convert
  29569. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29570. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29571. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29572. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29573. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29574. */
  29575. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29576. /**
  29577. * Transition property of an host to the target Value
  29578. * @param property The property to transition
  29579. * @param targetValue The target Value of the property
  29580. * @param host The object where the property to animate belongs
  29581. * @param scene Scene used to run the animation
  29582. * @param frameRate Framerate (in frame/s) to use
  29583. * @param transition The transition type we want to use
  29584. * @param duration The duration of the animation, in milliseconds
  29585. * @param onAnimationEnd Callback trigger at the end of the animation
  29586. * @returns Nullable animation
  29587. */
  29588. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29589. /**
  29590. * Return the array of runtime animations currently using this animation
  29591. */
  29592. get runtimeAnimations(): RuntimeAnimation[];
  29593. /**
  29594. * Specifies if any of the runtime animations are currently running
  29595. */
  29596. get hasRunningRuntimeAnimations(): boolean;
  29597. /**
  29598. * Initializes the animation
  29599. * @param name Name of the animation
  29600. * @param targetProperty Property to animate
  29601. * @param framePerSecond The frames per second of the animation
  29602. * @param dataType The data type of the animation
  29603. * @param loopMode The loop mode of the animation
  29604. * @param enableBlending Specifies if blending should be enabled
  29605. */
  29606. constructor(
  29607. /**Name of the animation */
  29608. name: string,
  29609. /**Property to animate */
  29610. targetProperty: string,
  29611. /**The frames per second of the animation */
  29612. framePerSecond: number,
  29613. /**The data type of the animation */
  29614. dataType: number,
  29615. /**The loop mode of the animation */
  29616. loopMode?: number | undefined,
  29617. /**Specifies if blending should be enabled */
  29618. enableBlending?: boolean | undefined);
  29619. /**
  29620. * Converts the animation to a string
  29621. * @param fullDetails support for multiple levels of logging within scene loading
  29622. * @returns String form of the animation
  29623. */
  29624. toString(fullDetails?: boolean): string;
  29625. /**
  29626. * Add an event to this animation
  29627. * @param event Event to add
  29628. */
  29629. addEvent(event: AnimationEvent): void;
  29630. /**
  29631. * Remove all events found at the given frame
  29632. * @param frame The frame to remove events from
  29633. */
  29634. removeEvents(frame: number): void;
  29635. /**
  29636. * Retrieves all the events from the animation
  29637. * @returns Events from the animation
  29638. */
  29639. getEvents(): AnimationEvent[];
  29640. /**
  29641. * Creates an animation range
  29642. * @param name Name of the animation range
  29643. * @param from Starting frame of the animation range
  29644. * @param to Ending frame of the animation
  29645. */
  29646. createRange(name: string, from: number, to: number): void;
  29647. /**
  29648. * Deletes an animation range by name
  29649. * @param name Name of the animation range to delete
  29650. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29651. */
  29652. deleteRange(name: string, deleteFrames?: boolean): void;
  29653. /**
  29654. * Gets the animation range by name, or null if not defined
  29655. * @param name Name of the animation range
  29656. * @returns Nullable animation range
  29657. */
  29658. getRange(name: string): Nullable<AnimationRange>;
  29659. /**
  29660. * Gets the key frames from the animation
  29661. * @returns The key frames of the animation
  29662. */
  29663. getKeys(): Array<IAnimationKey>;
  29664. /**
  29665. * Gets the highest frame rate of the animation
  29666. * @returns Highest frame rate of the animation
  29667. */
  29668. getHighestFrame(): number;
  29669. /**
  29670. * Gets the easing function of the animation
  29671. * @returns Easing function of the animation
  29672. */
  29673. getEasingFunction(): IEasingFunction;
  29674. /**
  29675. * Sets the easing function of the animation
  29676. * @param easingFunction A custom mathematical formula for animation
  29677. */
  29678. setEasingFunction(easingFunction: EasingFunction): void;
  29679. /**
  29680. * Interpolates a scalar linearly
  29681. * @param startValue Start value of the animation curve
  29682. * @param endValue End value of the animation curve
  29683. * @param gradient Scalar amount to interpolate
  29684. * @returns Interpolated scalar value
  29685. */
  29686. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29687. /**
  29688. * Interpolates a scalar cubically
  29689. * @param startValue Start value of the animation curve
  29690. * @param outTangent End tangent of the animation
  29691. * @param endValue End value of the animation curve
  29692. * @param inTangent Start tangent of the animation curve
  29693. * @param gradient Scalar amount to interpolate
  29694. * @returns Interpolated scalar value
  29695. */
  29696. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29697. /**
  29698. * Interpolates a quaternion using a spherical linear interpolation
  29699. * @param startValue Start value of the animation curve
  29700. * @param endValue End value of the animation curve
  29701. * @param gradient Scalar amount to interpolate
  29702. * @returns Interpolated quaternion value
  29703. */
  29704. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29705. /**
  29706. * Interpolates a quaternion cubically
  29707. * @param startValue Start value of the animation curve
  29708. * @param outTangent End tangent of the animation curve
  29709. * @param endValue End value of the animation curve
  29710. * @param inTangent Start tangent of the animation curve
  29711. * @param gradient Scalar amount to interpolate
  29712. * @returns Interpolated quaternion value
  29713. */
  29714. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29715. /**
  29716. * Interpolates a Vector3 linearl
  29717. * @param startValue Start value of the animation curve
  29718. * @param endValue End value of the animation curve
  29719. * @param gradient Scalar amount to interpolate
  29720. * @returns Interpolated scalar value
  29721. */
  29722. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29723. /**
  29724. * Interpolates a Vector3 cubically
  29725. * @param startValue Start value of the animation curve
  29726. * @param outTangent End tangent of the animation
  29727. * @param endValue End value of the animation curve
  29728. * @param inTangent Start tangent of the animation curve
  29729. * @param gradient Scalar amount to interpolate
  29730. * @returns InterpolatedVector3 value
  29731. */
  29732. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29733. /**
  29734. * Interpolates a Vector2 linearly
  29735. * @param startValue Start value of the animation curve
  29736. * @param endValue End value of the animation curve
  29737. * @param gradient Scalar amount to interpolate
  29738. * @returns Interpolated Vector2 value
  29739. */
  29740. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29741. /**
  29742. * Interpolates a Vector2 cubically
  29743. * @param startValue Start value of the animation curve
  29744. * @param outTangent End tangent of the animation
  29745. * @param endValue End value of the animation curve
  29746. * @param inTangent Start tangent of the animation curve
  29747. * @param gradient Scalar amount to interpolate
  29748. * @returns Interpolated Vector2 value
  29749. */
  29750. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29751. /**
  29752. * Interpolates a size linearly
  29753. * @param startValue Start value of the animation curve
  29754. * @param endValue End value of the animation curve
  29755. * @param gradient Scalar amount to interpolate
  29756. * @returns Interpolated Size value
  29757. */
  29758. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29759. /**
  29760. * Interpolates a Color3 linearly
  29761. * @param startValue Start value of the animation curve
  29762. * @param endValue End value of the animation curve
  29763. * @param gradient Scalar amount to interpolate
  29764. * @returns Interpolated Color3 value
  29765. */
  29766. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29767. /**
  29768. * Interpolates a Color4 linearly
  29769. * @param startValue Start value of the animation curve
  29770. * @param endValue End value of the animation curve
  29771. * @param gradient Scalar amount to interpolate
  29772. * @returns Interpolated Color3 value
  29773. */
  29774. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29775. /**
  29776. * @hidden Internal use only
  29777. */
  29778. _getKeyValue(value: any): any;
  29779. /**
  29780. * @hidden Internal use only
  29781. */
  29782. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29783. /**
  29784. * Defines the function to use to interpolate matrices
  29785. * @param startValue defines the start matrix
  29786. * @param endValue defines the end matrix
  29787. * @param gradient defines the gradient between both matrices
  29788. * @param result defines an optional target matrix where to store the interpolation
  29789. * @returns the interpolated matrix
  29790. */
  29791. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29792. /**
  29793. * Makes a copy of the animation
  29794. * @returns Cloned animation
  29795. */
  29796. clone(): Animation;
  29797. /**
  29798. * Sets the key frames of the animation
  29799. * @param values The animation key frames to set
  29800. */
  29801. setKeys(values: Array<IAnimationKey>): void;
  29802. /**
  29803. * Serializes the animation to an object
  29804. * @returns Serialized object
  29805. */
  29806. serialize(): any;
  29807. /**
  29808. * Float animation type
  29809. */
  29810. static readonly ANIMATIONTYPE_FLOAT: number;
  29811. /**
  29812. * Vector3 animation type
  29813. */
  29814. static readonly ANIMATIONTYPE_VECTOR3: number;
  29815. /**
  29816. * Quaternion animation type
  29817. */
  29818. static readonly ANIMATIONTYPE_QUATERNION: number;
  29819. /**
  29820. * Matrix animation type
  29821. */
  29822. static readonly ANIMATIONTYPE_MATRIX: number;
  29823. /**
  29824. * Color3 animation type
  29825. */
  29826. static readonly ANIMATIONTYPE_COLOR3: number;
  29827. /**
  29828. * Color3 animation type
  29829. */
  29830. static readonly ANIMATIONTYPE_COLOR4: number;
  29831. /**
  29832. * Vector2 animation type
  29833. */
  29834. static readonly ANIMATIONTYPE_VECTOR2: number;
  29835. /**
  29836. * Size animation type
  29837. */
  29838. static readonly ANIMATIONTYPE_SIZE: number;
  29839. /**
  29840. * Relative Loop Mode
  29841. */
  29842. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29843. /**
  29844. * Cycle Loop Mode
  29845. */
  29846. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29847. /**
  29848. * Constant Loop Mode
  29849. */
  29850. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29851. /** @hidden */
  29852. static _UniversalLerp(left: any, right: any, amount: number): any;
  29853. /**
  29854. * Parses an animation object and creates an animation
  29855. * @param parsedAnimation Parsed animation object
  29856. * @returns Animation object
  29857. */
  29858. static Parse(parsedAnimation: any): Animation;
  29859. /**
  29860. * Appends the serialized animations from the source animations
  29861. * @param source Source containing the animations
  29862. * @param destination Target to store the animations
  29863. */
  29864. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29865. }
  29866. }
  29867. declare module BABYLON {
  29868. /**
  29869. * Interface containing an array of animations
  29870. */
  29871. export interface IAnimatable {
  29872. /**
  29873. * Array of animations
  29874. */
  29875. animations: Nullable<Array<Animation>>;
  29876. }
  29877. }
  29878. declare module BABYLON {
  29879. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29880. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29881. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29882. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29883. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29884. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29885. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29886. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29887. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29888. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29889. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29890. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29891. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29892. /**
  29893. * Decorator used to define property that can be serialized as reference to a camera
  29894. * @param sourceName defines the name of the property to decorate
  29895. */
  29896. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29897. /**
  29898. * Class used to help serialization objects
  29899. */
  29900. export class SerializationHelper {
  29901. /** @hidden */
  29902. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29903. /** @hidden */
  29904. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29905. /** @hidden */
  29906. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29907. /** @hidden */
  29908. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29909. /**
  29910. * Appends the serialized animations from the source animations
  29911. * @param source Source containing the animations
  29912. * @param destination Target to store the animations
  29913. */
  29914. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29915. /**
  29916. * Static function used to serialized a specific entity
  29917. * @param entity defines the entity to serialize
  29918. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29919. * @returns a JSON compatible object representing the serialization of the entity
  29920. */
  29921. static Serialize<T>(entity: T, serializationObject?: any): any;
  29922. /**
  29923. * Creates a new entity from a serialization data object
  29924. * @param creationFunction defines a function used to instanciated the new entity
  29925. * @param source defines the source serialization data
  29926. * @param scene defines the hosting scene
  29927. * @param rootUrl defines the root url for resources
  29928. * @returns a new entity
  29929. */
  29930. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29931. /**
  29932. * Clones an object
  29933. * @param creationFunction defines the function used to instanciate the new object
  29934. * @param source defines the source object
  29935. * @returns the cloned object
  29936. */
  29937. static Clone<T>(creationFunction: () => T, source: T): T;
  29938. /**
  29939. * Instanciates a new object based on a source one (some data will be shared between both object)
  29940. * @param creationFunction defines the function used to instanciate the new object
  29941. * @param source defines the source object
  29942. * @returns the new object
  29943. */
  29944. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29945. }
  29946. }
  29947. declare module BABYLON {
  29948. /**
  29949. * Class used to manipulate GUIDs
  29950. */
  29951. export class GUID {
  29952. /**
  29953. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29954. * Be aware Math.random() could cause collisions, but:
  29955. * "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"
  29956. * @returns a pseudo random id
  29957. */
  29958. static RandomId(): string;
  29959. }
  29960. }
  29961. declare module BABYLON {
  29962. /**
  29963. * Base class of all the textures in babylon.
  29964. * It groups all the common properties the materials, post process, lights... might need
  29965. * in order to make a correct use of the texture.
  29966. */
  29967. export class BaseTexture implements IAnimatable {
  29968. /**
  29969. * Default anisotropic filtering level for the application.
  29970. * It is set to 4 as a good tradeoff between perf and quality.
  29971. */
  29972. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29973. /**
  29974. * Gets or sets the unique id of the texture
  29975. */
  29976. uniqueId: number;
  29977. /**
  29978. * Define the name of the texture.
  29979. */
  29980. name: string;
  29981. /**
  29982. * Gets or sets an object used to store user defined information.
  29983. */
  29984. metadata: any;
  29985. /**
  29986. * For internal use only. Please do not use.
  29987. */
  29988. reservedDataStore: any;
  29989. private _hasAlpha;
  29990. /**
  29991. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29992. */
  29993. set hasAlpha(value: boolean);
  29994. get hasAlpha(): boolean;
  29995. /**
  29996. * Defines if the alpha value should be determined via the rgb values.
  29997. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29998. */
  29999. getAlphaFromRGB: boolean;
  30000. /**
  30001. * Intensity or strength of the texture.
  30002. * It is commonly used by materials to fine tune the intensity of the texture
  30003. */
  30004. level: number;
  30005. /**
  30006. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30007. * This is part of the texture as textures usually maps to one uv set.
  30008. */
  30009. coordinatesIndex: number;
  30010. private _coordinatesMode;
  30011. /**
  30012. * How a texture is mapped.
  30013. *
  30014. * | Value | Type | Description |
  30015. * | ----- | ----------------------------------- | ----------- |
  30016. * | 0 | EXPLICIT_MODE | |
  30017. * | 1 | SPHERICAL_MODE | |
  30018. * | 2 | PLANAR_MODE | |
  30019. * | 3 | CUBIC_MODE | |
  30020. * | 4 | PROJECTION_MODE | |
  30021. * | 5 | SKYBOX_MODE | |
  30022. * | 6 | INVCUBIC_MODE | |
  30023. * | 7 | EQUIRECTANGULAR_MODE | |
  30024. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30025. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30026. */
  30027. set coordinatesMode(value: number);
  30028. get coordinatesMode(): number;
  30029. /**
  30030. * | Value | Type | Description |
  30031. * | ----- | ------------------ | ----------- |
  30032. * | 0 | CLAMP_ADDRESSMODE | |
  30033. * | 1 | WRAP_ADDRESSMODE | |
  30034. * | 2 | MIRROR_ADDRESSMODE | |
  30035. */
  30036. wrapU: number;
  30037. /**
  30038. * | Value | Type | Description |
  30039. * | ----- | ------------------ | ----------- |
  30040. * | 0 | CLAMP_ADDRESSMODE | |
  30041. * | 1 | WRAP_ADDRESSMODE | |
  30042. * | 2 | MIRROR_ADDRESSMODE | |
  30043. */
  30044. wrapV: number;
  30045. /**
  30046. * | Value | Type | Description |
  30047. * | ----- | ------------------ | ----------- |
  30048. * | 0 | CLAMP_ADDRESSMODE | |
  30049. * | 1 | WRAP_ADDRESSMODE | |
  30050. * | 2 | MIRROR_ADDRESSMODE | |
  30051. */
  30052. wrapR: number;
  30053. /**
  30054. * With compliant hardware and browser (supporting anisotropic filtering)
  30055. * this defines the level of anisotropic filtering in the texture.
  30056. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30057. */
  30058. anisotropicFilteringLevel: number;
  30059. /**
  30060. * Define if the texture is a cube texture or if false a 2d texture.
  30061. */
  30062. get isCube(): boolean;
  30063. set isCube(value: boolean);
  30064. /**
  30065. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30066. */
  30067. get is3D(): boolean;
  30068. set is3D(value: boolean);
  30069. /**
  30070. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30071. */
  30072. get is2DArray(): boolean;
  30073. set is2DArray(value: boolean);
  30074. /**
  30075. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30076. * HDR texture are usually stored in linear space.
  30077. * This only impacts the PBR and Background materials
  30078. */
  30079. gammaSpace: boolean;
  30080. /**
  30081. * Gets or sets whether or not the texture contains RGBD data.
  30082. */
  30083. get isRGBD(): boolean;
  30084. set isRGBD(value: boolean);
  30085. /**
  30086. * Is Z inverted in the texture (useful in a cube texture).
  30087. */
  30088. invertZ: boolean;
  30089. /**
  30090. * Are mip maps generated for this texture or not.
  30091. */
  30092. get noMipmap(): boolean;
  30093. /**
  30094. * @hidden
  30095. */
  30096. lodLevelInAlpha: boolean;
  30097. /**
  30098. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30099. */
  30100. get lodGenerationOffset(): number;
  30101. set lodGenerationOffset(value: number);
  30102. /**
  30103. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30104. */
  30105. get lodGenerationScale(): number;
  30106. set lodGenerationScale(value: number);
  30107. /**
  30108. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30109. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30110. * average roughness values.
  30111. */
  30112. get linearSpecularLOD(): boolean;
  30113. set linearSpecularLOD(value: boolean);
  30114. /**
  30115. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30116. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30117. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30118. */
  30119. get irradianceTexture(): Nullable<BaseTexture>;
  30120. set irradianceTexture(value: Nullable<BaseTexture>);
  30121. /**
  30122. * Define if the texture is a render target.
  30123. */
  30124. isRenderTarget: boolean;
  30125. /**
  30126. * Define the unique id of the texture in the scene.
  30127. */
  30128. get uid(): string;
  30129. /**
  30130. * Return a string representation of the texture.
  30131. * @returns the texture as a string
  30132. */
  30133. toString(): string;
  30134. /**
  30135. * Get the class name of the texture.
  30136. * @returns "BaseTexture"
  30137. */
  30138. getClassName(): string;
  30139. /**
  30140. * Define the list of animation attached to the texture.
  30141. */
  30142. animations: Animation[];
  30143. /**
  30144. * An event triggered when the texture is disposed.
  30145. */
  30146. onDisposeObservable: Observable<BaseTexture>;
  30147. private _onDisposeObserver;
  30148. /**
  30149. * Callback triggered when the texture has been disposed.
  30150. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30151. */
  30152. set onDispose(callback: () => void);
  30153. /**
  30154. * Define the current state of the loading sequence when in delayed load mode.
  30155. */
  30156. delayLoadState: number;
  30157. private _scene;
  30158. /** @hidden */
  30159. _texture: Nullable<InternalTexture>;
  30160. private _uid;
  30161. /**
  30162. * Define if the texture is preventinga material to render or not.
  30163. * If not and the texture is not ready, the engine will use a default black texture instead.
  30164. */
  30165. get isBlocking(): boolean;
  30166. /**
  30167. * Instantiates a new BaseTexture.
  30168. * Base class of all the textures in babylon.
  30169. * It groups all the common properties the materials, post process, lights... might need
  30170. * in order to make a correct use of the texture.
  30171. * @param scene Define the scene the texture blongs to
  30172. */
  30173. constructor(scene: Nullable<Scene>);
  30174. /**
  30175. * Get the scene the texture belongs to.
  30176. * @returns the scene or null if undefined
  30177. */
  30178. getScene(): Nullable<Scene>;
  30179. /**
  30180. * Get the texture transform matrix used to offset tile the texture for istance.
  30181. * @returns the transformation matrix
  30182. */
  30183. getTextureMatrix(): Matrix;
  30184. /**
  30185. * Get the texture reflection matrix used to rotate/transform the reflection.
  30186. * @returns the reflection matrix
  30187. */
  30188. getReflectionTextureMatrix(): Matrix;
  30189. /**
  30190. * Get the underlying lower level texture from Babylon.
  30191. * @returns the insternal texture
  30192. */
  30193. getInternalTexture(): Nullable<InternalTexture>;
  30194. /**
  30195. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30196. * @returns true if ready or not blocking
  30197. */
  30198. isReadyOrNotBlocking(): boolean;
  30199. /**
  30200. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30201. * @returns true if fully ready
  30202. */
  30203. isReady(): boolean;
  30204. private _cachedSize;
  30205. /**
  30206. * Get the size of the texture.
  30207. * @returns the texture size.
  30208. */
  30209. getSize(): ISize;
  30210. /**
  30211. * Get the base size of the texture.
  30212. * It can be different from the size if the texture has been resized for POT for instance
  30213. * @returns the base size
  30214. */
  30215. getBaseSize(): ISize;
  30216. /**
  30217. * Update the sampling mode of the texture.
  30218. * Default is Trilinear mode.
  30219. *
  30220. * | Value | Type | Description |
  30221. * | ----- | ------------------ | ----------- |
  30222. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30223. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30224. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30225. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30226. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30227. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30228. * | 7 | NEAREST_LINEAR | |
  30229. * | 8 | NEAREST_NEAREST | |
  30230. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30231. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30232. * | 11 | LINEAR_LINEAR | |
  30233. * | 12 | LINEAR_NEAREST | |
  30234. *
  30235. * > _mag_: magnification filter (close to the viewer)
  30236. * > _min_: minification filter (far from the viewer)
  30237. * > _mip_: filter used between mip map levels
  30238. *@param samplingMode Define the new sampling mode of the texture
  30239. */
  30240. updateSamplingMode(samplingMode: number): void;
  30241. /**
  30242. * Scales the texture if is `canRescale()`
  30243. * @param ratio the resize factor we want to use to rescale
  30244. */
  30245. scale(ratio: number): void;
  30246. /**
  30247. * Get if the texture can rescale.
  30248. */
  30249. get canRescale(): boolean;
  30250. /** @hidden */
  30251. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30252. /** @hidden */
  30253. _rebuild(): void;
  30254. /**
  30255. * Triggers the load sequence in delayed load mode.
  30256. */
  30257. delayLoad(): void;
  30258. /**
  30259. * Clones the texture.
  30260. * @returns the cloned texture
  30261. */
  30262. clone(): Nullable<BaseTexture>;
  30263. /**
  30264. * Get the texture underlying type (INT, FLOAT...)
  30265. */
  30266. get textureType(): number;
  30267. /**
  30268. * Get the texture underlying format (RGB, RGBA...)
  30269. */
  30270. get textureFormat(): number;
  30271. /**
  30272. * Indicates that textures need to be re-calculated for all materials
  30273. */
  30274. protected _markAllSubMeshesAsTexturesDirty(): void;
  30275. /**
  30276. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30277. * This will returns an RGBA array buffer containing either in values (0-255) or
  30278. * float values (0-1) depending of the underlying buffer type.
  30279. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30280. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30281. * @param buffer defines a user defined buffer to fill with data (can be null)
  30282. * @returns The Array buffer containing the pixels data.
  30283. */
  30284. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30285. /**
  30286. * Release and destroy the underlying lower level texture aka internalTexture.
  30287. */
  30288. releaseInternalTexture(): void;
  30289. /** @hidden */
  30290. get _lodTextureHigh(): Nullable<BaseTexture>;
  30291. /** @hidden */
  30292. get _lodTextureMid(): Nullable<BaseTexture>;
  30293. /** @hidden */
  30294. get _lodTextureLow(): Nullable<BaseTexture>;
  30295. /**
  30296. * Dispose the texture and release its associated resources.
  30297. */
  30298. dispose(): void;
  30299. /**
  30300. * Serialize the texture into a JSON representation that can be parsed later on.
  30301. * @returns the JSON representation of the texture
  30302. */
  30303. serialize(): any;
  30304. /**
  30305. * Helper function to be called back once a list of texture contains only ready textures.
  30306. * @param textures Define the list of textures to wait for
  30307. * @param callback Define the callback triggered once the entire list will be ready
  30308. */
  30309. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30310. }
  30311. }
  30312. declare module BABYLON {
  30313. /**
  30314. * Options to be used when creating an effect.
  30315. */
  30316. export interface IEffectCreationOptions {
  30317. /**
  30318. * Atrributes that will be used in the shader.
  30319. */
  30320. attributes: string[];
  30321. /**
  30322. * Uniform varible names that will be set in the shader.
  30323. */
  30324. uniformsNames: string[];
  30325. /**
  30326. * Uniform buffer variable names that will be set in the shader.
  30327. */
  30328. uniformBuffersNames: string[];
  30329. /**
  30330. * Sampler texture variable names that will be set in the shader.
  30331. */
  30332. samplers: string[];
  30333. /**
  30334. * Define statements that will be set in the shader.
  30335. */
  30336. defines: any;
  30337. /**
  30338. * Possible fallbacks for this effect to improve performance when needed.
  30339. */
  30340. fallbacks: Nullable<IEffectFallbacks>;
  30341. /**
  30342. * Callback that will be called when the shader is compiled.
  30343. */
  30344. onCompiled: Nullable<(effect: Effect) => void>;
  30345. /**
  30346. * Callback that will be called if an error occurs during shader compilation.
  30347. */
  30348. onError: Nullable<(effect: Effect, errors: string) => void>;
  30349. /**
  30350. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30351. */
  30352. indexParameters?: any;
  30353. /**
  30354. * Max number of lights that can be used in the shader.
  30355. */
  30356. maxSimultaneousLights?: number;
  30357. /**
  30358. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30359. */
  30360. transformFeedbackVaryings?: Nullable<string[]>;
  30361. }
  30362. /**
  30363. * Effect containing vertex and fragment shader that can be executed on an object.
  30364. */
  30365. export class Effect implements IDisposable {
  30366. /**
  30367. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30368. */
  30369. static ShadersRepository: string;
  30370. /**
  30371. * Enable logging of the shader code when a compilation error occurs
  30372. */
  30373. static LogShaderCodeOnCompilationError: boolean;
  30374. /**
  30375. * Name of the effect.
  30376. */
  30377. name: any;
  30378. /**
  30379. * String container all the define statements that should be set on the shader.
  30380. */
  30381. defines: string;
  30382. /**
  30383. * Callback that will be called when the shader is compiled.
  30384. */
  30385. onCompiled: Nullable<(effect: Effect) => void>;
  30386. /**
  30387. * Callback that will be called if an error occurs during shader compilation.
  30388. */
  30389. onError: Nullable<(effect: Effect, errors: string) => void>;
  30390. /**
  30391. * Callback that will be called when effect is bound.
  30392. */
  30393. onBind: Nullable<(effect: Effect) => void>;
  30394. /**
  30395. * Unique ID of the effect.
  30396. */
  30397. uniqueId: number;
  30398. /**
  30399. * Observable that will be called when the shader is compiled.
  30400. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30401. */
  30402. onCompileObservable: Observable<Effect>;
  30403. /**
  30404. * Observable that will be called if an error occurs during shader compilation.
  30405. */
  30406. onErrorObservable: Observable<Effect>;
  30407. /** @hidden */
  30408. _onBindObservable: Nullable<Observable<Effect>>;
  30409. /**
  30410. * @hidden
  30411. * Specifies if the effect was previously ready
  30412. */
  30413. _wasPreviouslyReady: boolean;
  30414. /**
  30415. * Observable that will be called when effect is bound.
  30416. */
  30417. get onBindObservable(): Observable<Effect>;
  30418. /** @hidden */
  30419. _bonesComputationForcedToCPU: boolean;
  30420. private static _uniqueIdSeed;
  30421. private _engine;
  30422. private _uniformBuffersNames;
  30423. private _uniformsNames;
  30424. private _samplerList;
  30425. private _samplers;
  30426. private _isReady;
  30427. private _compilationError;
  30428. private _allFallbacksProcessed;
  30429. private _attributesNames;
  30430. private _attributes;
  30431. private _attributeLocationByName;
  30432. private _uniforms;
  30433. /**
  30434. * Key for the effect.
  30435. * @hidden
  30436. */
  30437. _key: string;
  30438. private _indexParameters;
  30439. private _fallbacks;
  30440. private _vertexSourceCode;
  30441. private _fragmentSourceCode;
  30442. private _vertexSourceCodeOverride;
  30443. private _fragmentSourceCodeOverride;
  30444. private _transformFeedbackVaryings;
  30445. /**
  30446. * Compiled shader to webGL program.
  30447. * @hidden
  30448. */
  30449. _pipelineContext: Nullable<IPipelineContext>;
  30450. private _valueCache;
  30451. private static _baseCache;
  30452. /**
  30453. * Instantiates an effect.
  30454. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30455. * @param baseName Name of the effect.
  30456. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30457. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30458. * @param samplers List of sampler variables that will be passed to the shader.
  30459. * @param engine Engine to be used to render the effect
  30460. * @param defines Define statements to be added to the shader.
  30461. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30462. * @param onCompiled Callback that will be called when the shader is compiled.
  30463. * @param onError Callback that will be called if an error occurs during shader compilation.
  30464. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30465. */
  30466. 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);
  30467. private _useFinalCode;
  30468. /**
  30469. * Unique key for this effect
  30470. */
  30471. get key(): string;
  30472. /**
  30473. * If the effect has been compiled and prepared.
  30474. * @returns if the effect is compiled and prepared.
  30475. */
  30476. isReady(): boolean;
  30477. private _isReadyInternal;
  30478. /**
  30479. * The engine the effect was initialized with.
  30480. * @returns the engine.
  30481. */
  30482. getEngine(): Engine;
  30483. /**
  30484. * The pipeline context for this effect
  30485. * @returns the associated pipeline context
  30486. */
  30487. getPipelineContext(): Nullable<IPipelineContext>;
  30488. /**
  30489. * The set of names of attribute variables for the shader.
  30490. * @returns An array of attribute names.
  30491. */
  30492. getAttributesNames(): string[];
  30493. /**
  30494. * Returns the attribute at the given index.
  30495. * @param index The index of the attribute.
  30496. * @returns The location of the attribute.
  30497. */
  30498. getAttributeLocation(index: number): number;
  30499. /**
  30500. * Returns the attribute based on the name of the variable.
  30501. * @param name of the attribute to look up.
  30502. * @returns the attribute location.
  30503. */
  30504. getAttributeLocationByName(name: string): number;
  30505. /**
  30506. * The number of attributes.
  30507. * @returns the numnber of attributes.
  30508. */
  30509. getAttributesCount(): number;
  30510. /**
  30511. * Gets the index of a uniform variable.
  30512. * @param uniformName of the uniform to look up.
  30513. * @returns the index.
  30514. */
  30515. getUniformIndex(uniformName: string): number;
  30516. /**
  30517. * Returns the attribute based on the name of the variable.
  30518. * @param uniformName of the uniform to look up.
  30519. * @returns the location of the uniform.
  30520. */
  30521. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30522. /**
  30523. * Returns an array of sampler variable names
  30524. * @returns The array of sampler variable neames.
  30525. */
  30526. getSamplers(): string[];
  30527. /**
  30528. * The error from the last compilation.
  30529. * @returns the error string.
  30530. */
  30531. getCompilationError(): string;
  30532. /**
  30533. * Gets a boolean indicating that all fallbacks were used during compilation
  30534. * @returns true if all fallbacks were used
  30535. */
  30536. allFallbacksProcessed(): boolean;
  30537. /**
  30538. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30539. * @param func The callback to be used.
  30540. */
  30541. executeWhenCompiled(func: (effect: Effect) => void): void;
  30542. private _checkIsReady;
  30543. private _loadShader;
  30544. /**
  30545. * Recompiles the webGL program
  30546. * @param vertexSourceCode The source code for the vertex shader.
  30547. * @param fragmentSourceCode The source code for the fragment shader.
  30548. * @param onCompiled Callback called when completed.
  30549. * @param onError Callback called on error.
  30550. * @hidden
  30551. */
  30552. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30553. /**
  30554. * Prepares the effect
  30555. * @hidden
  30556. */
  30557. _prepareEffect(): void;
  30558. private _getShaderCodeAndErrorLine;
  30559. private _processCompilationErrors;
  30560. /**
  30561. * Checks if the effect is supported. (Must be called after compilation)
  30562. */
  30563. get isSupported(): boolean;
  30564. /**
  30565. * Binds a texture to the engine to be used as output of the shader.
  30566. * @param channel Name of the output variable.
  30567. * @param texture Texture to bind.
  30568. * @hidden
  30569. */
  30570. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30571. /**
  30572. * Sets a texture on the engine to be used in the shader.
  30573. * @param channel Name of the sampler variable.
  30574. * @param texture Texture to set.
  30575. */
  30576. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30577. /**
  30578. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30579. * @param channel Name of the sampler variable.
  30580. * @param texture Texture to set.
  30581. */
  30582. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30583. /**
  30584. * Sets an array of textures on the engine to be used in the shader.
  30585. * @param channel Name of the variable.
  30586. * @param textures Textures to set.
  30587. */
  30588. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30589. /**
  30590. * 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)
  30591. * @param channel Name of the sampler variable.
  30592. * @param postProcess Post process to get the input texture from.
  30593. */
  30594. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30595. /**
  30596. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30597. * 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)
  30598. * @param channel Name of the sampler variable.
  30599. * @param postProcess Post process to get the output texture from.
  30600. */
  30601. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30602. /** @hidden */
  30603. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30604. /** @hidden */
  30605. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30606. /** @hidden */
  30607. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30608. /** @hidden */
  30609. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30610. /**
  30611. * Binds a buffer to a uniform.
  30612. * @param buffer Buffer to bind.
  30613. * @param name Name of the uniform variable to bind to.
  30614. */
  30615. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30616. /**
  30617. * Binds block to a uniform.
  30618. * @param blockName Name of the block to bind.
  30619. * @param index Index to bind.
  30620. */
  30621. bindUniformBlock(blockName: string, index: number): void;
  30622. /**
  30623. * Sets an interger value on a uniform variable.
  30624. * @param uniformName Name of the variable.
  30625. * @param value Value to be set.
  30626. * @returns this effect.
  30627. */
  30628. setInt(uniformName: string, value: number): Effect;
  30629. /**
  30630. * Sets an int array on a uniform variable.
  30631. * @param uniformName Name of the variable.
  30632. * @param array array to be set.
  30633. * @returns this effect.
  30634. */
  30635. setIntArray(uniformName: string, array: Int32Array): Effect;
  30636. /**
  30637. * 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)
  30638. * @param uniformName Name of the variable.
  30639. * @param array array to be set.
  30640. * @returns this effect.
  30641. */
  30642. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30643. /**
  30644. * 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)
  30645. * @param uniformName Name of the variable.
  30646. * @param array array to be set.
  30647. * @returns this effect.
  30648. */
  30649. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30650. /**
  30651. * 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)
  30652. * @param uniformName Name of the variable.
  30653. * @param array array to be set.
  30654. * @returns this effect.
  30655. */
  30656. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30657. /**
  30658. * Sets an float array on a uniform variable.
  30659. * @param uniformName Name of the variable.
  30660. * @param array array to be set.
  30661. * @returns this effect.
  30662. */
  30663. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30664. /**
  30665. * 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)
  30666. * @param uniformName Name of the variable.
  30667. * @param array array to be set.
  30668. * @returns this effect.
  30669. */
  30670. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30671. /**
  30672. * 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)
  30673. * @param uniformName Name of the variable.
  30674. * @param array array to be set.
  30675. * @returns this effect.
  30676. */
  30677. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30678. /**
  30679. * 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)
  30680. * @param uniformName Name of the variable.
  30681. * @param array array to be set.
  30682. * @returns this effect.
  30683. */
  30684. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30685. /**
  30686. * Sets an array on a uniform variable.
  30687. * @param uniformName Name of the variable.
  30688. * @param array array to be set.
  30689. * @returns this effect.
  30690. */
  30691. setArray(uniformName: string, array: number[]): Effect;
  30692. /**
  30693. * 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)
  30694. * @param uniformName Name of the variable.
  30695. * @param array array to be set.
  30696. * @returns this effect.
  30697. */
  30698. setArray2(uniformName: string, array: number[]): Effect;
  30699. /**
  30700. * 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)
  30701. * @param uniformName Name of the variable.
  30702. * @param array array to be set.
  30703. * @returns this effect.
  30704. */
  30705. setArray3(uniformName: string, array: number[]): Effect;
  30706. /**
  30707. * 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)
  30708. * @param uniformName Name of the variable.
  30709. * @param array array to be set.
  30710. * @returns this effect.
  30711. */
  30712. setArray4(uniformName: string, array: number[]): Effect;
  30713. /**
  30714. * Sets matrices on a uniform variable.
  30715. * @param uniformName Name of the variable.
  30716. * @param matrices matrices to be set.
  30717. * @returns this effect.
  30718. */
  30719. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30720. /**
  30721. * Sets matrix on a uniform variable.
  30722. * @param uniformName Name of the variable.
  30723. * @param matrix matrix to be set.
  30724. * @returns this effect.
  30725. */
  30726. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30727. /**
  30728. * 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)
  30729. * @param uniformName Name of the variable.
  30730. * @param matrix matrix to be set.
  30731. * @returns this effect.
  30732. */
  30733. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30734. /**
  30735. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30736. * @param uniformName Name of the variable.
  30737. * @param matrix matrix to be set.
  30738. * @returns this effect.
  30739. */
  30740. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30741. /**
  30742. * Sets a float on a uniform variable.
  30743. * @param uniformName Name of the variable.
  30744. * @param value value to be set.
  30745. * @returns this effect.
  30746. */
  30747. setFloat(uniformName: string, value: number): Effect;
  30748. /**
  30749. * Sets a boolean on a uniform variable.
  30750. * @param uniformName Name of the variable.
  30751. * @param bool value to be set.
  30752. * @returns this effect.
  30753. */
  30754. setBool(uniformName: string, bool: boolean): Effect;
  30755. /**
  30756. * Sets a Vector2 on a uniform variable.
  30757. * @param uniformName Name of the variable.
  30758. * @param vector2 vector2 to be set.
  30759. * @returns this effect.
  30760. */
  30761. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30762. /**
  30763. * Sets a float2 on a uniform variable.
  30764. * @param uniformName Name of the variable.
  30765. * @param x First float in float2.
  30766. * @param y Second float in float2.
  30767. * @returns this effect.
  30768. */
  30769. setFloat2(uniformName: string, x: number, y: number): Effect;
  30770. /**
  30771. * Sets a Vector3 on a uniform variable.
  30772. * @param uniformName Name of the variable.
  30773. * @param vector3 Value to be set.
  30774. * @returns this effect.
  30775. */
  30776. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30777. /**
  30778. * Sets a float3 on a uniform variable.
  30779. * @param uniformName Name of the variable.
  30780. * @param x First float in float3.
  30781. * @param y Second float in float3.
  30782. * @param z Third float in float3.
  30783. * @returns this effect.
  30784. */
  30785. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30786. /**
  30787. * Sets a Vector4 on a uniform variable.
  30788. * @param uniformName Name of the variable.
  30789. * @param vector4 Value to be set.
  30790. * @returns this effect.
  30791. */
  30792. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30793. /**
  30794. * Sets a float4 on a uniform variable.
  30795. * @param uniformName Name of the variable.
  30796. * @param x First float in float4.
  30797. * @param y Second float in float4.
  30798. * @param z Third float in float4.
  30799. * @param w Fourth float in float4.
  30800. * @returns this effect.
  30801. */
  30802. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30803. /**
  30804. * Sets a Color3 on a uniform variable.
  30805. * @param uniformName Name of the variable.
  30806. * @param color3 Value to be set.
  30807. * @returns this effect.
  30808. */
  30809. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30810. /**
  30811. * Sets a Color4 on a uniform variable.
  30812. * @param uniformName Name of the variable.
  30813. * @param color3 Value to be set.
  30814. * @param alpha Alpha value to be set.
  30815. * @returns this effect.
  30816. */
  30817. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30818. /**
  30819. * Sets a Color4 on a uniform variable
  30820. * @param uniformName defines the name of the variable
  30821. * @param color4 defines the value to be set
  30822. * @returns this effect.
  30823. */
  30824. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30825. /** Release all associated resources */
  30826. dispose(): void;
  30827. /**
  30828. * This function will add a new shader to the shader store
  30829. * @param name the name of the shader
  30830. * @param pixelShader optional pixel shader content
  30831. * @param vertexShader optional vertex shader content
  30832. */
  30833. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30834. /**
  30835. * Store of each shader (The can be looked up using effect.key)
  30836. */
  30837. static ShadersStore: {
  30838. [key: string]: string;
  30839. };
  30840. /**
  30841. * Store of each included file for a shader (The can be looked up using effect.key)
  30842. */
  30843. static IncludesShadersStore: {
  30844. [key: string]: string;
  30845. };
  30846. /**
  30847. * Resets the cache of effects.
  30848. */
  30849. static ResetCache(): void;
  30850. }
  30851. }
  30852. declare module BABYLON {
  30853. /**
  30854. * Interface used to describe the capabilities of the engine relatively to the current browser
  30855. */
  30856. export interface EngineCapabilities {
  30857. /** Maximum textures units per fragment shader */
  30858. maxTexturesImageUnits: number;
  30859. /** Maximum texture units per vertex shader */
  30860. maxVertexTextureImageUnits: number;
  30861. /** Maximum textures units in the entire pipeline */
  30862. maxCombinedTexturesImageUnits: number;
  30863. /** Maximum texture size */
  30864. maxTextureSize: number;
  30865. /** Maximum texture samples */
  30866. maxSamples?: number;
  30867. /** Maximum cube texture size */
  30868. maxCubemapTextureSize: number;
  30869. /** Maximum render texture size */
  30870. maxRenderTextureSize: number;
  30871. /** Maximum number of vertex attributes */
  30872. maxVertexAttribs: number;
  30873. /** Maximum number of varyings */
  30874. maxVaryingVectors: number;
  30875. /** Maximum number of uniforms per vertex shader */
  30876. maxVertexUniformVectors: number;
  30877. /** Maximum number of uniforms per fragment shader */
  30878. maxFragmentUniformVectors: number;
  30879. /** Defines if standard derivates (dx/dy) are supported */
  30880. standardDerivatives: boolean;
  30881. /** Defines if s3tc texture compression is supported */
  30882. s3tc?: WEBGL_compressed_texture_s3tc;
  30883. /** Defines if pvrtc texture compression is supported */
  30884. pvrtc: any;
  30885. /** Defines if etc1 texture compression is supported */
  30886. etc1: any;
  30887. /** Defines if etc2 texture compression is supported */
  30888. etc2: any;
  30889. /** Defines if astc texture compression is supported */
  30890. astc: any;
  30891. /** Defines if float textures are supported */
  30892. textureFloat: boolean;
  30893. /** Defines if vertex array objects are supported */
  30894. vertexArrayObject: boolean;
  30895. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30896. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30897. /** Gets the maximum level of anisotropy supported */
  30898. maxAnisotropy: number;
  30899. /** Defines if instancing is supported */
  30900. instancedArrays: boolean;
  30901. /** Defines if 32 bits indices are supported */
  30902. uintIndices: boolean;
  30903. /** Defines if high precision shaders are supported */
  30904. highPrecisionShaderSupported: boolean;
  30905. /** Defines if depth reading in the fragment shader is supported */
  30906. fragmentDepthSupported: boolean;
  30907. /** Defines if float texture linear filtering is supported*/
  30908. textureFloatLinearFiltering: boolean;
  30909. /** Defines if rendering to float textures is supported */
  30910. textureFloatRender: boolean;
  30911. /** Defines if half float textures are supported*/
  30912. textureHalfFloat: boolean;
  30913. /** Defines if half float texture linear filtering is supported*/
  30914. textureHalfFloatLinearFiltering: boolean;
  30915. /** Defines if rendering to half float textures is supported */
  30916. textureHalfFloatRender: boolean;
  30917. /** Defines if textureLOD shader command is supported */
  30918. textureLOD: boolean;
  30919. /** Defines if draw buffers extension is supported */
  30920. drawBuffersExtension: boolean;
  30921. /** Defines if depth textures are supported */
  30922. depthTextureExtension: boolean;
  30923. /** Defines if float color buffer are supported */
  30924. colorBufferFloat: boolean;
  30925. /** Gets disjoint timer query extension (null if not supported) */
  30926. timerQuery?: EXT_disjoint_timer_query;
  30927. /** Defines if timestamp can be used with timer query */
  30928. canUseTimestampForTimerQuery: boolean;
  30929. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30930. multiview?: any;
  30931. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30932. oculusMultiview?: any;
  30933. /** Function used to let the system compiles shaders in background */
  30934. parallelShaderCompile?: {
  30935. COMPLETION_STATUS_KHR: number;
  30936. };
  30937. /** Max number of texture samples for MSAA */
  30938. maxMSAASamples: number;
  30939. /** Defines if the blend min max extension is supported */
  30940. blendMinMax: boolean;
  30941. }
  30942. }
  30943. declare module BABYLON {
  30944. /**
  30945. * @hidden
  30946. **/
  30947. export class DepthCullingState {
  30948. private _isDepthTestDirty;
  30949. private _isDepthMaskDirty;
  30950. private _isDepthFuncDirty;
  30951. private _isCullFaceDirty;
  30952. private _isCullDirty;
  30953. private _isZOffsetDirty;
  30954. private _isFrontFaceDirty;
  30955. private _depthTest;
  30956. private _depthMask;
  30957. private _depthFunc;
  30958. private _cull;
  30959. private _cullFace;
  30960. private _zOffset;
  30961. private _frontFace;
  30962. /**
  30963. * Initializes the state.
  30964. */
  30965. constructor();
  30966. get isDirty(): boolean;
  30967. get zOffset(): number;
  30968. set zOffset(value: number);
  30969. get cullFace(): Nullable<number>;
  30970. set cullFace(value: Nullable<number>);
  30971. get cull(): Nullable<boolean>;
  30972. set cull(value: Nullable<boolean>);
  30973. get depthFunc(): Nullable<number>;
  30974. set depthFunc(value: Nullable<number>);
  30975. get depthMask(): boolean;
  30976. set depthMask(value: boolean);
  30977. get depthTest(): boolean;
  30978. set depthTest(value: boolean);
  30979. get frontFace(): Nullable<number>;
  30980. set frontFace(value: Nullable<number>);
  30981. reset(): void;
  30982. apply(gl: WebGLRenderingContext): void;
  30983. }
  30984. }
  30985. declare module BABYLON {
  30986. /**
  30987. * @hidden
  30988. **/
  30989. export class StencilState {
  30990. /** 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 */
  30991. static readonly ALWAYS: number;
  30992. /** Passed to stencilOperation to specify that stencil value must be kept */
  30993. static readonly KEEP: number;
  30994. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30995. static readonly REPLACE: number;
  30996. private _isStencilTestDirty;
  30997. private _isStencilMaskDirty;
  30998. private _isStencilFuncDirty;
  30999. private _isStencilOpDirty;
  31000. private _stencilTest;
  31001. private _stencilMask;
  31002. private _stencilFunc;
  31003. private _stencilFuncRef;
  31004. private _stencilFuncMask;
  31005. private _stencilOpStencilFail;
  31006. private _stencilOpDepthFail;
  31007. private _stencilOpStencilDepthPass;
  31008. get isDirty(): boolean;
  31009. get stencilFunc(): number;
  31010. set stencilFunc(value: number);
  31011. get stencilFuncRef(): number;
  31012. set stencilFuncRef(value: number);
  31013. get stencilFuncMask(): number;
  31014. set stencilFuncMask(value: number);
  31015. get stencilOpStencilFail(): number;
  31016. set stencilOpStencilFail(value: number);
  31017. get stencilOpDepthFail(): number;
  31018. set stencilOpDepthFail(value: number);
  31019. get stencilOpStencilDepthPass(): number;
  31020. set stencilOpStencilDepthPass(value: number);
  31021. get stencilMask(): number;
  31022. set stencilMask(value: number);
  31023. get stencilTest(): boolean;
  31024. set stencilTest(value: boolean);
  31025. constructor();
  31026. reset(): void;
  31027. apply(gl: WebGLRenderingContext): void;
  31028. }
  31029. }
  31030. declare module BABYLON {
  31031. /**
  31032. * @hidden
  31033. **/
  31034. export class AlphaState {
  31035. private _isAlphaBlendDirty;
  31036. private _isBlendFunctionParametersDirty;
  31037. private _isBlendEquationParametersDirty;
  31038. private _isBlendConstantsDirty;
  31039. private _alphaBlend;
  31040. private _blendFunctionParameters;
  31041. private _blendEquationParameters;
  31042. private _blendConstants;
  31043. /**
  31044. * Initializes the state.
  31045. */
  31046. constructor();
  31047. get isDirty(): boolean;
  31048. get alphaBlend(): boolean;
  31049. set alphaBlend(value: boolean);
  31050. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31051. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31052. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31053. reset(): void;
  31054. apply(gl: WebGLRenderingContext): void;
  31055. }
  31056. }
  31057. declare module BABYLON {
  31058. /** @hidden */
  31059. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31060. attributeProcessor(attribute: string): string;
  31061. varyingProcessor(varying: string, isFragment: boolean): string;
  31062. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31063. }
  31064. }
  31065. declare module BABYLON {
  31066. /**
  31067. * Interface for attribute information associated with buffer instanciation
  31068. */
  31069. export interface InstancingAttributeInfo {
  31070. /**
  31071. * Name of the GLSL attribute
  31072. * if attribute index is not specified, this is used to retrieve the index from the effect
  31073. */
  31074. attributeName: string;
  31075. /**
  31076. * Index/offset of the attribute in the vertex shader
  31077. * if not specified, this will be computes from the name.
  31078. */
  31079. index?: number;
  31080. /**
  31081. * size of the attribute, 1, 2, 3 or 4
  31082. */
  31083. attributeSize: number;
  31084. /**
  31085. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31086. */
  31087. offset: number;
  31088. /**
  31089. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31090. * default to 1
  31091. */
  31092. divisor?: number;
  31093. /**
  31094. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31095. * default is FLOAT
  31096. */
  31097. attributeType?: number;
  31098. /**
  31099. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31100. */
  31101. normalized?: boolean;
  31102. }
  31103. }
  31104. declare module BABYLON {
  31105. interface ThinEngine {
  31106. /**
  31107. * Update a video texture
  31108. * @param texture defines the texture to update
  31109. * @param video defines the video element to use
  31110. * @param invertY defines if data must be stored with Y axis inverted
  31111. */
  31112. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31113. }
  31114. }
  31115. declare module BABYLON {
  31116. /**
  31117. * Settings for finer control over video usage
  31118. */
  31119. export interface VideoTextureSettings {
  31120. /**
  31121. * Applies `autoplay` to video, if specified
  31122. */
  31123. autoPlay?: boolean;
  31124. /**
  31125. * Applies `loop` to video, if specified
  31126. */
  31127. loop?: boolean;
  31128. /**
  31129. * Automatically updates internal texture from video at every frame in the render loop
  31130. */
  31131. autoUpdateTexture: boolean;
  31132. /**
  31133. * Image src displayed during the video loading or until the user interacts with the video.
  31134. */
  31135. poster?: string;
  31136. }
  31137. /**
  31138. * If you want to display a video in your scene, this is the special texture for that.
  31139. * This special texture works similar to other textures, with the exception of a few parameters.
  31140. * @see https://doc.babylonjs.com/how_to/video_texture
  31141. */
  31142. export class VideoTexture extends Texture {
  31143. /**
  31144. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31145. */
  31146. readonly autoUpdateTexture: boolean;
  31147. /**
  31148. * The video instance used by the texture internally
  31149. */
  31150. readonly video: HTMLVideoElement;
  31151. private _onUserActionRequestedObservable;
  31152. /**
  31153. * Event triggerd when a dom action is required by the user to play the video.
  31154. * This happens due to recent changes in browser policies preventing video to auto start.
  31155. */
  31156. get onUserActionRequestedObservable(): Observable<Texture>;
  31157. private _generateMipMaps;
  31158. private _engine;
  31159. private _stillImageCaptured;
  31160. private _displayingPosterTexture;
  31161. private _settings;
  31162. private _createInternalTextureOnEvent;
  31163. private _frameId;
  31164. private _currentSrc;
  31165. /**
  31166. * Creates a video texture.
  31167. * If you want to display a video in your scene, this is the special texture for that.
  31168. * This special texture works similar to other textures, with the exception of a few parameters.
  31169. * @see https://doc.babylonjs.com/how_to/video_texture
  31170. * @param name optional name, will detect from video source, if not defined
  31171. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31172. * @param scene is obviously the current scene.
  31173. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31174. * @param invertY is false by default but can be used to invert video on Y axis
  31175. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31176. * @param settings allows finer control over video usage
  31177. */
  31178. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31179. private _getName;
  31180. private _getVideo;
  31181. private _createInternalTexture;
  31182. private reset;
  31183. /**
  31184. * @hidden Internal method to initiate `update`.
  31185. */
  31186. _rebuild(): void;
  31187. /**
  31188. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31189. */
  31190. update(): void;
  31191. /**
  31192. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31193. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31194. */
  31195. updateTexture(isVisible: boolean): void;
  31196. protected _updateInternalTexture: () => void;
  31197. /**
  31198. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31199. * @param url New url.
  31200. */
  31201. updateURL(url: string): void;
  31202. /**
  31203. * Clones the texture.
  31204. * @returns the cloned texture
  31205. */
  31206. clone(): VideoTexture;
  31207. /**
  31208. * Dispose the texture and release its associated resources.
  31209. */
  31210. dispose(): void;
  31211. /**
  31212. * Creates a video texture straight from a stream.
  31213. * @param scene Define the scene the texture should be created in
  31214. * @param stream Define the stream the texture should be created from
  31215. * @returns The created video texture as a promise
  31216. */
  31217. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31218. /**
  31219. * Creates a video texture straight from your WebCam video feed.
  31220. * @param scene Define the scene the texture should be created in
  31221. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31222. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31223. * @returns The created video texture as a promise
  31224. */
  31225. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31226. minWidth: number;
  31227. maxWidth: number;
  31228. minHeight: number;
  31229. maxHeight: number;
  31230. deviceId: string;
  31231. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31232. /**
  31233. * Creates a video texture straight from your WebCam video feed.
  31234. * @param scene Define the scene the texture should be created in
  31235. * @param onReady Define a callback to triggered once the texture will be ready
  31236. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31237. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31238. */
  31239. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31240. minWidth: number;
  31241. maxWidth: number;
  31242. minHeight: number;
  31243. maxHeight: number;
  31244. deviceId: string;
  31245. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31246. }
  31247. }
  31248. declare module BABYLON {
  31249. /**
  31250. * Defines the interface used by objects working like Scene
  31251. * @hidden
  31252. */
  31253. export interface ISceneLike {
  31254. _addPendingData(data: any): void;
  31255. _removePendingData(data: any): void;
  31256. offlineProvider: IOfflineProvider;
  31257. }
  31258. /** Interface defining initialization parameters for Engine class */
  31259. export interface EngineOptions extends WebGLContextAttributes {
  31260. /**
  31261. * Defines if the engine should no exceed a specified device ratio
  31262. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31263. */
  31264. limitDeviceRatio?: number;
  31265. /**
  31266. * Defines if webvr should be enabled automatically
  31267. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31268. */
  31269. autoEnableWebVR?: boolean;
  31270. /**
  31271. * Defines if webgl2 should be turned off even if supported
  31272. * @see http://doc.babylonjs.com/features/webgl2
  31273. */
  31274. disableWebGL2Support?: boolean;
  31275. /**
  31276. * Defines if webaudio should be initialized as well
  31277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31278. */
  31279. audioEngine?: boolean;
  31280. /**
  31281. * Defines if animations should run using a deterministic lock step
  31282. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31283. */
  31284. deterministicLockstep?: boolean;
  31285. /** Defines the maximum steps to use with deterministic lock step mode */
  31286. lockstepMaxSteps?: number;
  31287. /** Defines the seconds between each deterministic lock step */
  31288. timeStep?: number;
  31289. /**
  31290. * Defines that engine should ignore context lost events
  31291. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31292. */
  31293. doNotHandleContextLost?: boolean;
  31294. /**
  31295. * Defines that engine should ignore modifying touch action attribute and style
  31296. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31297. */
  31298. doNotHandleTouchAction?: boolean;
  31299. /**
  31300. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31301. */
  31302. useHighPrecisionFloats?: boolean;
  31303. }
  31304. /**
  31305. * The base engine class (root of all engines)
  31306. */
  31307. export class ThinEngine {
  31308. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31309. static ExceptionList: ({
  31310. key: string;
  31311. capture: string;
  31312. captureConstraint: number;
  31313. targets: string[];
  31314. } | {
  31315. key: string;
  31316. capture: null;
  31317. captureConstraint: null;
  31318. targets: string[];
  31319. })[];
  31320. /** @hidden */
  31321. static _TextureLoaders: IInternalTextureLoader[];
  31322. /**
  31323. * Returns the current npm package of the sdk
  31324. */
  31325. static get NpmPackage(): string;
  31326. /**
  31327. * Returns the current version of the framework
  31328. */
  31329. static get Version(): string;
  31330. /**
  31331. * Returns a string describing the current engine
  31332. */
  31333. get description(): string;
  31334. /**
  31335. * Gets or sets the epsilon value used by collision engine
  31336. */
  31337. static CollisionsEpsilon: number;
  31338. /**
  31339. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31340. */
  31341. static get ShadersRepository(): string;
  31342. static set ShadersRepository(value: string);
  31343. /** @hidden */
  31344. _shaderProcessor: IShaderProcessor;
  31345. /**
  31346. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31347. */
  31348. forcePOTTextures: boolean;
  31349. /**
  31350. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31351. */
  31352. isFullscreen: boolean;
  31353. /**
  31354. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31355. */
  31356. cullBackFaces: boolean;
  31357. /**
  31358. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31359. */
  31360. renderEvenInBackground: boolean;
  31361. /**
  31362. * Gets or sets a boolean indicating that cache can be kept between frames
  31363. */
  31364. preventCacheWipeBetweenFrames: boolean;
  31365. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31366. validateShaderPrograms: boolean;
  31367. /**
  31368. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31369. * This can provide greater z depth for distant objects.
  31370. */
  31371. useReverseDepthBuffer: boolean;
  31372. /**
  31373. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31374. */
  31375. disableUniformBuffers: boolean;
  31376. /** @hidden */
  31377. _uniformBuffers: UniformBuffer[];
  31378. /**
  31379. * Gets a boolean indicating that the engine supports uniform buffers
  31380. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31381. */
  31382. get supportsUniformBuffers(): boolean;
  31383. /** @hidden */
  31384. _gl: WebGLRenderingContext;
  31385. /** @hidden */
  31386. _webGLVersion: number;
  31387. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31388. protected _windowIsBackground: boolean;
  31389. protected _creationOptions: EngineOptions;
  31390. protected _highPrecisionShadersAllowed: boolean;
  31391. /** @hidden */
  31392. get _shouldUseHighPrecisionShader(): boolean;
  31393. /**
  31394. * Gets a boolean indicating that only power of 2 textures are supported
  31395. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31396. */
  31397. get needPOTTextures(): boolean;
  31398. /** @hidden */
  31399. _badOS: boolean;
  31400. /** @hidden */
  31401. _badDesktopOS: boolean;
  31402. private _hardwareScalingLevel;
  31403. /** @hidden */
  31404. _caps: EngineCapabilities;
  31405. private _isStencilEnable;
  31406. private _glVersion;
  31407. private _glRenderer;
  31408. private _glVendor;
  31409. /** @hidden */
  31410. _videoTextureSupported: boolean;
  31411. protected _renderingQueueLaunched: boolean;
  31412. protected _activeRenderLoops: (() => void)[];
  31413. /**
  31414. * Observable signaled when a context lost event is raised
  31415. */
  31416. onContextLostObservable: Observable<ThinEngine>;
  31417. /**
  31418. * Observable signaled when a context restored event is raised
  31419. */
  31420. onContextRestoredObservable: Observable<ThinEngine>;
  31421. private _onContextLost;
  31422. private _onContextRestored;
  31423. protected _contextWasLost: boolean;
  31424. /** @hidden */
  31425. _doNotHandleContextLost: boolean;
  31426. /**
  31427. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31429. */
  31430. get doNotHandleContextLost(): boolean;
  31431. set doNotHandleContextLost(value: boolean);
  31432. /**
  31433. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31434. */
  31435. disableVertexArrayObjects: boolean;
  31436. /** @hidden */
  31437. protected _colorWrite: boolean;
  31438. /** @hidden */
  31439. protected _colorWriteChanged: boolean;
  31440. /** @hidden */
  31441. protected _depthCullingState: DepthCullingState;
  31442. /** @hidden */
  31443. protected _stencilState: StencilState;
  31444. /** @hidden */
  31445. _alphaState: AlphaState;
  31446. /** @hidden */
  31447. _alphaMode: number;
  31448. /** @hidden */
  31449. _alphaEquation: number;
  31450. /** @hidden */
  31451. _internalTexturesCache: InternalTexture[];
  31452. /** @hidden */
  31453. protected _activeChannel: number;
  31454. private _currentTextureChannel;
  31455. /** @hidden */
  31456. protected _boundTexturesCache: {
  31457. [key: string]: Nullable<InternalTexture>;
  31458. };
  31459. /** @hidden */
  31460. protected _currentEffect: Nullable<Effect>;
  31461. /** @hidden */
  31462. protected _currentProgram: Nullable<WebGLProgram>;
  31463. private _compiledEffects;
  31464. private _vertexAttribArraysEnabled;
  31465. /** @hidden */
  31466. protected _cachedViewport: Nullable<IViewportLike>;
  31467. private _cachedVertexArrayObject;
  31468. /** @hidden */
  31469. protected _cachedVertexBuffers: any;
  31470. /** @hidden */
  31471. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31472. /** @hidden */
  31473. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31474. /** @hidden */
  31475. _currentRenderTarget: Nullable<InternalTexture>;
  31476. private _uintIndicesCurrentlySet;
  31477. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31478. /** @hidden */
  31479. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31480. private _currentBufferPointers;
  31481. private _currentInstanceLocations;
  31482. private _currentInstanceBuffers;
  31483. private _textureUnits;
  31484. /** @hidden */
  31485. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31486. /** @hidden */
  31487. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31488. /** @hidden */
  31489. _boundRenderFunction: any;
  31490. private _vaoRecordInProgress;
  31491. private _mustWipeVertexAttributes;
  31492. private _emptyTexture;
  31493. private _emptyCubeTexture;
  31494. private _emptyTexture3D;
  31495. private _emptyTexture2DArray;
  31496. /** @hidden */
  31497. _frameHandler: number;
  31498. private _nextFreeTextureSlots;
  31499. private _maxSimultaneousTextures;
  31500. private _activeRequests;
  31501. /** @hidden */
  31502. _transformTextureUrl: Nullable<(url: string) => string>;
  31503. protected get _supportsHardwareTextureRescaling(): boolean;
  31504. private _framebufferDimensionsObject;
  31505. /**
  31506. * sets the object from which width and height will be taken from when getting render width and height
  31507. * Will fallback to the gl object
  31508. * @param dimensions the framebuffer width and height that will be used.
  31509. */
  31510. set framebufferDimensionsObject(dimensions: Nullable<{
  31511. framebufferWidth: number;
  31512. framebufferHeight: number;
  31513. }>);
  31514. /**
  31515. * Gets the current viewport
  31516. */
  31517. get currentViewport(): Nullable<IViewportLike>;
  31518. /**
  31519. * Gets the default empty texture
  31520. */
  31521. get emptyTexture(): InternalTexture;
  31522. /**
  31523. * Gets the default empty 3D texture
  31524. */
  31525. get emptyTexture3D(): InternalTexture;
  31526. /**
  31527. * Gets the default empty 2D array texture
  31528. */
  31529. get emptyTexture2DArray(): InternalTexture;
  31530. /**
  31531. * Gets the default empty cube texture
  31532. */
  31533. get emptyCubeTexture(): InternalTexture;
  31534. /**
  31535. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31536. */
  31537. readonly premultipliedAlpha: boolean;
  31538. /**
  31539. * Observable event triggered before each texture is initialized
  31540. */
  31541. onBeforeTextureInitObservable: Observable<Texture>;
  31542. /**
  31543. * Creates a new engine
  31544. * @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
  31545. * @param antialias defines enable antialiasing (default: false)
  31546. * @param options defines further options to be sent to the getContext() function
  31547. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31548. */
  31549. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31550. private _rebuildInternalTextures;
  31551. private _rebuildEffects;
  31552. /**
  31553. * Gets a boolean indicating if all created effects are ready
  31554. * @returns true if all effects are ready
  31555. */
  31556. areAllEffectsReady(): boolean;
  31557. protected _rebuildBuffers(): void;
  31558. protected _initGLContext(): void;
  31559. /**
  31560. * Gets version of the current webGL context
  31561. */
  31562. get webGLVersion(): number;
  31563. /**
  31564. * Gets a string idenfifying the name of the class
  31565. * @returns "Engine" string
  31566. */
  31567. getClassName(): string;
  31568. /**
  31569. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31570. */
  31571. get isStencilEnable(): boolean;
  31572. /** @hidden */
  31573. _prepareWorkingCanvas(): void;
  31574. /**
  31575. * Reset the texture cache to empty state
  31576. */
  31577. resetTextureCache(): void;
  31578. /**
  31579. * Gets an object containing information about the current webGL context
  31580. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31581. */
  31582. getGlInfo(): {
  31583. vendor: string;
  31584. renderer: string;
  31585. version: string;
  31586. };
  31587. /**
  31588. * Defines the hardware scaling level.
  31589. * By default the hardware scaling level is computed from the window device ratio.
  31590. * 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.
  31591. * @param level defines the level to use
  31592. */
  31593. setHardwareScalingLevel(level: number): void;
  31594. /**
  31595. * Gets the current hardware scaling level.
  31596. * By default the hardware scaling level is computed from the window device ratio.
  31597. * 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.
  31598. * @returns a number indicating the current hardware scaling level
  31599. */
  31600. getHardwareScalingLevel(): number;
  31601. /**
  31602. * Gets the list of loaded textures
  31603. * @returns an array containing all loaded textures
  31604. */
  31605. getLoadedTexturesCache(): InternalTexture[];
  31606. /**
  31607. * Gets the object containing all engine capabilities
  31608. * @returns the EngineCapabilities object
  31609. */
  31610. getCaps(): EngineCapabilities;
  31611. /**
  31612. * stop executing a render loop function and remove it from the execution array
  31613. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31614. */
  31615. stopRenderLoop(renderFunction?: () => void): void;
  31616. /** @hidden */
  31617. _renderLoop(): void;
  31618. /**
  31619. * Gets the HTML canvas attached with the current webGL context
  31620. * @returns a HTML canvas
  31621. */
  31622. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31623. /**
  31624. * Gets host window
  31625. * @returns the host window object
  31626. */
  31627. getHostWindow(): Nullable<Window>;
  31628. /**
  31629. * Gets the current render width
  31630. * @param useScreen defines if screen size must be used (or the current render target if any)
  31631. * @returns a number defining the current render width
  31632. */
  31633. getRenderWidth(useScreen?: boolean): number;
  31634. /**
  31635. * Gets the current render height
  31636. * @param useScreen defines if screen size must be used (or the current render target if any)
  31637. * @returns a number defining the current render height
  31638. */
  31639. getRenderHeight(useScreen?: boolean): number;
  31640. /**
  31641. * Can be used to override the current requestAnimationFrame requester.
  31642. * @hidden
  31643. */
  31644. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31645. /**
  31646. * Register and execute a render loop. The engine can have more than one render function
  31647. * @param renderFunction defines the function to continuously execute
  31648. */
  31649. runRenderLoop(renderFunction: () => void): void;
  31650. /**
  31651. * Clear the current render buffer or the current render target (if any is set up)
  31652. * @param color defines the color to use
  31653. * @param backBuffer defines if the back buffer must be cleared
  31654. * @param depth defines if the depth buffer must be cleared
  31655. * @param stencil defines if the stencil buffer must be cleared
  31656. */
  31657. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31658. private _viewportCached;
  31659. /** @hidden */
  31660. _viewport(x: number, y: number, width: number, height: number): void;
  31661. /**
  31662. * Set the WebGL's viewport
  31663. * @param viewport defines the viewport element to be used
  31664. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31665. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31666. */
  31667. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31668. /**
  31669. * Begin a new frame
  31670. */
  31671. beginFrame(): void;
  31672. /**
  31673. * Enf the current frame
  31674. */
  31675. endFrame(): void;
  31676. /**
  31677. * Resize the view according to the canvas' size
  31678. */
  31679. resize(): void;
  31680. /**
  31681. * Force a specific size of the canvas
  31682. * @param width defines the new canvas' width
  31683. * @param height defines the new canvas' height
  31684. */
  31685. setSize(width: number, height: number): void;
  31686. /**
  31687. * Binds the frame buffer to the specified texture.
  31688. * @param texture The texture to render to or null for the default canvas
  31689. * @param faceIndex The face of the texture to render to in case of cube texture
  31690. * @param requiredWidth The width of the target to render to
  31691. * @param requiredHeight The height of the target to render to
  31692. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31693. * @param lodLevel defines the lod level to bind to the frame buffer
  31694. * @param layer defines the 2d array index to bind to frame buffer to
  31695. */
  31696. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31697. /** @hidden */
  31698. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31699. /**
  31700. * Unbind the current render target texture from the webGL context
  31701. * @param texture defines the render target texture to unbind
  31702. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31703. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31704. */
  31705. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31706. /**
  31707. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31708. */
  31709. flushFramebuffer(): void;
  31710. /**
  31711. * Unbind the current render target and bind the default framebuffer
  31712. */
  31713. restoreDefaultFramebuffer(): void;
  31714. /** @hidden */
  31715. protected _resetVertexBufferBinding(): void;
  31716. /**
  31717. * Creates a vertex buffer
  31718. * @param data the data for the vertex buffer
  31719. * @returns the new WebGL static buffer
  31720. */
  31721. createVertexBuffer(data: DataArray): DataBuffer;
  31722. private _createVertexBuffer;
  31723. /**
  31724. * Creates a dynamic vertex buffer
  31725. * @param data the data for the dynamic vertex buffer
  31726. * @returns the new WebGL dynamic buffer
  31727. */
  31728. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31729. protected _resetIndexBufferBinding(): void;
  31730. /**
  31731. * Creates a new index buffer
  31732. * @param indices defines the content of the index buffer
  31733. * @param updatable defines if the index buffer must be updatable
  31734. * @returns a new webGL buffer
  31735. */
  31736. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31737. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31738. /**
  31739. * Bind a webGL buffer to the webGL context
  31740. * @param buffer defines the buffer to bind
  31741. */
  31742. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31743. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31744. private bindBuffer;
  31745. /**
  31746. * update the bound buffer with the given data
  31747. * @param data defines the data to update
  31748. */
  31749. updateArrayBuffer(data: Float32Array): void;
  31750. private _vertexAttribPointer;
  31751. /** @hidden */
  31752. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31753. private _bindVertexBuffersAttributes;
  31754. /**
  31755. * Records a vertex array object
  31756. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31757. * @param vertexBuffers defines the list of vertex buffers to store
  31758. * @param indexBuffer defines the index buffer to store
  31759. * @param effect defines the effect to store
  31760. * @returns the new vertex array object
  31761. */
  31762. recordVertexArrayObject(vertexBuffers: {
  31763. [key: string]: VertexBuffer;
  31764. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31765. /**
  31766. * Bind a specific vertex array object
  31767. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31768. * @param vertexArrayObject defines the vertex array object to bind
  31769. * @param indexBuffer defines the index buffer to bind
  31770. */
  31771. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31772. /**
  31773. * Bind webGl buffers directly to the webGL context
  31774. * @param vertexBuffer defines the vertex buffer to bind
  31775. * @param indexBuffer defines the index buffer to bind
  31776. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31777. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31778. * @param effect defines the effect associated with the vertex buffer
  31779. */
  31780. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31781. private _unbindVertexArrayObject;
  31782. /**
  31783. * Bind a list of vertex buffers to the webGL context
  31784. * @param vertexBuffers defines the list of vertex buffers to bind
  31785. * @param indexBuffer defines the index buffer to bind
  31786. * @param effect defines the effect associated with the vertex buffers
  31787. */
  31788. bindBuffers(vertexBuffers: {
  31789. [key: string]: Nullable<VertexBuffer>;
  31790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31791. /**
  31792. * Unbind all instance attributes
  31793. */
  31794. unbindInstanceAttributes(): void;
  31795. /**
  31796. * Release and free the memory of a vertex array object
  31797. * @param vao defines the vertex array object to delete
  31798. */
  31799. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31800. /** @hidden */
  31801. _releaseBuffer(buffer: DataBuffer): boolean;
  31802. protected _deleteBuffer(buffer: DataBuffer): void;
  31803. /**
  31804. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31805. * @param instancesBuffer defines the webGL buffer to update and bind
  31806. * @param data defines the data to store in the buffer
  31807. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31808. */
  31809. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31810. /**
  31811. * Bind the content of a webGL buffer used with instantiation
  31812. * @param instancesBuffer defines the webGL buffer to bind
  31813. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31814. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31815. */
  31816. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31817. /**
  31818. * Disable the instance attribute corresponding to the name in parameter
  31819. * @param name defines the name of the attribute to disable
  31820. */
  31821. disableInstanceAttributeByName(name: string): void;
  31822. /**
  31823. * Disable the instance attribute corresponding to the location in parameter
  31824. * @param attributeLocation defines the attribute location of the attribute to disable
  31825. */
  31826. disableInstanceAttribute(attributeLocation: number): void;
  31827. /**
  31828. * Disable the attribute corresponding to the location in parameter
  31829. * @param attributeLocation defines the attribute location of the attribute to disable
  31830. */
  31831. disableAttributeByIndex(attributeLocation: number): void;
  31832. /**
  31833. * Send a draw order
  31834. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31835. * @param indexStart defines the starting index
  31836. * @param indexCount defines the number of index to draw
  31837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31838. */
  31839. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31840. /**
  31841. * Draw a list of points
  31842. * @param verticesStart defines the index of first vertex to draw
  31843. * @param verticesCount defines the count of vertices to draw
  31844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31845. */
  31846. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31847. /**
  31848. * Draw a list of unindexed primitives
  31849. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31850. * @param verticesStart defines the index of first vertex to draw
  31851. * @param verticesCount defines the count of vertices to draw
  31852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31853. */
  31854. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31855. /**
  31856. * Draw a list of indexed primitives
  31857. * @param fillMode defines the primitive to use
  31858. * @param indexStart defines the starting index
  31859. * @param indexCount defines the number of index to draw
  31860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31861. */
  31862. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31863. /**
  31864. * Draw a list of unindexed primitives
  31865. * @param fillMode defines the primitive to use
  31866. * @param verticesStart defines the index of first vertex to draw
  31867. * @param verticesCount defines the count of vertices to draw
  31868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31869. */
  31870. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31871. private _drawMode;
  31872. /** @hidden */
  31873. protected _reportDrawCall(): void;
  31874. /** @hidden */
  31875. _releaseEffect(effect: Effect): void;
  31876. /** @hidden */
  31877. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31878. /**
  31879. * Create a new effect (used to store vertex/fragment shaders)
  31880. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31881. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31882. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31883. * @param samplers defines an array of string used to represent textures
  31884. * @param defines defines the string containing the defines to use to compile the shaders
  31885. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31886. * @param onCompiled defines a function to call when the effect creation is successful
  31887. * @param onError defines a function to call when the effect creation has failed
  31888. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31889. * @returns the new Effect
  31890. */
  31891. 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;
  31892. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31893. private _compileShader;
  31894. private _compileRawShader;
  31895. /** @hidden */
  31896. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31897. /**
  31898. * Directly creates a webGL program
  31899. * @param pipelineContext defines the pipeline context to attach to
  31900. * @param vertexCode defines the vertex shader code to use
  31901. * @param fragmentCode defines the fragment shader code to use
  31902. * @param context defines the webGL context to use (if not set, the current one will be used)
  31903. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31904. * @returns the new webGL program
  31905. */
  31906. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31907. /**
  31908. * Creates a webGL program
  31909. * @param pipelineContext defines the pipeline context to attach to
  31910. * @param vertexCode defines the vertex shader code to use
  31911. * @param fragmentCode defines the fragment shader code to use
  31912. * @param defines defines the string containing the defines to use to compile the shaders
  31913. * @param context defines the webGL context to use (if not set, the current one will be used)
  31914. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31915. * @returns the new webGL program
  31916. */
  31917. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31918. /**
  31919. * Creates a new pipeline context
  31920. * @returns the new pipeline
  31921. */
  31922. createPipelineContext(): IPipelineContext;
  31923. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31924. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31925. /** @hidden */
  31926. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31927. /** @hidden */
  31928. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31929. /** @hidden */
  31930. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31931. /**
  31932. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31933. * @param pipelineContext defines the pipeline context to use
  31934. * @param uniformsNames defines the list of uniform names
  31935. * @returns an array of webGL uniform locations
  31936. */
  31937. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31938. /**
  31939. * Gets the lsit of active attributes for a given webGL program
  31940. * @param pipelineContext defines the pipeline context to use
  31941. * @param attributesNames defines the list of attribute names to get
  31942. * @returns an array of indices indicating the offset of each attribute
  31943. */
  31944. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31945. /**
  31946. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31947. * @param effect defines the effect to activate
  31948. */
  31949. enableEffect(effect: Nullable<Effect>): void;
  31950. /**
  31951. * Set the value of an uniform to a number (int)
  31952. * @param uniform defines the webGL uniform location where to store the value
  31953. * @param value defines the int number to store
  31954. */
  31955. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31956. /**
  31957. * Set the value of an uniform to an array of int32
  31958. * @param uniform defines the webGL uniform location where to store the value
  31959. * @param array defines the array of int32 to store
  31960. */
  31961. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31962. /**
  31963. * Set the value of an uniform to an array of int32 (stored as vec2)
  31964. * @param uniform defines the webGL uniform location where to store the value
  31965. * @param array defines the array of int32 to store
  31966. */
  31967. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31968. /**
  31969. * Set the value of an uniform to an array of int32 (stored as vec3)
  31970. * @param uniform defines the webGL uniform location where to store the value
  31971. * @param array defines the array of int32 to store
  31972. */
  31973. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31974. /**
  31975. * Set the value of an uniform to an array of int32 (stored as vec4)
  31976. * @param uniform defines the webGL uniform location where to store the value
  31977. * @param array defines the array of int32 to store
  31978. */
  31979. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31980. /**
  31981. * Set the value of an uniform to an array of number
  31982. * @param uniform defines the webGL uniform location where to store the value
  31983. * @param array defines the array of number to store
  31984. */
  31985. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31986. /**
  31987. * Set the value of an uniform to an array of number (stored as vec2)
  31988. * @param uniform defines the webGL uniform location where to store the value
  31989. * @param array defines the array of number to store
  31990. */
  31991. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31992. /**
  31993. * Set the value of an uniform to an array of number (stored as vec3)
  31994. * @param uniform defines the webGL uniform location where to store the value
  31995. * @param array defines the array of number to store
  31996. */
  31997. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31998. /**
  31999. * Set the value of an uniform to an array of number (stored as vec4)
  32000. * @param uniform defines the webGL uniform location where to store the value
  32001. * @param array defines the array of number to store
  32002. */
  32003. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32004. /**
  32005. * Set the value of an uniform to an array of float32 (stored as matrices)
  32006. * @param uniform defines the webGL uniform location where to store the value
  32007. * @param matrices defines the array of float32 to store
  32008. */
  32009. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32010. /**
  32011. * Set the value of an uniform to a matrix (3x3)
  32012. * @param uniform defines the webGL uniform location where to store the value
  32013. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32014. */
  32015. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32016. /**
  32017. * Set the value of an uniform to a matrix (2x2)
  32018. * @param uniform defines the webGL uniform location where to store the value
  32019. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32020. */
  32021. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32022. /**
  32023. * Set the value of an uniform to a number (float)
  32024. * @param uniform defines the webGL uniform location where to store the value
  32025. * @param value defines the float number to store
  32026. */
  32027. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32028. /**
  32029. * Set the value of an uniform to a vec2
  32030. * @param uniform defines the webGL uniform location where to store the value
  32031. * @param x defines the 1st component of the value
  32032. * @param y defines the 2nd component of the value
  32033. */
  32034. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32035. /**
  32036. * Set the value of an uniform to a vec3
  32037. * @param uniform defines the webGL uniform location where to store the value
  32038. * @param x defines the 1st component of the value
  32039. * @param y defines the 2nd component of the value
  32040. * @param z defines the 3rd component of the value
  32041. */
  32042. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32043. /**
  32044. * Set the value of an uniform to a vec4
  32045. * @param uniform defines the webGL uniform location where to store the value
  32046. * @param x defines the 1st component of the value
  32047. * @param y defines the 2nd component of the value
  32048. * @param z defines the 3rd component of the value
  32049. * @param w defines the 4th component of the value
  32050. */
  32051. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32052. /**
  32053. * Apply all cached states (depth, culling, stencil and alpha)
  32054. */
  32055. applyStates(): void;
  32056. /**
  32057. * Enable or disable color writing
  32058. * @param enable defines the state to set
  32059. */
  32060. setColorWrite(enable: boolean): void;
  32061. /**
  32062. * Gets a boolean indicating if color writing is enabled
  32063. * @returns the current color writing state
  32064. */
  32065. getColorWrite(): boolean;
  32066. /**
  32067. * Gets the depth culling state manager
  32068. */
  32069. get depthCullingState(): DepthCullingState;
  32070. /**
  32071. * Gets the alpha state manager
  32072. */
  32073. get alphaState(): AlphaState;
  32074. /**
  32075. * Gets the stencil state manager
  32076. */
  32077. get stencilState(): StencilState;
  32078. /**
  32079. * Clears the list of texture accessible through engine.
  32080. * This can help preventing texture load conflict due to name collision.
  32081. */
  32082. clearInternalTexturesCache(): void;
  32083. /**
  32084. * Force the entire cache to be cleared
  32085. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32086. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32087. */
  32088. wipeCaches(bruteForce?: boolean): void;
  32089. /** @hidden */
  32090. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32091. min: number;
  32092. mag: number;
  32093. };
  32094. /** @hidden */
  32095. _createTexture(): WebGLTexture;
  32096. /**
  32097. * Usually called from Texture.ts.
  32098. * Passed information to create a WebGLTexture
  32099. * @param url defines a value which contains one of the following:
  32100. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32101. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32102. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32103. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32104. * @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)
  32105. * @param scene needed for loading to the correct scene
  32106. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32107. * @param onLoad optional callback to be called upon successful completion
  32108. * @param onError optional callback to be called upon failure
  32109. * @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
  32110. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32111. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32112. * @param forcedExtension defines the extension to use to pick the right loader
  32113. * @param mimeType defines an optional mime type
  32114. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32115. */
  32116. 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;
  32117. /**
  32118. * Loads an image as an HTMLImageElement.
  32119. * @param input url string, ArrayBuffer, or Blob to load
  32120. * @param onLoad callback called when the image successfully loads
  32121. * @param onError callback called when the image fails to load
  32122. * @param offlineProvider offline provider for caching
  32123. * @param mimeType optional mime type
  32124. * @returns the HTMLImageElement of the loaded image
  32125. * @hidden
  32126. */
  32127. 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>;
  32128. /**
  32129. * @hidden
  32130. */
  32131. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32132. /**
  32133. * Creates a raw texture
  32134. * @param data defines the data to store in the texture
  32135. * @param width defines the width of the texture
  32136. * @param height defines the height of the texture
  32137. * @param format defines the format of the data
  32138. * @param generateMipMaps defines if the engine should generate the mip levels
  32139. * @param invertY defines if data must be stored with Y axis inverted
  32140. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32141. * @param compression defines the compression used (null by default)
  32142. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32143. * @returns the raw texture inside an InternalTexture
  32144. */
  32145. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32146. /**
  32147. * Creates a new raw cube texture
  32148. * @param data defines the array of data to use to create each face
  32149. * @param size defines the size of the textures
  32150. * @param format defines the format of the data
  32151. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32152. * @param generateMipMaps defines if the engine should generate the mip levels
  32153. * @param invertY defines if data must be stored with Y axis inverted
  32154. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32155. * @param compression defines the compression used (null by default)
  32156. * @returns the cube texture as an InternalTexture
  32157. */
  32158. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32159. /**
  32160. * Creates a new raw 3D texture
  32161. * @param data defines the data used to create the texture
  32162. * @param width defines the width of the texture
  32163. * @param height defines the height of the texture
  32164. * @param depth defines the depth of the texture
  32165. * @param format defines the format of the texture
  32166. * @param generateMipMaps defines if the engine must generate mip levels
  32167. * @param invertY defines if data must be stored with Y axis inverted
  32168. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32169. * @param compression defines the compressed used (can be null)
  32170. * @param textureType defines the compressed used (can be null)
  32171. * @returns a new raw 3D texture (stored in an InternalTexture)
  32172. */
  32173. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32174. /**
  32175. * Creates a new raw 2D array texture
  32176. * @param data defines the data used to create the texture
  32177. * @param width defines the width of the texture
  32178. * @param height defines the height of the texture
  32179. * @param depth defines the number of layers of the texture
  32180. * @param format defines the format of the texture
  32181. * @param generateMipMaps defines if the engine must generate mip levels
  32182. * @param invertY defines if data must be stored with Y axis inverted
  32183. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32184. * @param compression defines the compressed used (can be null)
  32185. * @param textureType defines the compressed used (can be null)
  32186. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32187. */
  32188. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32189. private _unpackFlipYCached;
  32190. /**
  32191. * In case you are sharing the context with other applications, it might
  32192. * be interested to not cache the unpack flip y state to ensure a consistent
  32193. * value would be set.
  32194. */
  32195. enableUnpackFlipYCached: boolean;
  32196. /** @hidden */
  32197. _unpackFlipY(value: boolean): void;
  32198. /** @hidden */
  32199. _getUnpackAlignement(): number;
  32200. private _getTextureTarget;
  32201. /**
  32202. * Update the sampling mode of a given texture
  32203. * @param samplingMode defines the required sampling mode
  32204. * @param texture defines the texture to update
  32205. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32206. */
  32207. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32208. /**
  32209. * Update the sampling mode of a given texture
  32210. * @param texture defines the texture to update
  32211. * @param wrapU defines the texture wrap mode of the u coordinates
  32212. * @param wrapV defines the texture wrap mode of the v coordinates
  32213. * @param wrapR defines the texture wrap mode of the r coordinates
  32214. */
  32215. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32216. /** @hidden */
  32217. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32218. width: number;
  32219. height: number;
  32220. layers?: number;
  32221. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32222. /** @hidden */
  32223. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32224. /** @hidden */
  32225. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32226. /**
  32227. * Update a portion of an internal texture
  32228. * @param texture defines the texture to update
  32229. * @param imageData defines the data to store into the texture
  32230. * @param xOffset defines the x coordinates of the update rectangle
  32231. * @param yOffset defines the y coordinates of the update rectangle
  32232. * @param width defines the width of the update rectangle
  32233. * @param height defines the height of the update rectangle
  32234. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32235. * @param lod defines the lod level to update (0 by default)
  32236. */
  32237. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32238. /** @hidden */
  32239. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32240. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32241. private _prepareWebGLTexture;
  32242. /** @hidden */
  32243. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32244. private _getDepthStencilBuffer;
  32245. /** @hidden */
  32246. _releaseFramebufferObjects(texture: InternalTexture): void;
  32247. /** @hidden */
  32248. _releaseTexture(texture: InternalTexture): void;
  32249. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32250. protected _setProgram(program: WebGLProgram): void;
  32251. protected _boundUniforms: {
  32252. [key: number]: WebGLUniformLocation;
  32253. };
  32254. /**
  32255. * Binds an effect to the webGL context
  32256. * @param effect defines the effect to bind
  32257. */
  32258. bindSamplers(effect: Effect): void;
  32259. private _activateCurrentTexture;
  32260. /** @hidden */
  32261. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32262. /** @hidden */
  32263. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32264. /**
  32265. * Unbind all textures from the webGL context
  32266. */
  32267. unbindAllTextures(): void;
  32268. /**
  32269. * Sets a texture to the according uniform.
  32270. * @param channel The texture channel
  32271. * @param uniform The uniform to set
  32272. * @param texture The texture to apply
  32273. */
  32274. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32275. private _bindSamplerUniformToChannel;
  32276. private _getTextureWrapMode;
  32277. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32278. /**
  32279. * Sets an array of texture to the webGL context
  32280. * @param channel defines the channel where the texture array must be set
  32281. * @param uniform defines the associated uniform location
  32282. * @param textures defines the array of textures to bind
  32283. */
  32284. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32285. /** @hidden */
  32286. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32287. private _setTextureParameterFloat;
  32288. private _setTextureParameterInteger;
  32289. /**
  32290. * Unbind all vertex attributes from the webGL context
  32291. */
  32292. unbindAllAttributes(): void;
  32293. /**
  32294. * 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
  32295. */
  32296. releaseEffects(): void;
  32297. /**
  32298. * Dispose and release all associated resources
  32299. */
  32300. dispose(): void;
  32301. /**
  32302. * Attach a new callback raised when context lost event is fired
  32303. * @param callback defines the callback to call
  32304. */
  32305. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32306. /**
  32307. * Attach a new callback raised when context restored event is fired
  32308. * @param callback defines the callback to call
  32309. */
  32310. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32311. /**
  32312. * Get the current error code of the webGL context
  32313. * @returns the error code
  32314. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32315. */
  32316. getError(): number;
  32317. private _canRenderToFloatFramebuffer;
  32318. private _canRenderToHalfFloatFramebuffer;
  32319. private _canRenderToFramebuffer;
  32320. /** @hidden */
  32321. _getWebGLTextureType(type: number): number;
  32322. /** @hidden */
  32323. _getInternalFormat(format: number): number;
  32324. /** @hidden */
  32325. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32326. /** @hidden */
  32327. _getRGBAMultiSampleBufferFormat(type: number): number;
  32328. /** @hidden */
  32329. _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;
  32330. /**
  32331. * Loads a file from a url
  32332. * @param url url to load
  32333. * @param onSuccess callback called when the file successfully loads
  32334. * @param onProgress callback called while file is loading (if the server supports this mode)
  32335. * @param offlineProvider defines the offline provider for caching
  32336. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32337. * @param onError callback called when the file fails to load
  32338. * @returns a file request object
  32339. * @hidden
  32340. */
  32341. 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;
  32342. /**
  32343. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32344. * @param x defines the x coordinate of the rectangle where pixels must be read
  32345. * @param y defines the y coordinate of the rectangle where pixels must be read
  32346. * @param width defines the width of the rectangle where pixels must be read
  32347. * @param height defines the height of the rectangle where pixels must be read
  32348. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32349. * @returns a Uint8Array containing RGBA colors
  32350. */
  32351. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32352. private static _isSupported;
  32353. /**
  32354. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32355. * @returns true if the engine can be created
  32356. * @ignorenaming
  32357. */
  32358. static isSupported(): boolean;
  32359. /**
  32360. * Find the next highest power of two.
  32361. * @param x Number to start search from.
  32362. * @return Next highest power of two.
  32363. */
  32364. static CeilingPOT(x: number): number;
  32365. /**
  32366. * Find the next lowest power of two.
  32367. * @param x Number to start search from.
  32368. * @return Next lowest power of two.
  32369. */
  32370. static FloorPOT(x: number): number;
  32371. /**
  32372. * Find the nearest power of two.
  32373. * @param x Number to start search from.
  32374. * @return Next nearest power of two.
  32375. */
  32376. static NearestPOT(x: number): number;
  32377. /**
  32378. * Get the closest exponent of two
  32379. * @param value defines the value to approximate
  32380. * @param max defines the maximum value to return
  32381. * @param mode defines how to define the closest value
  32382. * @returns closest exponent of two of the given value
  32383. */
  32384. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32385. /**
  32386. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32387. * @param func - the function to be called
  32388. * @param requester - the object that will request the next frame. Falls back to window.
  32389. * @returns frame number
  32390. */
  32391. static QueueNewFrame(func: () => void, requester?: any): number;
  32392. /**
  32393. * Gets host document
  32394. * @returns the host document object
  32395. */
  32396. getHostDocument(): Nullable<Document>;
  32397. }
  32398. }
  32399. declare module BABYLON {
  32400. /**
  32401. * Class representing spherical harmonics coefficients to the 3rd degree
  32402. */
  32403. export class SphericalHarmonics {
  32404. /**
  32405. * Defines whether or not the harmonics have been prescaled for rendering.
  32406. */
  32407. preScaled: boolean;
  32408. /**
  32409. * The l0,0 coefficients of the spherical harmonics
  32410. */
  32411. l00: Vector3;
  32412. /**
  32413. * The l1,-1 coefficients of the spherical harmonics
  32414. */
  32415. l1_1: Vector3;
  32416. /**
  32417. * The l1,0 coefficients of the spherical harmonics
  32418. */
  32419. l10: Vector3;
  32420. /**
  32421. * The l1,1 coefficients of the spherical harmonics
  32422. */
  32423. l11: Vector3;
  32424. /**
  32425. * The l2,-2 coefficients of the spherical harmonics
  32426. */
  32427. l2_2: Vector3;
  32428. /**
  32429. * The l2,-1 coefficients of the spherical harmonics
  32430. */
  32431. l2_1: Vector3;
  32432. /**
  32433. * The l2,0 coefficients of the spherical harmonics
  32434. */
  32435. l20: Vector3;
  32436. /**
  32437. * The l2,1 coefficients of the spherical harmonics
  32438. */
  32439. l21: Vector3;
  32440. /**
  32441. * The l2,2 coefficients of the spherical harmonics
  32442. */
  32443. l22: Vector3;
  32444. /**
  32445. * Adds a light to the spherical harmonics
  32446. * @param direction the direction of the light
  32447. * @param color the color of the light
  32448. * @param deltaSolidAngle the delta solid angle of the light
  32449. */
  32450. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32451. /**
  32452. * Scales the spherical harmonics by the given amount
  32453. * @param scale the amount to scale
  32454. */
  32455. scaleInPlace(scale: number): void;
  32456. /**
  32457. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32458. *
  32459. * ```
  32460. * E_lm = A_l * L_lm
  32461. * ```
  32462. *
  32463. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32464. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32465. * the scaling factors are given in equation 9.
  32466. */
  32467. convertIncidentRadianceToIrradiance(): void;
  32468. /**
  32469. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32470. *
  32471. * ```
  32472. * L = (1/pi) * E * rho
  32473. * ```
  32474. *
  32475. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32476. */
  32477. convertIrradianceToLambertianRadiance(): void;
  32478. /**
  32479. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32480. * required operations at run time.
  32481. *
  32482. * This is simply done by scaling back the SH with Ylm constants parameter.
  32483. * The trigonometric part being applied by the shader at run time.
  32484. */
  32485. preScaleForRendering(): void;
  32486. /**
  32487. * Constructs a spherical harmonics from an array.
  32488. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32489. * @returns the spherical harmonics
  32490. */
  32491. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32492. /**
  32493. * Gets the spherical harmonics from polynomial
  32494. * @param polynomial the spherical polynomial
  32495. * @returns the spherical harmonics
  32496. */
  32497. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32498. }
  32499. /**
  32500. * Class representing spherical polynomial coefficients to the 3rd degree
  32501. */
  32502. export class SphericalPolynomial {
  32503. private _harmonics;
  32504. /**
  32505. * The spherical harmonics used to create the polynomials.
  32506. */
  32507. get preScaledHarmonics(): SphericalHarmonics;
  32508. /**
  32509. * The x coefficients of the spherical polynomial
  32510. */
  32511. x: Vector3;
  32512. /**
  32513. * The y coefficients of the spherical polynomial
  32514. */
  32515. y: Vector3;
  32516. /**
  32517. * The z coefficients of the spherical polynomial
  32518. */
  32519. z: Vector3;
  32520. /**
  32521. * The xx coefficients of the spherical polynomial
  32522. */
  32523. xx: Vector3;
  32524. /**
  32525. * The yy coefficients of the spherical polynomial
  32526. */
  32527. yy: Vector3;
  32528. /**
  32529. * The zz coefficients of the spherical polynomial
  32530. */
  32531. zz: Vector3;
  32532. /**
  32533. * The xy coefficients of the spherical polynomial
  32534. */
  32535. xy: Vector3;
  32536. /**
  32537. * The yz coefficients of the spherical polynomial
  32538. */
  32539. yz: Vector3;
  32540. /**
  32541. * The zx coefficients of the spherical polynomial
  32542. */
  32543. zx: Vector3;
  32544. /**
  32545. * Adds an ambient color to the spherical polynomial
  32546. * @param color the color to add
  32547. */
  32548. addAmbient(color: Color3): void;
  32549. /**
  32550. * Scales the spherical polynomial by the given amount
  32551. * @param scale the amount to scale
  32552. */
  32553. scaleInPlace(scale: number): void;
  32554. /**
  32555. * Gets the spherical polynomial from harmonics
  32556. * @param harmonics the spherical harmonics
  32557. * @returns the spherical polynomial
  32558. */
  32559. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32560. /**
  32561. * Constructs a spherical polynomial from an array.
  32562. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32563. * @returns the spherical polynomial
  32564. */
  32565. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32566. }
  32567. }
  32568. declare module BABYLON {
  32569. /**
  32570. * Defines the source of the internal texture
  32571. */
  32572. export enum InternalTextureSource {
  32573. /**
  32574. * The source of the texture data is unknown
  32575. */
  32576. Unknown = 0,
  32577. /**
  32578. * Texture data comes from an URL
  32579. */
  32580. Url = 1,
  32581. /**
  32582. * Texture data is only used for temporary storage
  32583. */
  32584. Temp = 2,
  32585. /**
  32586. * Texture data comes from raw data (ArrayBuffer)
  32587. */
  32588. Raw = 3,
  32589. /**
  32590. * Texture content is dynamic (video or dynamic texture)
  32591. */
  32592. Dynamic = 4,
  32593. /**
  32594. * Texture content is generated by rendering to it
  32595. */
  32596. RenderTarget = 5,
  32597. /**
  32598. * Texture content is part of a multi render target process
  32599. */
  32600. MultiRenderTarget = 6,
  32601. /**
  32602. * Texture data comes from a cube data file
  32603. */
  32604. Cube = 7,
  32605. /**
  32606. * Texture data comes from a raw cube data
  32607. */
  32608. CubeRaw = 8,
  32609. /**
  32610. * Texture data come from a prefiltered cube data file
  32611. */
  32612. CubePrefiltered = 9,
  32613. /**
  32614. * Texture content is raw 3D data
  32615. */
  32616. Raw3D = 10,
  32617. /**
  32618. * Texture content is raw 2D array data
  32619. */
  32620. Raw2DArray = 11,
  32621. /**
  32622. * Texture content is a depth texture
  32623. */
  32624. Depth = 12,
  32625. /**
  32626. * Texture data comes from a raw cube data encoded with RGBD
  32627. */
  32628. CubeRawRGBD = 13
  32629. }
  32630. /**
  32631. * Class used to store data associated with WebGL texture data for the engine
  32632. * This class should not be used directly
  32633. */
  32634. export class InternalTexture {
  32635. /** @hidden */
  32636. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32637. /**
  32638. * Defines if the texture is ready
  32639. */
  32640. isReady: boolean;
  32641. /**
  32642. * Defines if the texture is a cube texture
  32643. */
  32644. isCube: boolean;
  32645. /**
  32646. * Defines if the texture contains 3D data
  32647. */
  32648. is3D: boolean;
  32649. /**
  32650. * Defines if the texture contains 2D array data
  32651. */
  32652. is2DArray: boolean;
  32653. /**
  32654. * Defines if the texture contains multiview data
  32655. */
  32656. isMultiview: boolean;
  32657. /**
  32658. * Gets the URL used to load this texture
  32659. */
  32660. url: string;
  32661. /**
  32662. * Gets the sampling mode of the texture
  32663. */
  32664. samplingMode: number;
  32665. /**
  32666. * Gets a boolean indicating if the texture needs mipmaps generation
  32667. */
  32668. generateMipMaps: boolean;
  32669. /**
  32670. * Gets the number of samples used by the texture (WebGL2+ only)
  32671. */
  32672. samples: number;
  32673. /**
  32674. * Gets the type of the texture (int, float...)
  32675. */
  32676. type: number;
  32677. /**
  32678. * Gets the format of the texture (RGB, RGBA...)
  32679. */
  32680. format: number;
  32681. /**
  32682. * Observable called when the texture is loaded
  32683. */
  32684. onLoadedObservable: Observable<InternalTexture>;
  32685. /**
  32686. * Gets the width of the texture
  32687. */
  32688. width: number;
  32689. /**
  32690. * Gets the height of the texture
  32691. */
  32692. height: number;
  32693. /**
  32694. * Gets the depth of the texture
  32695. */
  32696. depth: number;
  32697. /**
  32698. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32699. */
  32700. baseWidth: number;
  32701. /**
  32702. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32703. */
  32704. baseHeight: number;
  32705. /**
  32706. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32707. */
  32708. baseDepth: number;
  32709. /**
  32710. * Gets a boolean indicating if the texture is inverted on Y axis
  32711. */
  32712. invertY: boolean;
  32713. /** @hidden */
  32714. _invertVScale: boolean;
  32715. /** @hidden */
  32716. _associatedChannel: number;
  32717. /** @hidden */
  32718. _source: InternalTextureSource;
  32719. /** @hidden */
  32720. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32721. /** @hidden */
  32722. _bufferView: Nullable<ArrayBufferView>;
  32723. /** @hidden */
  32724. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32725. /** @hidden */
  32726. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32727. /** @hidden */
  32728. _size: number;
  32729. /** @hidden */
  32730. _extension: string;
  32731. /** @hidden */
  32732. _files: Nullable<string[]>;
  32733. /** @hidden */
  32734. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32735. /** @hidden */
  32736. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32737. /** @hidden */
  32738. _framebuffer: Nullable<WebGLFramebuffer>;
  32739. /** @hidden */
  32740. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32741. /** @hidden */
  32742. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32743. /** @hidden */
  32744. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32745. /** @hidden */
  32746. _attachments: Nullable<number[]>;
  32747. /** @hidden */
  32748. _cachedCoordinatesMode: Nullable<number>;
  32749. /** @hidden */
  32750. _cachedWrapU: Nullable<number>;
  32751. /** @hidden */
  32752. _cachedWrapV: Nullable<number>;
  32753. /** @hidden */
  32754. _cachedWrapR: Nullable<number>;
  32755. /** @hidden */
  32756. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32757. /** @hidden */
  32758. _isDisabled: boolean;
  32759. /** @hidden */
  32760. _compression: Nullable<string>;
  32761. /** @hidden */
  32762. _generateStencilBuffer: boolean;
  32763. /** @hidden */
  32764. _generateDepthBuffer: boolean;
  32765. /** @hidden */
  32766. _comparisonFunction: number;
  32767. /** @hidden */
  32768. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32769. /** @hidden */
  32770. _lodGenerationScale: number;
  32771. /** @hidden */
  32772. _lodGenerationOffset: number;
  32773. /** @hidden */
  32774. _depthStencilTexture: Nullable<InternalTexture>;
  32775. /** @hidden */
  32776. _colorTextureArray: Nullable<WebGLTexture>;
  32777. /** @hidden */
  32778. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32779. /** @hidden */
  32780. _lodTextureHigh: Nullable<BaseTexture>;
  32781. /** @hidden */
  32782. _lodTextureMid: Nullable<BaseTexture>;
  32783. /** @hidden */
  32784. _lodTextureLow: Nullable<BaseTexture>;
  32785. /** @hidden */
  32786. _isRGBD: boolean;
  32787. /** @hidden */
  32788. _linearSpecularLOD: boolean;
  32789. /** @hidden */
  32790. _irradianceTexture: Nullable<BaseTexture>;
  32791. /** @hidden */
  32792. _webGLTexture: Nullable<WebGLTexture>;
  32793. /** @hidden */
  32794. _references: number;
  32795. private _engine;
  32796. /**
  32797. * Gets the Engine the texture belongs to.
  32798. * @returns The babylon engine
  32799. */
  32800. getEngine(): ThinEngine;
  32801. /**
  32802. * Gets the data source type of the texture
  32803. */
  32804. get source(): InternalTextureSource;
  32805. /**
  32806. * Creates a new InternalTexture
  32807. * @param engine defines the engine to use
  32808. * @param source defines the type of data that will be used
  32809. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32810. */
  32811. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32812. /**
  32813. * Increments the number of references (ie. the number of Texture that point to it)
  32814. */
  32815. incrementReferences(): void;
  32816. /**
  32817. * Change the size of the texture (not the size of the content)
  32818. * @param width defines the new width
  32819. * @param height defines the new height
  32820. * @param depth defines the new depth (1 by default)
  32821. */
  32822. updateSize(width: int, height: int, depth?: int): void;
  32823. /** @hidden */
  32824. _rebuild(): void;
  32825. /** @hidden */
  32826. _swapAndDie(target: InternalTexture): void;
  32827. /**
  32828. * Dispose the current allocated resources
  32829. */
  32830. dispose(): void;
  32831. }
  32832. }
  32833. declare module BABYLON {
  32834. /**
  32835. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32837. */
  32838. export class Analyser {
  32839. /**
  32840. * Gets or sets the smoothing
  32841. * @ignorenaming
  32842. */
  32843. SMOOTHING: number;
  32844. /**
  32845. * Gets or sets the FFT table size
  32846. * @ignorenaming
  32847. */
  32848. FFT_SIZE: number;
  32849. /**
  32850. * Gets or sets the bar graph amplitude
  32851. * @ignorenaming
  32852. */
  32853. BARGRAPHAMPLITUDE: number;
  32854. /**
  32855. * Gets or sets the position of the debug canvas
  32856. * @ignorenaming
  32857. */
  32858. DEBUGCANVASPOS: {
  32859. x: number;
  32860. y: number;
  32861. };
  32862. /**
  32863. * Gets or sets the debug canvas size
  32864. * @ignorenaming
  32865. */
  32866. DEBUGCANVASSIZE: {
  32867. width: number;
  32868. height: number;
  32869. };
  32870. private _byteFreqs;
  32871. private _byteTime;
  32872. private _floatFreqs;
  32873. private _webAudioAnalyser;
  32874. private _debugCanvas;
  32875. private _debugCanvasContext;
  32876. private _scene;
  32877. private _registerFunc;
  32878. private _audioEngine;
  32879. /**
  32880. * Creates a new analyser
  32881. * @param scene defines hosting scene
  32882. */
  32883. constructor(scene: Scene);
  32884. /**
  32885. * Get the number of data values you will have to play with for the visualization
  32886. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32887. * @returns a number
  32888. */
  32889. getFrequencyBinCount(): number;
  32890. /**
  32891. * Gets the current frequency data as a byte array
  32892. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32893. * @returns a Uint8Array
  32894. */
  32895. getByteFrequencyData(): Uint8Array;
  32896. /**
  32897. * Gets the current waveform as a byte array
  32898. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32899. * @returns a Uint8Array
  32900. */
  32901. getByteTimeDomainData(): Uint8Array;
  32902. /**
  32903. * Gets the current frequency data as a float array
  32904. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32905. * @returns a Float32Array
  32906. */
  32907. getFloatFrequencyData(): Float32Array;
  32908. /**
  32909. * Renders the debug canvas
  32910. */
  32911. drawDebugCanvas(): void;
  32912. /**
  32913. * Stops rendering the debug canvas and removes it
  32914. */
  32915. stopDebugCanvas(): void;
  32916. /**
  32917. * Connects two audio nodes
  32918. * @param inputAudioNode defines first node to connect
  32919. * @param outputAudioNode defines second node to connect
  32920. */
  32921. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32922. /**
  32923. * Releases all associated resources
  32924. */
  32925. dispose(): void;
  32926. }
  32927. }
  32928. declare module BABYLON {
  32929. /**
  32930. * This represents an audio engine and it is responsible
  32931. * to play, synchronize and analyse sounds throughout the application.
  32932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32933. */
  32934. export interface IAudioEngine extends IDisposable {
  32935. /**
  32936. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32937. */
  32938. readonly canUseWebAudio: boolean;
  32939. /**
  32940. * Gets the current AudioContext if available.
  32941. */
  32942. readonly audioContext: Nullable<AudioContext>;
  32943. /**
  32944. * The master gain node defines the global audio volume of your audio engine.
  32945. */
  32946. readonly masterGain: GainNode;
  32947. /**
  32948. * Gets whether or not mp3 are supported by your browser.
  32949. */
  32950. readonly isMP3supported: boolean;
  32951. /**
  32952. * Gets whether or not ogg are supported by your browser.
  32953. */
  32954. readonly isOGGsupported: boolean;
  32955. /**
  32956. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32957. * @ignoreNaming
  32958. */
  32959. WarnedWebAudioUnsupported: boolean;
  32960. /**
  32961. * Defines if the audio engine relies on a custom unlocked button.
  32962. * In this case, the embedded button will not be displayed.
  32963. */
  32964. useCustomUnlockedButton: boolean;
  32965. /**
  32966. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32967. */
  32968. readonly unlocked: boolean;
  32969. /**
  32970. * Event raised when audio has been unlocked on the browser.
  32971. */
  32972. onAudioUnlockedObservable: Observable<AudioEngine>;
  32973. /**
  32974. * Event raised when audio has been locked on the browser.
  32975. */
  32976. onAudioLockedObservable: Observable<AudioEngine>;
  32977. /**
  32978. * Flags the audio engine in Locked state.
  32979. * This happens due to new browser policies preventing audio to autoplay.
  32980. */
  32981. lock(): void;
  32982. /**
  32983. * Unlocks the audio engine once a user action has been done on the dom.
  32984. * This is helpful to resume play once browser policies have been satisfied.
  32985. */
  32986. unlock(): void;
  32987. /**
  32988. * Gets the global volume sets on the master gain.
  32989. * @returns the global volume if set or -1 otherwise
  32990. */
  32991. getGlobalVolume(): number;
  32992. /**
  32993. * Sets the global volume of your experience (sets on the master gain).
  32994. * @param newVolume Defines the new global volume of the application
  32995. */
  32996. setGlobalVolume(newVolume: number): void;
  32997. /**
  32998. * Connect the audio engine to an audio analyser allowing some amazing
  32999. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33001. * @param analyser The analyser to connect to the engine
  33002. */
  33003. connectToAnalyser(analyser: Analyser): void;
  33004. }
  33005. /**
  33006. * This represents the default audio engine used in babylon.
  33007. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33009. */
  33010. export class AudioEngine implements IAudioEngine {
  33011. private _audioContext;
  33012. private _audioContextInitialized;
  33013. private _muteButton;
  33014. private _hostElement;
  33015. /**
  33016. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33017. */
  33018. canUseWebAudio: boolean;
  33019. /**
  33020. * The master gain node defines the global audio volume of your audio engine.
  33021. */
  33022. masterGain: GainNode;
  33023. /**
  33024. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33025. * @ignoreNaming
  33026. */
  33027. WarnedWebAudioUnsupported: boolean;
  33028. /**
  33029. * Gets whether or not mp3 are supported by your browser.
  33030. */
  33031. isMP3supported: boolean;
  33032. /**
  33033. * Gets whether or not ogg are supported by your browser.
  33034. */
  33035. isOGGsupported: boolean;
  33036. /**
  33037. * Gets whether audio has been unlocked on the device.
  33038. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33039. * a user interaction has happened.
  33040. */
  33041. unlocked: boolean;
  33042. /**
  33043. * Defines if the audio engine relies on a custom unlocked button.
  33044. * In this case, the embedded button will not be displayed.
  33045. */
  33046. useCustomUnlockedButton: boolean;
  33047. /**
  33048. * Event raised when audio has been unlocked on the browser.
  33049. */
  33050. onAudioUnlockedObservable: Observable<AudioEngine>;
  33051. /**
  33052. * Event raised when audio has been locked on the browser.
  33053. */
  33054. onAudioLockedObservable: Observable<AudioEngine>;
  33055. /**
  33056. * Gets the current AudioContext if available.
  33057. */
  33058. get audioContext(): Nullable<AudioContext>;
  33059. private _connectedAnalyser;
  33060. /**
  33061. * Instantiates a new audio engine.
  33062. *
  33063. * There should be only one per page as some browsers restrict the number
  33064. * of audio contexts you can create.
  33065. * @param hostElement defines the host element where to display the mute icon if necessary
  33066. */
  33067. constructor(hostElement?: Nullable<HTMLElement>);
  33068. /**
  33069. * Flags the audio engine in Locked state.
  33070. * This happens due to new browser policies preventing audio to autoplay.
  33071. */
  33072. lock(): void;
  33073. /**
  33074. * Unlocks the audio engine once a user action has been done on the dom.
  33075. * This is helpful to resume play once browser policies have been satisfied.
  33076. */
  33077. unlock(): void;
  33078. private _resumeAudioContext;
  33079. private _initializeAudioContext;
  33080. private _tryToRun;
  33081. private _triggerRunningState;
  33082. private _triggerSuspendedState;
  33083. private _displayMuteButton;
  33084. private _moveButtonToTopLeft;
  33085. private _onResize;
  33086. private _hideMuteButton;
  33087. /**
  33088. * Destroy and release the resources associated with the audio ccontext.
  33089. */
  33090. dispose(): void;
  33091. /**
  33092. * Gets the global volume sets on the master gain.
  33093. * @returns the global volume if set or -1 otherwise
  33094. */
  33095. getGlobalVolume(): number;
  33096. /**
  33097. * Sets the global volume of your experience (sets on the master gain).
  33098. * @param newVolume Defines the new global volume of the application
  33099. */
  33100. setGlobalVolume(newVolume: number): void;
  33101. /**
  33102. * Connect the audio engine to an audio analyser allowing some amazing
  33103. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33105. * @param analyser The analyser to connect to the engine
  33106. */
  33107. connectToAnalyser(analyser: Analyser): void;
  33108. }
  33109. }
  33110. declare module BABYLON {
  33111. /**
  33112. * Interface used to present a loading screen while loading a scene
  33113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33114. */
  33115. export interface ILoadingScreen {
  33116. /**
  33117. * Function called to display the loading screen
  33118. */
  33119. displayLoadingUI: () => void;
  33120. /**
  33121. * Function called to hide the loading screen
  33122. */
  33123. hideLoadingUI: () => void;
  33124. /**
  33125. * Gets or sets the color to use for the background
  33126. */
  33127. loadingUIBackgroundColor: string;
  33128. /**
  33129. * Gets or sets the text to display while loading
  33130. */
  33131. loadingUIText: string;
  33132. }
  33133. /**
  33134. * Class used for the default loading screen
  33135. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33136. */
  33137. export class DefaultLoadingScreen implements ILoadingScreen {
  33138. private _renderingCanvas;
  33139. private _loadingText;
  33140. private _loadingDivBackgroundColor;
  33141. private _loadingDiv;
  33142. private _loadingTextDiv;
  33143. /** Gets or sets the logo url to use for the default loading screen */
  33144. static DefaultLogoUrl: string;
  33145. /** Gets or sets the spinner url to use for the default loading screen */
  33146. static DefaultSpinnerUrl: string;
  33147. /**
  33148. * Creates a new default loading screen
  33149. * @param _renderingCanvas defines the canvas used to render the scene
  33150. * @param _loadingText defines the default text to display
  33151. * @param _loadingDivBackgroundColor defines the default background color
  33152. */
  33153. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33154. /**
  33155. * Function called to display the loading screen
  33156. */
  33157. displayLoadingUI(): void;
  33158. /**
  33159. * Function called to hide the loading screen
  33160. */
  33161. hideLoadingUI(): void;
  33162. /**
  33163. * Gets or sets the text to display while loading
  33164. */
  33165. set loadingUIText(text: string);
  33166. get loadingUIText(): string;
  33167. /**
  33168. * Gets or sets the color to use for the background
  33169. */
  33170. get loadingUIBackgroundColor(): string;
  33171. set loadingUIBackgroundColor(color: string);
  33172. private _resizeLoadingUI;
  33173. }
  33174. }
  33175. declare module BABYLON {
  33176. /**
  33177. * Interface for any object that can request an animation frame
  33178. */
  33179. export interface ICustomAnimationFrameRequester {
  33180. /**
  33181. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33182. */
  33183. renderFunction?: Function;
  33184. /**
  33185. * Called to request the next frame to render to
  33186. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33187. */
  33188. requestAnimationFrame: Function;
  33189. /**
  33190. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33191. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33192. */
  33193. requestID?: number;
  33194. }
  33195. }
  33196. declare module BABYLON {
  33197. /**
  33198. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33199. */
  33200. export class PerformanceMonitor {
  33201. private _enabled;
  33202. private _rollingFrameTime;
  33203. private _lastFrameTimeMs;
  33204. /**
  33205. * constructor
  33206. * @param frameSampleSize The number of samples required to saturate the sliding window
  33207. */
  33208. constructor(frameSampleSize?: number);
  33209. /**
  33210. * Samples current frame
  33211. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33212. */
  33213. sampleFrame(timeMs?: number): void;
  33214. /**
  33215. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33216. */
  33217. get averageFrameTime(): number;
  33218. /**
  33219. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33220. */
  33221. get averageFrameTimeVariance(): number;
  33222. /**
  33223. * Returns the frame time of the most recent frame
  33224. */
  33225. get instantaneousFrameTime(): number;
  33226. /**
  33227. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33228. */
  33229. get averageFPS(): number;
  33230. /**
  33231. * Returns the average framerate in frames per second using the most recent frame time
  33232. */
  33233. get instantaneousFPS(): number;
  33234. /**
  33235. * Returns true if enough samples have been taken to completely fill the sliding window
  33236. */
  33237. get isSaturated(): boolean;
  33238. /**
  33239. * Enables contributions to the sliding window sample set
  33240. */
  33241. enable(): void;
  33242. /**
  33243. * Disables contributions to the sliding window sample set
  33244. * Samples will not be interpolated over the disabled period
  33245. */
  33246. disable(): void;
  33247. /**
  33248. * Returns true if sampling is enabled
  33249. */
  33250. get isEnabled(): boolean;
  33251. /**
  33252. * Resets performance monitor
  33253. */
  33254. reset(): void;
  33255. }
  33256. /**
  33257. * RollingAverage
  33258. *
  33259. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33260. */
  33261. export class RollingAverage {
  33262. /**
  33263. * Current average
  33264. */
  33265. average: number;
  33266. /**
  33267. * Current variance
  33268. */
  33269. variance: number;
  33270. protected _samples: Array<number>;
  33271. protected _sampleCount: number;
  33272. protected _pos: number;
  33273. protected _m2: number;
  33274. /**
  33275. * constructor
  33276. * @param length The number of samples required to saturate the sliding window
  33277. */
  33278. constructor(length: number);
  33279. /**
  33280. * Adds a sample to the sample set
  33281. * @param v The sample value
  33282. */
  33283. add(v: number): void;
  33284. /**
  33285. * Returns previously added values or null if outside of history or outside the sliding window domain
  33286. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33287. * @return Value previously recorded with add() or null if outside of range
  33288. */
  33289. history(i: number): number;
  33290. /**
  33291. * Returns true if enough samples have been taken to completely fill the sliding window
  33292. * @return true if sample-set saturated
  33293. */
  33294. isSaturated(): boolean;
  33295. /**
  33296. * Resets the rolling average (equivalent to 0 samples taken so far)
  33297. */
  33298. reset(): void;
  33299. /**
  33300. * Wraps a value around the sample range boundaries
  33301. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33302. * @return Wrapped position in sample range
  33303. */
  33304. protected _wrapPosition(i: number): number;
  33305. }
  33306. }
  33307. declare module BABYLON {
  33308. /**
  33309. * This class is used to track a performance counter which is number based.
  33310. * The user has access to many properties which give statistics of different nature.
  33311. *
  33312. * The implementer can track two kinds of Performance Counter: time and count.
  33313. * 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.
  33314. * 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.
  33315. */
  33316. export class PerfCounter {
  33317. /**
  33318. * Gets or sets a global boolean to turn on and off all the counters
  33319. */
  33320. static Enabled: boolean;
  33321. /**
  33322. * Returns the smallest value ever
  33323. */
  33324. get min(): number;
  33325. /**
  33326. * Returns the biggest value ever
  33327. */
  33328. get max(): number;
  33329. /**
  33330. * Returns the average value since the performance counter is running
  33331. */
  33332. get average(): number;
  33333. /**
  33334. * Returns the average value of the last second the counter was monitored
  33335. */
  33336. get lastSecAverage(): number;
  33337. /**
  33338. * Returns the current value
  33339. */
  33340. get current(): number;
  33341. /**
  33342. * Gets the accumulated total
  33343. */
  33344. get total(): number;
  33345. /**
  33346. * Gets the total value count
  33347. */
  33348. get count(): number;
  33349. /**
  33350. * Creates a new counter
  33351. */
  33352. constructor();
  33353. /**
  33354. * Call this method to start monitoring a new frame.
  33355. * 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.
  33356. */
  33357. fetchNewFrame(): void;
  33358. /**
  33359. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33360. * @param newCount the count value to add to the monitored count
  33361. * @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.
  33362. */
  33363. addCount(newCount: number, fetchResult: boolean): void;
  33364. /**
  33365. * Start monitoring this performance counter
  33366. */
  33367. beginMonitoring(): void;
  33368. /**
  33369. * Compute the time lapsed since the previous beginMonitoring() call.
  33370. * @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
  33371. */
  33372. endMonitoring(newFrame?: boolean): void;
  33373. private _fetchResult;
  33374. private _startMonitoringTime;
  33375. private _min;
  33376. private _max;
  33377. private _average;
  33378. private _current;
  33379. private _totalValueCount;
  33380. private _totalAccumulated;
  33381. private _lastSecAverage;
  33382. private _lastSecAccumulated;
  33383. private _lastSecTime;
  33384. private _lastSecValueCount;
  33385. }
  33386. }
  33387. declare module BABYLON {
  33388. interface ThinEngine {
  33389. /**
  33390. * Sets alpha constants used by some alpha blending modes
  33391. * @param r defines the red component
  33392. * @param g defines the green component
  33393. * @param b defines the blue component
  33394. * @param a defines the alpha component
  33395. */
  33396. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33397. /**
  33398. * Sets the current alpha mode
  33399. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33400. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33402. */
  33403. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33404. /**
  33405. * Gets the current alpha mode
  33406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33407. * @returns the current alpha mode
  33408. */
  33409. getAlphaMode(): number;
  33410. /**
  33411. * Sets the current alpha equation
  33412. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33413. */
  33414. setAlphaEquation(equation: number): void;
  33415. /**
  33416. * Gets the current alpha equation.
  33417. * @returns the current alpha equation
  33418. */
  33419. getAlphaEquation(): number;
  33420. }
  33421. }
  33422. declare module BABYLON {
  33423. /**
  33424. * Defines the interface used by display changed events
  33425. */
  33426. export interface IDisplayChangedEventArgs {
  33427. /** Gets the vrDisplay object (if any) */
  33428. vrDisplay: Nullable<any>;
  33429. /** Gets a boolean indicating if webVR is supported */
  33430. vrSupported: boolean;
  33431. }
  33432. /**
  33433. * Defines the interface used by objects containing a viewport (like a camera)
  33434. */
  33435. interface IViewportOwnerLike {
  33436. /**
  33437. * Gets or sets the viewport
  33438. */
  33439. viewport: IViewportLike;
  33440. }
  33441. /**
  33442. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33443. */
  33444. export class Engine extends ThinEngine {
  33445. /** Defines that alpha blending is disabled */
  33446. static readonly ALPHA_DISABLE: number;
  33447. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33448. static readonly ALPHA_ADD: number;
  33449. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33450. static readonly ALPHA_COMBINE: number;
  33451. /** Defines that alpha blending to DEST - SRC * DEST */
  33452. static readonly ALPHA_SUBTRACT: number;
  33453. /** Defines that alpha blending to SRC * DEST */
  33454. static readonly ALPHA_MULTIPLY: number;
  33455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33456. static readonly ALPHA_MAXIMIZED: number;
  33457. /** Defines that alpha blending to SRC + DEST */
  33458. static readonly ALPHA_ONEONE: number;
  33459. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33460. static readonly ALPHA_PREMULTIPLIED: number;
  33461. /**
  33462. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33463. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33464. */
  33465. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33466. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33467. static readonly ALPHA_INTERPOLATE: number;
  33468. /**
  33469. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33470. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33471. */
  33472. static readonly ALPHA_SCREENMODE: number;
  33473. /** Defines that the ressource is not delayed*/
  33474. static readonly DELAYLOADSTATE_NONE: number;
  33475. /** Defines that the ressource was successfully delay loaded */
  33476. static readonly DELAYLOADSTATE_LOADED: number;
  33477. /** Defines that the ressource is currently delay loading */
  33478. static readonly DELAYLOADSTATE_LOADING: number;
  33479. /** Defines that the ressource is delayed and has not started loading */
  33480. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33482. static readonly NEVER: number;
  33483. /** 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 */
  33484. static readonly ALWAYS: number;
  33485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33486. static readonly LESS: number;
  33487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33488. static readonly EQUAL: number;
  33489. /** 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 */
  33490. static readonly LEQUAL: number;
  33491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33492. static readonly GREATER: number;
  33493. /** 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 */
  33494. static readonly GEQUAL: number;
  33495. /** 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 */
  33496. static readonly NOTEQUAL: number;
  33497. /** Passed to stencilOperation to specify that stencil value must be kept */
  33498. static readonly KEEP: number;
  33499. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33500. static readonly REPLACE: number;
  33501. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33502. static readonly INCR: number;
  33503. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33504. static readonly DECR: number;
  33505. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33506. static readonly INVERT: number;
  33507. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33508. static readonly INCR_WRAP: number;
  33509. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33510. static readonly DECR_WRAP: number;
  33511. /** Texture is not repeating outside of 0..1 UVs */
  33512. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33513. /** Texture is repeating outside of 0..1 UVs */
  33514. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33515. /** Texture is repeating and mirrored */
  33516. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33517. /** ALPHA */
  33518. static readonly TEXTUREFORMAT_ALPHA: number;
  33519. /** LUMINANCE */
  33520. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33521. /** LUMINANCE_ALPHA */
  33522. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33523. /** RGB */
  33524. static readonly TEXTUREFORMAT_RGB: number;
  33525. /** RGBA */
  33526. static readonly TEXTUREFORMAT_RGBA: number;
  33527. /** RED */
  33528. static readonly TEXTUREFORMAT_RED: number;
  33529. /** RED (2nd reference) */
  33530. static readonly TEXTUREFORMAT_R: number;
  33531. /** RG */
  33532. static readonly TEXTUREFORMAT_RG: number;
  33533. /** RED_INTEGER */
  33534. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33535. /** RED_INTEGER (2nd reference) */
  33536. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33537. /** RG_INTEGER */
  33538. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33539. /** RGB_INTEGER */
  33540. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33541. /** RGBA_INTEGER */
  33542. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33543. /** UNSIGNED_BYTE */
  33544. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33545. /** UNSIGNED_BYTE (2nd reference) */
  33546. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33547. /** FLOAT */
  33548. static readonly TEXTURETYPE_FLOAT: number;
  33549. /** HALF_FLOAT */
  33550. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33551. /** BYTE */
  33552. static readonly TEXTURETYPE_BYTE: number;
  33553. /** SHORT */
  33554. static readonly TEXTURETYPE_SHORT: number;
  33555. /** UNSIGNED_SHORT */
  33556. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33557. /** INT */
  33558. static readonly TEXTURETYPE_INT: number;
  33559. /** UNSIGNED_INT */
  33560. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33561. /** UNSIGNED_SHORT_4_4_4_4 */
  33562. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33563. /** UNSIGNED_SHORT_5_5_5_1 */
  33564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33565. /** UNSIGNED_SHORT_5_6_5 */
  33566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33567. /** UNSIGNED_INT_2_10_10_10_REV */
  33568. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33569. /** UNSIGNED_INT_24_8 */
  33570. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33571. /** UNSIGNED_INT_10F_11F_11F_REV */
  33572. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33573. /** UNSIGNED_INT_5_9_9_9_REV */
  33574. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33575. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33576. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33577. /** nearest is mag = nearest and min = nearest and mip = linear */
  33578. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33580. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33581. /** Trilinear is mag = linear and min = linear and mip = linear */
  33582. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33583. /** nearest is mag = nearest and min = nearest and mip = linear */
  33584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33586. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33587. /** Trilinear is mag = linear and min = linear and mip = linear */
  33588. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33589. /** mag = nearest and min = nearest and mip = nearest */
  33590. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33591. /** mag = nearest and min = linear and mip = nearest */
  33592. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33593. /** mag = nearest and min = linear and mip = linear */
  33594. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33595. /** mag = nearest and min = linear and mip = none */
  33596. static readonly TEXTURE_NEAREST_LINEAR: number;
  33597. /** mag = nearest and min = nearest and mip = none */
  33598. static readonly TEXTURE_NEAREST_NEAREST: number;
  33599. /** mag = linear and min = nearest and mip = nearest */
  33600. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33601. /** mag = linear and min = nearest and mip = linear */
  33602. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33603. /** mag = linear and min = linear and mip = none */
  33604. static readonly TEXTURE_LINEAR_LINEAR: number;
  33605. /** mag = linear and min = nearest and mip = none */
  33606. static readonly TEXTURE_LINEAR_NEAREST: number;
  33607. /** Explicit coordinates mode */
  33608. static readonly TEXTURE_EXPLICIT_MODE: number;
  33609. /** Spherical coordinates mode */
  33610. static readonly TEXTURE_SPHERICAL_MODE: number;
  33611. /** Planar coordinates mode */
  33612. static readonly TEXTURE_PLANAR_MODE: number;
  33613. /** Cubic coordinates mode */
  33614. static readonly TEXTURE_CUBIC_MODE: number;
  33615. /** Projection coordinates mode */
  33616. static readonly TEXTURE_PROJECTION_MODE: number;
  33617. /** Skybox coordinates mode */
  33618. static readonly TEXTURE_SKYBOX_MODE: number;
  33619. /** Inverse Cubic coordinates mode */
  33620. static readonly TEXTURE_INVCUBIC_MODE: number;
  33621. /** Equirectangular coordinates mode */
  33622. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33623. /** Equirectangular Fixed coordinates mode */
  33624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33625. /** Equirectangular Fixed Mirrored coordinates mode */
  33626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33627. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33628. static readonly SCALEMODE_FLOOR: number;
  33629. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33630. static readonly SCALEMODE_NEAREST: number;
  33631. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33632. static readonly SCALEMODE_CEILING: number;
  33633. /**
  33634. * Returns the current npm package of the sdk
  33635. */
  33636. static get NpmPackage(): string;
  33637. /**
  33638. * Returns the current version of the framework
  33639. */
  33640. static get Version(): string;
  33641. /** Gets the list of created engines */
  33642. static get Instances(): Engine[];
  33643. /**
  33644. * Gets the latest created engine
  33645. */
  33646. static get LastCreatedEngine(): Nullable<Engine>;
  33647. /**
  33648. * Gets the latest created scene
  33649. */
  33650. static get LastCreatedScene(): Nullable<Scene>;
  33651. /**
  33652. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33653. * @param flag defines which part of the materials must be marked as dirty
  33654. * @param predicate defines a predicate used to filter which materials should be affected
  33655. */
  33656. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33657. /**
  33658. * Method called to create the default loading screen.
  33659. * This can be overriden in your own app.
  33660. * @param canvas The rendering canvas element
  33661. * @returns The loading screen
  33662. */
  33663. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33664. /**
  33665. * Method called to create the default rescale post process on each engine.
  33666. */
  33667. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33668. /**
  33669. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33670. **/
  33671. enableOfflineSupport: boolean;
  33672. /**
  33673. * 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)
  33674. **/
  33675. disableManifestCheck: boolean;
  33676. /**
  33677. * Gets the list of created scenes
  33678. */
  33679. scenes: Scene[];
  33680. /**
  33681. * Event raised when a new scene is created
  33682. */
  33683. onNewSceneAddedObservable: Observable<Scene>;
  33684. /**
  33685. * Gets the list of created postprocesses
  33686. */
  33687. postProcesses: PostProcess[];
  33688. /**
  33689. * Gets a boolean indicating if the pointer is currently locked
  33690. */
  33691. isPointerLock: boolean;
  33692. /**
  33693. * Observable event triggered each time the rendering canvas is resized
  33694. */
  33695. onResizeObservable: Observable<Engine>;
  33696. /**
  33697. * Observable event triggered each time the canvas loses focus
  33698. */
  33699. onCanvasBlurObservable: Observable<Engine>;
  33700. /**
  33701. * Observable event triggered each time the canvas gains focus
  33702. */
  33703. onCanvasFocusObservable: Observable<Engine>;
  33704. /**
  33705. * Observable event triggered each time the canvas receives pointerout event
  33706. */
  33707. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33708. /**
  33709. * Observable raised when the engine begins a new frame
  33710. */
  33711. onBeginFrameObservable: Observable<Engine>;
  33712. /**
  33713. * If set, will be used to request the next animation frame for the render loop
  33714. */
  33715. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33716. /**
  33717. * Observable raised when the engine ends the current frame
  33718. */
  33719. onEndFrameObservable: Observable<Engine>;
  33720. /**
  33721. * Observable raised when the engine is about to compile a shader
  33722. */
  33723. onBeforeShaderCompilationObservable: Observable<Engine>;
  33724. /**
  33725. * Observable raised when the engine has jsut compiled a shader
  33726. */
  33727. onAfterShaderCompilationObservable: Observable<Engine>;
  33728. /**
  33729. * Gets the audio engine
  33730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33731. * @ignorenaming
  33732. */
  33733. static audioEngine: IAudioEngine;
  33734. /**
  33735. * Default AudioEngine factory responsible of creating the Audio Engine.
  33736. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33737. */
  33738. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33739. /**
  33740. * Default offline support factory responsible of creating a tool used to store data locally.
  33741. * By default, this will create a Database object if the workload has been embedded.
  33742. */
  33743. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33744. private _loadingScreen;
  33745. private _pointerLockRequested;
  33746. private _dummyFramebuffer;
  33747. private _rescalePostProcess;
  33748. private _deterministicLockstep;
  33749. private _lockstepMaxSteps;
  33750. private _timeStep;
  33751. protected get _supportsHardwareTextureRescaling(): boolean;
  33752. private _fps;
  33753. private _deltaTime;
  33754. /** @hidden */
  33755. _drawCalls: PerfCounter;
  33756. /** 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 */
  33757. canvasTabIndex: number;
  33758. /**
  33759. * Turn this value on if you want to pause FPS computation when in background
  33760. */
  33761. disablePerformanceMonitorInBackground: boolean;
  33762. private _performanceMonitor;
  33763. /**
  33764. * Gets the performance monitor attached to this engine
  33765. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33766. */
  33767. get performanceMonitor(): PerformanceMonitor;
  33768. private _onFocus;
  33769. private _onBlur;
  33770. private _onCanvasPointerOut;
  33771. private _onCanvasBlur;
  33772. private _onCanvasFocus;
  33773. private _onFullscreenChange;
  33774. private _onPointerLockChange;
  33775. /**
  33776. * Gets the HTML element used to attach event listeners
  33777. * @returns a HTML element
  33778. */
  33779. getInputElement(): Nullable<HTMLElement>;
  33780. /**
  33781. * Creates a new engine
  33782. * @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
  33783. * @param antialias defines enable antialiasing (default: false)
  33784. * @param options defines further options to be sent to the getContext() function
  33785. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33786. */
  33787. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33788. /**
  33789. * Gets current aspect ratio
  33790. * @param viewportOwner defines the camera to use to get the aspect ratio
  33791. * @param useScreen defines if screen size must be used (or the current render target if any)
  33792. * @returns a number defining the aspect ratio
  33793. */
  33794. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33795. /**
  33796. * Gets current screen aspect ratio
  33797. * @returns a number defining the aspect ratio
  33798. */
  33799. getScreenAspectRatio(): number;
  33800. /**
  33801. * Gets the client rect of the HTML canvas attached with the current webGL context
  33802. * @returns a client rectanglee
  33803. */
  33804. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33805. /**
  33806. * Gets the client rect of the HTML element used for events
  33807. * @returns a client rectanglee
  33808. */
  33809. getInputElementClientRect(): Nullable<ClientRect>;
  33810. /**
  33811. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33813. * @returns true if engine is in deterministic lock step mode
  33814. */
  33815. isDeterministicLockStep(): boolean;
  33816. /**
  33817. * Gets the max steps when engine is running in deterministic lock step
  33818. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33819. * @returns the max steps
  33820. */
  33821. getLockstepMaxSteps(): number;
  33822. /**
  33823. * Returns the time in ms between steps when using deterministic lock step.
  33824. * @returns time step in (ms)
  33825. */
  33826. getTimeStep(): number;
  33827. /**
  33828. * Force the mipmap generation for the given render target texture
  33829. * @param texture defines the render target texture to use
  33830. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33831. */
  33832. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33833. /** States */
  33834. /**
  33835. * Set various states to the webGL context
  33836. * @param culling defines backface culling state
  33837. * @param zOffset defines the value to apply to zOffset (0 by default)
  33838. * @param force defines if states must be applied even if cache is up to date
  33839. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33840. */
  33841. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33842. /**
  33843. * Set the z offset to apply to current rendering
  33844. * @param value defines the offset to apply
  33845. */
  33846. setZOffset(value: number): void;
  33847. /**
  33848. * Gets the current value of the zOffset
  33849. * @returns the current zOffset state
  33850. */
  33851. getZOffset(): number;
  33852. /**
  33853. * Enable or disable depth buffering
  33854. * @param enable defines the state to set
  33855. */
  33856. setDepthBuffer(enable: boolean): void;
  33857. /**
  33858. * Gets a boolean indicating if depth writing is enabled
  33859. * @returns the current depth writing state
  33860. */
  33861. getDepthWrite(): boolean;
  33862. /**
  33863. * Enable or disable depth writing
  33864. * @param enable defines the state to set
  33865. */
  33866. setDepthWrite(enable: boolean): void;
  33867. /**
  33868. * Gets a boolean indicating if stencil buffer is enabled
  33869. * @returns the current stencil buffer state
  33870. */
  33871. getStencilBuffer(): boolean;
  33872. /**
  33873. * Enable or disable the stencil buffer
  33874. * @param enable defines if the stencil buffer must be enabled or disabled
  33875. */
  33876. setStencilBuffer(enable: boolean): void;
  33877. /**
  33878. * Gets the current stencil mask
  33879. * @returns a number defining the new stencil mask to use
  33880. */
  33881. getStencilMask(): number;
  33882. /**
  33883. * Sets the current stencil mask
  33884. * @param mask defines the new stencil mask to use
  33885. */
  33886. setStencilMask(mask: number): void;
  33887. /**
  33888. * Gets the current stencil function
  33889. * @returns a number defining the stencil function to use
  33890. */
  33891. getStencilFunction(): number;
  33892. /**
  33893. * Gets the current stencil reference value
  33894. * @returns a number defining the stencil reference value to use
  33895. */
  33896. getStencilFunctionReference(): number;
  33897. /**
  33898. * Gets the current stencil mask
  33899. * @returns a number defining the stencil mask to use
  33900. */
  33901. getStencilFunctionMask(): number;
  33902. /**
  33903. * Sets the current stencil function
  33904. * @param stencilFunc defines the new stencil function to use
  33905. */
  33906. setStencilFunction(stencilFunc: number): void;
  33907. /**
  33908. * Sets the current stencil reference
  33909. * @param reference defines the new stencil reference to use
  33910. */
  33911. setStencilFunctionReference(reference: number): void;
  33912. /**
  33913. * Sets the current stencil mask
  33914. * @param mask defines the new stencil mask to use
  33915. */
  33916. setStencilFunctionMask(mask: number): void;
  33917. /**
  33918. * Gets the current stencil operation when stencil fails
  33919. * @returns a number defining stencil operation to use when stencil fails
  33920. */
  33921. getStencilOperationFail(): number;
  33922. /**
  33923. * Gets the current stencil operation when depth fails
  33924. * @returns a number defining stencil operation to use when depth fails
  33925. */
  33926. getStencilOperationDepthFail(): number;
  33927. /**
  33928. * Gets the current stencil operation when stencil passes
  33929. * @returns a number defining stencil operation to use when stencil passes
  33930. */
  33931. getStencilOperationPass(): number;
  33932. /**
  33933. * Sets the stencil operation to use when stencil fails
  33934. * @param operation defines the stencil operation to use when stencil fails
  33935. */
  33936. setStencilOperationFail(operation: number): void;
  33937. /**
  33938. * Sets the stencil operation to use when depth fails
  33939. * @param operation defines the stencil operation to use when depth fails
  33940. */
  33941. setStencilOperationDepthFail(operation: number): void;
  33942. /**
  33943. * Sets the stencil operation to use when stencil passes
  33944. * @param operation defines the stencil operation to use when stencil passes
  33945. */
  33946. setStencilOperationPass(operation: number): void;
  33947. /**
  33948. * Sets a boolean indicating if the dithering state is enabled or disabled
  33949. * @param value defines the dithering state
  33950. */
  33951. setDitheringState(value: boolean): void;
  33952. /**
  33953. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33954. * @param value defines the rasterizer state
  33955. */
  33956. setRasterizerState(value: boolean): void;
  33957. /**
  33958. * Gets the current depth function
  33959. * @returns a number defining the depth function
  33960. */
  33961. getDepthFunction(): Nullable<number>;
  33962. /**
  33963. * Sets the current depth function
  33964. * @param depthFunc defines the function to use
  33965. */
  33966. setDepthFunction(depthFunc: number): void;
  33967. /**
  33968. * Sets the current depth function to GREATER
  33969. */
  33970. setDepthFunctionToGreater(): void;
  33971. /**
  33972. * Sets the current depth function to GEQUAL
  33973. */
  33974. setDepthFunctionToGreaterOrEqual(): void;
  33975. /**
  33976. * Sets the current depth function to LESS
  33977. */
  33978. setDepthFunctionToLess(): void;
  33979. /**
  33980. * Sets the current depth function to LEQUAL
  33981. */
  33982. setDepthFunctionToLessOrEqual(): void;
  33983. private _cachedStencilBuffer;
  33984. private _cachedStencilFunction;
  33985. private _cachedStencilMask;
  33986. private _cachedStencilOperationPass;
  33987. private _cachedStencilOperationFail;
  33988. private _cachedStencilOperationDepthFail;
  33989. private _cachedStencilReference;
  33990. /**
  33991. * Caches the the state of the stencil buffer
  33992. */
  33993. cacheStencilState(): void;
  33994. /**
  33995. * Restores the state of the stencil buffer
  33996. */
  33997. restoreStencilState(): void;
  33998. /**
  33999. * Directly set the WebGL Viewport
  34000. * @param x defines the x coordinate of the viewport (in screen space)
  34001. * @param y defines the y coordinate of the viewport (in screen space)
  34002. * @param width defines the width of the viewport (in screen space)
  34003. * @param height defines the height of the viewport (in screen space)
  34004. * @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
  34005. */
  34006. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34007. /**
  34008. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34009. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34010. * @param y defines the y-coordinate of the corner of the clear rectangle
  34011. * @param width defines the width of the clear rectangle
  34012. * @param height defines the height of the clear rectangle
  34013. * @param clearColor defines the clear color
  34014. */
  34015. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34016. /**
  34017. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34018. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34019. * @param y defines the y-coordinate of the corner of the clear rectangle
  34020. * @param width defines the width of the clear rectangle
  34021. * @param height defines the height of the clear rectangle
  34022. */
  34023. enableScissor(x: number, y: number, width: number, height: number): void;
  34024. /**
  34025. * Disable previously set scissor test rectangle
  34026. */
  34027. disableScissor(): void;
  34028. protected _reportDrawCall(): void;
  34029. /**
  34030. * Initializes a webVR display and starts listening to display change events
  34031. * The onVRDisplayChangedObservable will be notified upon these changes
  34032. * @returns The onVRDisplayChangedObservable
  34033. */
  34034. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34035. /** @hidden */
  34036. _prepareVRComponent(): void;
  34037. /** @hidden */
  34038. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34039. /** @hidden */
  34040. _submitVRFrame(): void;
  34041. /**
  34042. * Call this function to leave webVR mode
  34043. * Will do nothing if webVR is not supported or if there is no webVR device
  34044. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34045. */
  34046. disableVR(): void;
  34047. /**
  34048. * Gets a boolean indicating that the system is in VR mode and is presenting
  34049. * @returns true if VR mode is engaged
  34050. */
  34051. isVRPresenting(): boolean;
  34052. /** @hidden */
  34053. _requestVRFrame(): void;
  34054. /** @hidden */
  34055. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34056. /**
  34057. * Gets the source code of the vertex shader associated with a specific webGL program
  34058. * @param program defines the program to use
  34059. * @returns a string containing the source code of the vertex shader associated with the program
  34060. */
  34061. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34062. /**
  34063. * Gets the source code of the fragment shader associated with a specific webGL program
  34064. * @param program defines the program to use
  34065. * @returns a string containing the source code of the fragment shader associated with the program
  34066. */
  34067. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34068. /**
  34069. * Sets a depth stencil texture from a render target to the according uniform.
  34070. * @param channel The texture channel
  34071. * @param uniform The uniform to set
  34072. * @param texture The render target texture containing the depth stencil texture to apply
  34073. */
  34074. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34075. /**
  34076. * Sets a texture to the webGL context from a postprocess
  34077. * @param channel defines the channel to use
  34078. * @param postProcess defines the source postprocess
  34079. */
  34080. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34081. /**
  34082. * Binds the output of the passed in post process to the texture channel specified
  34083. * @param channel The channel the texture should be bound to
  34084. * @param postProcess The post process which's output should be bound
  34085. */
  34086. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34087. /** @hidden */
  34088. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34089. protected _rebuildBuffers(): void;
  34090. /** @hidden */
  34091. _renderFrame(): void;
  34092. _renderLoop(): void;
  34093. /** @hidden */
  34094. _renderViews(): boolean;
  34095. /**
  34096. * Toggle full screen mode
  34097. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34098. */
  34099. switchFullscreen(requestPointerLock: boolean): void;
  34100. /**
  34101. * Enters full screen mode
  34102. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34103. */
  34104. enterFullscreen(requestPointerLock: boolean): void;
  34105. /**
  34106. * Exits full screen mode
  34107. */
  34108. exitFullscreen(): void;
  34109. /**
  34110. * Enters Pointerlock mode
  34111. */
  34112. enterPointerlock(): void;
  34113. /**
  34114. * Exits Pointerlock mode
  34115. */
  34116. exitPointerlock(): void;
  34117. /**
  34118. * Begin a new frame
  34119. */
  34120. beginFrame(): void;
  34121. /**
  34122. * Enf the current frame
  34123. */
  34124. endFrame(): void;
  34125. resize(): void;
  34126. /**
  34127. * Force a specific size of the canvas
  34128. * @param width defines the new canvas' width
  34129. * @param height defines the new canvas' height
  34130. */
  34131. setSize(width: number, height: number): void;
  34132. /**
  34133. * Updates a dynamic vertex buffer.
  34134. * @param vertexBuffer the vertex buffer to update
  34135. * @param data the data used to update the vertex buffer
  34136. * @param byteOffset the byte offset of the data
  34137. * @param byteLength the byte length of the data
  34138. */
  34139. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34140. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34141. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34142. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34143. _releaseTexture(texture: InternalTexture): void;
  34144. /**
  34145. * @hidden
  34146. * Rescales a texture
  34147. * @param source input texutre
  34148. * @param destination destination texture
  34149. * @param scene scene to use to render the resize
  34150. * @param internalFormat format to use when resizing
  34151. * @param onComplete callback to be called when resize has completed
  34152. */
  34153. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34154. /**
  34155. * Gets the current framerate
  34156. * @returns a number representing the framerate
  34157. */
  34158. getFps(): number;
  34159. /**
  34160. * Gets the time spent between current and previous frame
  34161. * @returns a number representing the delta time in ms
  34162. */
  34163. getDeltaTime(): number;
  34164. private _measureFps;
  34165. /** @hidden */
  34166. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34167. /**
  34168. * Update a dynamic index buffer
  34169. * @param indexBuffer defines the target index buffer
  34170. * @param indices defines the data to update
  34171. * @param offset defines the offset in the target index buffer where update should start
  34172. */
  34173. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34174. /**
  34175. * Updates the sample count of a render target texture
  34176. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34177. * @param texture defines the texture to update
  34178. * @param samples defines the sample count to set
  34179. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34180. */
  34181. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34182. /**
  34183. * Updates a depth texture Comparison Mode and Function.
  34184. * If the comparison Function is equal to 0, the mode will be set to none.
  34185. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34186. * @param texture The texture to set the comparison function for
  34187. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34188. */
  34189. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34190. /**
  34191. * Creates a webGL buffer to use with instanciation
  34192. * @param capacity defines the size of the buffer
  34193. * @returns the webGL buffer
  34194. */
  34195. createInstancesBuffer(capacity: number): DataBuffer;
  34196. /**
  34197. * Delete a webGL buffer used with instanciation
  34198. * @param buffer defines the webGL buffer to delete
  34199. */
  34200. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34201. private _clientWaitAsync;
  34202. /** @hidden */
  34203. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34204. /** @hidden */
  34205. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34206. dispose(): void;
  34207. private _disableTouchAction;
  34208. /**
  34209. * Display the loading screen
  34210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34211. */
  34212. displayLoadingUI(): void;
  34213. /**
  34214. * Hide the loading screen
  34215. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34216. */
  34217. hideLoadingUI(): void;
  34218. /**
  34219. * Gets the current loading screen object
  34220. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34221. */
  34222. get loadingScreen(): ILoadingScreen;
  34223. /**
  34224. * Sets the current loading screen object
  34225. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34226. */
  34227. set loadingScreen(loadingScreen: ILoadingScreen);
  34228. /**
  34229. * Sets the current loading screen text
  34230. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34231. */
  34232. set loadingUIText(text: string);
  34233. /**
  34234. * Sets the current loading screen background color
  34235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34236. */
  34237. set loadingUIBackgroundColor(color: string);
  34238. /** Pointerlock and fullscreen */
  34239. /**
  34240. * Ask the browser to promote the current element to pointerlock mode
  34241. * @param element defines the DOM element to promote
  34242. */
  34243. static _RequestPointerlock(element: HTMLElement): void;
  34244. /**
  34245. * Asks the browser to exit pointerlock mode
  34246. */
  34247. static _ExitPointerlock(): void;
  34248. /**
  34249. * Ask the browser to promote the current element to fullscreen rendering mode
  34250. * @param element defines the DOM element to promote
  34251. */
  34252. static _RequestFullscreen(element: HTMLElement): void;
  34253. /**
  34254. * Asks the browser to exit fullscreen mode
  34255. */
  34256. static _ExitFullscreen(): void;
  34257. }
  34258. }
  34259. declare module BABYLON {
  34260. /**
  34261. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34262. * during the life time of the application.
  34263. */
  34264. export class EngineStore {
  34265. /** Gets the list of created engines */
  34266. static Instances: Engine[];
  34267. /** @hidden */
  34268. static _LastCreatedScene: Nullable<Scene>;
  34269. /**
  34270. * Gets the latest created engine
  34271. */
  34272. static get LastCreatedEngine(): Nullable<Engine>;
  34273. /**
  34274. * Gets the latest created scene
  34275. */
  34276. static get LastCreatedScene(): Nullable<Scene>;
  34277. /**
  34278. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34279. * @ignorenaming
  34280. */
  34281. static UseFallbackTexture: boolean;
  34282. /**
  34283. * Texture content used if a texture cannot loaded
  34284. * @ignorenaming
  34285. */
  34286. static FallbackTexture: string;
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * Helper class that provides a small promise polyfill
  34292. */
  34293. export class PromisePolyfill {
  34294. /**
  34295. * Static function used to check if the polyfill is required
  34296. * If this is the case then the function will inject the polyfill to window.Promise
  34297. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34298. */
  34299. static Apply(force?: boolean): void;
  34300. }
  34301. }
  34302. declare module BABYLON {
  34303. /**
  34304. * Interface for screenshot methods with describe argument called `size` as object with options
  34305. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34306. */
  34307. export interface IScreenshotSize {
  34308. /**
  34309. * number in pixels for canvas height
  34310. */
  34311. height?: number;
  34312. /**
  34313. * multiplier allowing render at a higher or lower resolution
  34314. * If value is defined then height and width will be ignored and taken from camera
  34315. */
  34316. precision?: number;
  34317. /**
  34318. * number in pixels for canvas width
  34319. */
  34320. width?: number;
  34321. }
  34322. }
  34323. declare module BABYLON {
  34324. interface IColor4Like {
  34325. r: float;
  34326. g: float;
  34327. b: float;
  34328. a: float;
  34329. }
  34330. /**
  34331. * Class containing a set of static utilities functions
  34332. */
  34333. export class Tools {
  34334. /**
  34335. * Gets or sets the base URL to use to load assets
  34336. */
  34337. static get BaseUrl(): string;
  34338. static set BaseUrl(value: string);
  34339. /**
  34340. * Enable/Disable Custom HTTP Request Headers globally.
  34341. * default = false
  34342. * @see CustomRequestHeaders
  34343. */
  34344. static UseCustomRequestHeaders: boolean;
  34345. /**
  34346. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34347. * i.e. when loading files, where the server/service expects an Authorization header
  34348. */
  34349. static CustomRequestHeaders: {
  34350. [key: string]: string;
  34351. };
  34352. /**
  34353. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34354. */
  34355. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34356. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34357. /**
  34358. * Default behaviour for cors in the application.
  34359. * It can be a string if the expected behavior is identical in the entire app.
  34360. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34361. */
  34362. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34363. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34364. /**
  34365. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34366. * @ignorenaming
  34367. */
  34368. static get UseFallbackTexture(): boolean;
  34369. static set UseFallbackTexture(value: boolean);
  34370. /**
  34371. * Use this object to register external classes like custom textures or material
  34372. * to allow the laoders to instantiate them
  34373. */
  34374. static get RegisteredExternalClasses(): {
  34375. [key: string]: Object;
  34376. };
  34377. static set RegisteredExternalClasses(classes: {
  34378. [key: string]: Object;
  34379. });
  34380. /**
  34381. * Texture content used if a texture cannot loaded
  34382. * @ignorenaming
  34383. */
  34384. static get fallbackTexture(): string;
  34385. static set fallbackTexture(value: string);
  34386. /**
  34387. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34388. * @param u defines the coordinate on X axis
  34389. * @param v defines the coordinate on Y axis
  34390. * @param width defines the width of the source data
  34391. * @param height defines the height of the source data
  34392. * @param pixels defines the source byte array
  34393. * @param color defines the output color
  34394. */
  34395. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34396. /**
  34397. * Interpolates between a and b via alpha
  34398. * @param a The lower value (returned when alpha = 0)
  34399. * @param b The upper value (returned when alpha = 1)
  34400. * @param alpha The interpolation-factor
  34401. * @return The mixed value
  34402. */
  34403. static Mix(a: number, b: number, alpha: number): number;
  34404. /**
  34405. * Tries to instantiate a new object from a given class name
  34406. * @param className defines the class name to instantiate
  34407. * @returns the new object or null if the system was not able to do the instantiation
  34408. */
  34409. static Instantiate(className: string): any;
  34410. /**
  34411. * Provides a slice function that will work even on IE
  34412. * @param data defines the array to slice
  34413. * @param start defines the start of the data (optional)
  34414. * @param end defines the end of the data (optional)
  34415. * @returns the new sliced array
  34416. */
  34417. static Slice<T>(data: T, start?: number, end?: number): T;
  34418. /**
  34419. * Polyfill for setImmediate
  34420. * @param action defines the action to execute after the current execution block
  34421. */
  34422. static SetImmediate(action: () => void): void;
  34423. /**
  34424. * Function indicating if a number is an exponent of 2
  34425. * @param value defines the value to test
  34426. * @returns true if the value is an exponent of 2
  34427. */
  34428. static IsExponentOfTwo(value: number): boolean;
  34429. private static _tmpFloatArray;
  34430. /**
  34431. * Returns the nearest 32-bit single precision float representation of a Number
  34432. * @param value A Number. If the parameter is of a different type, it will get converted
  34433. * to a number or to NaN if it cannot be converted
  34434. * @returns number
  34435. */
  34436. static FloatRound(value: number): number;
  34437. /**
  34438. * Extracts the filename from a path
  34439. * @param path defines the path to use
  34440. * @returns the filename
  34441. */
  34442. static GetFilename(path: string): string;
  34443. /**
  34444. * Extracts the "folder" part of a path (everything before the filename).
  34445. * @param uri The URI to extract the info from
  34446. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34447. * @returns The "folder" part of the path
  34448. */
  34449. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34450. /**
  34451. * Extracts text content from a DOM element hierarchy
  34452. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34453. */
  34454. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34455. /**
  34456. * Convert an angle in radians to degrees
  34457. * @param angle defines the angle to convert
  34458. * @returns the angle in degrees
  34459. */
  34460. static ToDegrees(angle: number): number;
  34461. /**
  34462. * Convert an angle in degrees to radians
  34463. * @param angle defines the angle to convert
  34464. * @returns the angle in radians
  34465. */
  34466. static ToRadians(angle: number): number;
  34467. /**
  34468. * Returns an array if obj is not an array
  34469. * @param obj defines the object to evaluate as an array
  34470. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34471. * @returns either obj directly if obj is an array or a new array containing obj
  34472. */
  34473. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34474. /**
  34475. * Gets the pointer prefix to use
  34476. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34477. */
  34478. static GetPointerPrefix(): string;
  34479. /**
  34480. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34481. * @param url define the url we are trying
  34482. * @param element define the dom element where to configure the cors policy
  34483. */
  34484. static SetCorsBehavior(url: string | string[], element: {
  34485. crossOrigin: string | null;
  34486. }): void;
  34487. /**
  34488. * Removes unwanted characters from an url
  34489. * @param url defines the url to clean
  34490. * @returns the cleaned url
  34491. */
  34492. static CleanUrl(url: string): string;
  34493. /**
  34494. * Gets or sets a function used to pre-process url before using them to load assets
  34495. */
  34496. static get PreprocessUrl(): (url: string) => string;
  34497. static set PreprocessUrl(processor: (url: string) => string);
  34498. /**
  34499. * Loads an image as an HTMLImageElement.
  34500. * @param input url string, ArrayBuffer, or Blob to load
  34501. * @param onLoad callback called when the image successfully loads
  34502. * @param onError callback called when the image fails to load
  34503. * @param offlineProvider offline provider for caching
  34504. * @param mimeType optional mime type
  34505. * @returns the HTMLImageElement of the loaded image
  34506. */
  34507. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34508. /**
  34509. * Loads a file from a url
  34510. * @param url url string, ArrayBuffer, or Blob to load
  34511. * @param onSuccess callback called when the file successfully loads
  34512. * @param onProgress callback called while file is loading (if the server supports this mode)
  34513. * @param offlineProvider defines the offline provider for caching
  34514. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34515. * @param onError callback called when the file fails to load
  34516. * @returns a file request object
  34517. */
  34518. 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;
  34519. /**
  34520. * Loads a file from a url
  34521. * @param url the file url to load
  34522. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34523. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34524. */
  34525. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34526. /**
  34527. * Load a script (identified by an url). When the url returns, the
  34528. * content of this file is added into a new script element, attached to the DOM (body element)
  34529. * @param scriptUrl defines the url of the script to laod
  34530. * @param onSuccess defines the callback called when the script is loaded
  34531. * @param onError defines the callback to call if an error occurs
  34532. * @param scriptId defines the id of the script element
  34533. */
  34534. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34535. /**
  34536. * Load an asynchronous script (identified by an url). When the url returns, the
  34537. * content of this file is added into a new script element, attached to the DOM (body element)
  34538. * @param scriptUrl defines the url of the script to laod
  34539. * @param scriptId defines the id of the script element
  34540. * @returns a promise request object
  34541. */
  34542. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34543. /**
  34544. * Loads a file from a blob
  34545. * @param fileToLoad defines the blob to use
  34546. * @param callback defines the callback to call when data is loaded
  34547. * @param progressCallback defines the callback to call during loading process
  34548. * @returns a file request object
  34549. */
  34550. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34551. /**
  34552. * Reads a file from a File object
  34553. * @param file defines the file to load
  34554. * @param onSuccess defines the callback to call when data is loaded
  34555. * @param onProgress defines the callback to call during loading process
  34556. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34557. * @param onError defines the callback to call when an error occurs
  34558. * @returns a file request object
  34559. */
  34560. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34561. /**
  34562. * Creates a data url from a given string content
  34563. * @param content defines the content to convert
  34564. * @returns the new data url link
  34565. */
  34566. static FileAsURL(content: string): string;
  34567. /**
  34568. * Format the given number to a specific decimal format
  34569. * @param value defines the number to format
  34570. * @param decimals defines the number of decimals to use
  34571. * @returns the formatted string
  34572. */
  34573. static Format(value: number, decimals?: number): string;
  34574. /**
  34575. * Tries to copy an object by duplicating every property
  34576. * @param source defines the source object
  34577. * @param destination defines the target object
  34578. * @param doNotCopyList defines a list of properties to avoid
  34579. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34580. */
  34581. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34582. /**
  34583. * Gets a boolean indicating if the given object has no own property
  34584. * @param obj defines the object to test
  34585. * @returns true if object has no own property
  34586. */
  34587. static IsEmpty(obj: any): boolean;
  34588. /**
  34589. * Function used to register events at window level
  34590. * @param windowElement defines the Window object to use
  34591. * @param events defines the events to register
  34592. */
  34593. static RegisterTopRootEvents(windowElement: Window, events: {
  34594. name: string;
  34595. handler: Nullable<(e: FocusEvent) => any>;
  34596. }[]): void;
  34597. /**
  34598. * Function used to unregister events from window level
  34599. * @param windowElement defines the Window object to use
  34600. * @param events defines the events to unregister
  34601. */
  34602. static UnregisterTopRootEvents(windowElement: Window, events: {
  34603. name: string;
  34604. handler: Nullable<(e: FocusEvent) => any>;
  34605. }[]): void;
  34606. /**
  34607. * @ignore
  34608. */
  34609. static _ScreenshotCanvas: HTMLCanvasElement;
  34610. /**
  34611. * Dumps the current bound framebuffer
  34612. * @param width defines the rendering width
  34613. * @param height defines the rendering height
  34614. * @param engine defines the hosting engine
  34615. * @param successCallback defines the callback triggered once the data are available
  34616. * @param mimeType defines the mime type of the result
  34617. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34618. */
  34619. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34620. /**
  34621. * Converts the canvas data to blob.
  34622. * This acts as a polyfill for browsers not supporting the to blob function.
  34623. * @param canvas Defines the canvas to extract the data from
  34624. * @param successCallback Defines the callback triggered once the data are available
  34625. * @param mimeType Defines the mime type of the result
  34626. */
  34627. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34628. /**
  34629. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34630. * @param successCallback defines the callback triggered once the data are available
  34631. * @param mimeType defines the mime type of the result
  34632. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34633. */
  34634. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34635. /**
  34636. * Downloads a blob in the browser
  34637. * @param blob defines the blob to download
  34638. * @param fileName defines the name of the downloaded file
  34639. */
  34640. static Download(blob: Blob, fileName: string): void;
  34641. /**
  34642. * Captures a screenshot of the current rendering
  34643. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34644. * @param engine defines the rendering engine
  34645. * @param camera defines the source camera
  34646. * @param size This parameter can be set to a single number or to an object with the
  34647. * following (optional) properties: precision, width, height. If a single number is passed,
  34648. * it will be used for both width and height. If an object is passed, the screenshot size
  34649. * will be derived from the parameters. The precision property is a multiplier allowing
  34650. * rendering at a higher or lower resolution
  34651. * @param successCallback defines the callback receives a single parameter which contains the
  34652. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34653. * src parameter of an <img> to display it
  34654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34655. * Check your browser for supported MIME types
  34656. */
  34657. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34658. /**
  34659. * Captures a screenshot of the current rendering
  34660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34661. * @param engine defines the rendering engine
  34662. * @param camera defines the source camera
  34663. * @param size This parameter can be set to a single number or to an object with the
  34664. * following (optional) properties: precision, width, height. If a single number is passed,
  34665. * it will be used for both width and height. If an object is passed, the screenshot size
  34666. * will be derived from the parameters. The precision property is a multiplier allowing
  34667. * rendering at a higher or lower resolution
  34668. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34669. * Check your browser for supported MIME types
  34670. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34671. * to the src parameter of an <img> to display it
  34672. */
  34673. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34674. /**
  34675. * Generates an image screenshot from the specified camera.
  34676. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34677. * @param engine The engine to use for rendering
  34678. * @param camera The camera to use for rendering
  34679. * @param size This parameter can be set to a single number or to an object with the
  34680. * following (optional) properties: precision, width, height. If a single number is passed,
  34681. * it will be used for both width and height. If an object is passed, the screenshot size
  34682. * will be derived from the parameters. The precision property is a multiplier allowing
  34683. * rendering at a higher or lower resolution
  34684. * @param successCallback The callback receives a single parameter which contains the
  34685. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34686. * src parameter of an <img> to display it
  34687. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34688. * Check your browser for supported MIME types
  34689. * @param samples Texture samples (default: 1)
  34690. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34691. * @param fileName A name for for the downloaded file.
  34692. */
  34693. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34694. /**
  34695. * Generates an image screenshot from the specified camera.
  34696. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34697. * @param engine The engine to use for rendering
  34698. * @param camera The camera to use for rendering
  34699. * @param size This parameter can be set to a single number or to an object with the
  34700. * following (optional) properties: precision, width, height. If a single number is passed,
  34701. * it will be used for both width and height. If an object is passed, the screenshot size
  34702. * will be derived from the parameters. The precision property is a multiplier allowing
  34703. * rendering at a higher or lower resolution
  34704. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34705. * Check your browser for supported MIME types
  34706. * @param samples Texture samples (default: 1)
  34707. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34708. * @param fileName A name for for the downloaded file.
  34709. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34710. * to the src parameter of an <img> to display it
  34711. */
  34712. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34713. /**
  34714. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34715. * Be aware Math.random() could cause collisions, but:
  34716. * "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"
  34717. * @returns a pseudo random id
  34718. */
  34719. static RandomId(): string;
  34720. /**
  34721. * Test if the given uri is a base64 string
  34722. * @param uri The uri to test
  34723. * @return True if the uri is a base64 string or false otherwise
  34724. */
  34725. static IsBase64(uri: string): boolean;
  34726. /**
  34727. * Decode the given base64 uri.
  34728. * @param uri The uri to decode
  34729. * @return The decoded base64 data.
  34730. */
  34731. static DecodeBase64(uri: string): ArrayBuffer;
  34732. /**
  34733. * Gets the absolute url.
  34734. * @param url the input url
  34735. * @return the absolute url
  34736. */
  34737. static GetAbsoluteUrl(url: string): string;
  34738. /**
  34739. * No log
  34740. */
  34741. static readonly NoneLogLevel: number;
  34742. /**
  34743. * Only message logs
  34744. */
  34745. static readonly MessageLogLevel: number;
  34746. /**
  34747. * Only warning logs
  34748. */
  34749. static readonly WarningLogLevel: number;
  34750. /**
  34751. * Only error logs
  34752. */
  34753. static readonly ErrorLogLevel: number;
  34754. /**
  34755. * All logs
  34756. */
  34757. static readonly AllLogLevel: number;
  34758. /**
  34759. * Gets a value indicating the number of loading errors
  34760. * @ignorenaming
  34761. */
  34762. static get errorsCount(): number;
  34763. /**
  34764. * Callback called when a new log is added
  34765. */
  34766. static OnNewCacheEntry: (entry: string) => void;
  34767. /**
  34768. * Log a message to the console
  34769. * @param message defines the message to log
  34770. */
  34771. static Log(message: string): void;
  34772. /**
  34773. * Write a warning message to the console
  34774. * @param message defines the message to log
  34775. */
  34776. static Warn(message: string): void;
  34777. /**
  34778. * Write an error message to the console
  34779. * @param message defines the message to log
  34780. */
  34781. static Error(message: string): void;
  34782. /**
  34783. * Gets current log cache (list of logs)
  34784. */
  34785. static get LogCache(): string;
  34786. /**
  34787. * Clears the log cache
  34788. */
  34789. static ClearLogCache(): void;
  34790. /**
  34791. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34792. */
  34793. static set LogLevels(level: number);
  34794. /**
  34795. * Checks if the window object exists
  34796. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34797. */
  34798. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34799. /**
  34800. * No performance log
  34801. */
  34802. static readonly PerformanceNoneLogLevel: number;
  34803. /**
  34804. * Use user marks to log performance
  34805. */
  34806. static readonly PerformanceUserMarkLogLevel: number;
  34807. /**
  34808. * Log performance to the console
  34809. */
  34810. static readonly PerformanceConsoleLogLevel: number;
  34811. private static _performance;
  34812. /**
  34813. * Sets the current performance log level
  34814. */
  34815. static set PerformanceLogLevel(level: number);
  34816. private static _StartPerformanceCounterDisabled;
  34817. private static _EndPerformanceCounterDisabled;
  34818. private static _StartUserMark;
  34819. private static _EndUserMark;
  34820. private static _StartPerformanceConsole;
  34821. private static _EndPerformanceConsole;
  34822. /**
  34823. * Starts a performance counter
  34824. */
  34825. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34826. /**
  34827. * Ends a specific performance coutner
  34828. */
  34829. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34830. /**
  34831. * Gets either window.performance.now() if supported or Date.now() else
  34832. */
  34833. static get Now(): number;
  34834. /**
  34835. * This method will return the name of the class used to create the instance of the given object.
  34836. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34837. * @param object the object to get the class name from
  34838. * @param isType defines if the object is actually a type
  34839. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34840. */
  34841. static GetClassName(object: any, isType?: boolean): string;
  34842. /**
  34843. * Gets the first element of an array satisfying a given predicate
  34844. * @param array defines the array to browse
  34845. * @param predicate defines the predicate to use
  34846. * @returns null if not found or the element
  34847. */
  34848. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34849. /**
  34850. * This method will return the name of the full name of the class, including its owning module (if any).
  34851. * 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).
  34852. * @param object the object to get the class name from
  34853. * @param isType defines if the object is actually a type
  34854. * @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.
  34855. * @ignorenaming
  34856. */
  34857. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34858. /**
  34859. * Returns a promise that resolves after the given amount of time.
  34860. * @param delay Number of milliseconds to delay
  34861. * @returns Promise that resolves after the given amount of time
  34862. */
  34863. static DelayAsync(delay: number): Promise<void>;
  34864. /**
  34865. * Utility function to detect if the current user agent is Safari
  34866. * @returns whether or not the current user agent is safari
  34867. */
  34868. static IsSafari(): boolean;
  34869. }
  34870. /**
  34871. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34872. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34873. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34874. * @param name The name of the class, case should be preserved
  34875. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34876. */
  34877. export function className(name: string, module?: string): (target: Object) => void;
  34878. /**
  34879. * An implementation of a loop for asynchronous functions.
  34880. */
  34881. export class AsyncLoop {
  34882. /**
  34883. * Defines the number of iterations for the loop
  34884. */
  34885. iterations: number;
  34886. /**
  34887. * Defines the current index of the loop.
  34888. */
  34889. index: number;
  34890. private _done;
  34891. private _fn;
  34892. private _successCallback;
  34893. /**
  34894. * Constructor.
  34895. * @param iterations the number of iterations.
  34896. * @param func the function to run each iteration
  34897. * @param successCallback the callback that will be called upon succesful execution
  34898. * @param offset starting offset.
  34899. */
  34900. constructor(
  34901. /**
  34902. * Defines the number of iterations for the loop
  34903. */
  34904. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34905. /**
  34906. * Execute the next iteration. Must be called after the last iteration was finished.
  34907. */
  34908. executeNext(): void;
  34909. /**
  34910. * Break the loop and run the success callback.
  34911. */
  34912. breakLoop(): void;
  34913. /**
  34914. * Create and run an async loop.
  34915. * @param iterations the number of iterations.
  34916. * @param fn the function to run each iteration
  34917. * @param successCallback the callback that will be called upon succesful execution
  34918. * @param offset starting offset.
  34919. * @returns the created async loop object
  34920. */
  34921. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34922. /**
  34923. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34924. * @param iterations total number of iterations
  34925. * @param syncedIterations number of synchronous iterations in each async iteration.
  34926. * @param fn the function to call each iteration.
  34927. * @param callback a success call back that will be called when iterating stops.
  34928. * @param breakFunction a break condition (optional)
  34929. * @param timeout timeout settings for the setTimeout function. default - 0.
  34930. * @returns the created async loop object
  34931. */
  34932. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34933. }
  34934. }
  34935. declare module BABYLON {
  34936. /**
  34937. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34938. * The underlying implementation relies on an associative array to ensure the best performances.
  34939. * The value can be anything including 'null' but except 'undefined'
  34940. */
  34941. export class StringDictionary<T> {
  34942. /**
  34943. * This will clear this dictionary and copy the content from the 'source' one.
  34944. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34945. * @param source the dictionary to take the content from and copy to this dictionary
  34946. */
  34947. copyFrom(source: StringDictionary<T>): void;
  34948. /**
  34949. * Get a value based from its key
  34950. * @param key the given key to get the matching value from
  34951. * @return the value if found, otherwise undefined is returned
  34952. */
  34953. get(key: string): T | undefined;
  34954. /**
  34955. * Get a value from its key or add it if it doesn't exist.
  34956. * This method will ensure you that a given key/data will be present in the dictionary.
  34957. * @param key the given key to get the matching value from
  34958. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34959. * The factory will only be invoked if there's no data for the given key.
  34960. * @return the value corresponding to the key.
  34961. */
  34962. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34963. /**
  34964. * Get a value from its key if present in the dictionary otherwise add it
  34965. * @param key the key to get the value from
  34966. * @param val if there's no such key/value pair in the dictionary add it with this value
  34967. * @return the value corresponding to the key
  34968. */
  34969. getOrAdd(key: string, val: T): T;
  34970. /**
  34971. * Check if there's a given key in the dictionary
  34972. * @param key the key to check for
  34973. * @return true if the key is present, false otherwise
  34974. */
  34975. contains(key: string): boolean;
  34976. /**
  34977. * Add a new key and its corresponding value
  34978. * @param key the key to add
  34979. * @param value the value corresponding to the key
  34980. * @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
  34981. */
  34982. add(key: string, value: T): boolean;
  34983. /**
  34984. * Update a specific value associated to a key
  34985. * @param key defines the key to use
  34986. * @param value defines the value to store
  34987. * @returns true if the value was updated (or false if the key was not found)
  34988. */
  34989. set(key: string, value: T): boolean;
  34990. /**
  34991. * Get the element of the given key and remove it from the dictionary
  34992. * @param key defines the key to search
  34993. * @returns the value associated with the key or null if not found
  34994. */
  34995. getAndRemove(key: string): Nullable<T>;
  34996. /**
  34997. * Remove a key/value from the dictionary.
  34998. * @param key the key to remove
  34999. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35000. */
  35001. remove(key: string): boolean;
  35002. /**
  35003. * Clear the whole content of the dictionary
  35004. */
  35005. clear(): void;
  35006. /**
  35007. * Gets the current count
  35008. */
  35009. get count(): number;
  35010. /**
  35011. * Execute a callback on each key/val of the dictionary.
  35012. * Note that you can remove any element in this dictionary in the callback implementation
  35013. * @param callback the callback to execute on a given key/value pair
  35014. */
  35015. forEach(callback: (key: string, val: T) => void): void;
  35016. /**
  35017. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35018. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35019. * Note that you can remove any element in this dictionary in the callback implementation
  35020. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35021. * @returns the first item
  35022. */
  35023. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35024. private _count;
  35025. private _data;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /** @hidden */
  35030. export interface ICollisionCoordinator {
  35031. createCollider(): Collider;
  35032. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35033. init(scene: Scene): void;
  35034. }
  35035. /** @hidden */
  35036. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35037. private _scene;
  35038. private _scaledPosition;
  35039. private _scaledVelocity;
  35040. private _finalPosition;
  35041. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35042. createCollider(): Collider;
  35043. init(scene: Scene): void;
  35044. private _collideWithWorld;
  35045. }
  35046. }
  35047. declare module BABYLON {
  35048. /**
  35049. * Class used to manage all inputs for the scene.
  35050. */
  35051. export class InputManager {
  35052. /** The distance in pixel that you have to move to prevent some events */
  35053. static DragMovementThreshold: number;
  35054. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35055. static LongPressDelay: number;
  35056. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35057. static DoubleClickDelay: number;
  35058. /** If you need to check double click without raising a single click at first click, enable this flag */
  35059. static ExclusiveDoubleClickMode: boolean;
  35060. private _wheelEventName;
  35061. private _onPointerMove;
  35062. private _onPointerDown;
  35063. private _onPointerUp;
  35064. private _initClickEvent;
  35065. private _initActionManager;
  35066. private _delayedSimpleClick;
  35067. private _delayedSimpleClickTimeout;
  35068. private _previousDelayedSimpleClickTimeout;
  35069. private _meshPickProceed;
  35070. private _previousButtonPressed;
  35071. private _currentPickResult;
  35072. private _previousPickResult;
  35073. private _totalPointersPressed;
  35074. private _doubleClickOccured;
  35075. private _pointerOverMesh;
  35076. private _pickedDownMesh;
  35077. private _pickedUpMesh;
  35078. private _pointerX;
  35079. private _pointerY;
  35080. private _unTranslatedPointerX;
  35081. private _unTranslatedPointerY;
  35082. private _startingPointerPosition;
  35083. private _previousStartingPointerPosition;
  35084. private _startingPointerTime;
  35085. private _previousStartingPointerTime;
  35086. private _pointerCaptures;
  35087. private _onKeyDown;
  35088. private _onKeyUp;
  35089. private _onCanvasFocusObserver;
  35090. private _onCanvasBlurObserver;
  35091. private _scene;
  35092. /**
  35093. * Creates a new InputManager
  35094. * @param scene defines the hosting scene
  35095. */
  35096. constructor(scene: Scene);
  35097. /**
  35098. * Gets the mesh that is currently under the pointer
  35099. */
  35100. get meshUnderPointer(): Nullable<AbstractMesh>;
  35101. /**
  35102. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35103. */
  35104. get unTranslatedPointer(): Vector2;
  35105. /**
  35106. * Gets or sets the current on-screen X position of the pointer
  35107. */
  35108. get pointerX(): number;
  35109. set pointerX(value: number);
  35110. /**
  35111. * Gets or sets the current on-screen Y position of the pointer
  35112. */
  35113. get pointerY(): number;
  35114. set pointerY(value: number);
  35115. private _updatePointerPosition;
  35116. private _processPointerMove;
  35117. private _setRayOnPointerInfo;
  35118. private _checkPrePointerObservable;
  35119. /**
  35120. * Use this method to simulate a pointer move on a mesh
  35121. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35122. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35123. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35124. */
  35125. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35126. /**
  35127. * Use this method to simulate a pointer down on a mesh
  35128. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35129. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35130. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35131. */
  35132. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35133. private _processPointerDown;
  35134. /** @hidden */
  35135. _isPointerSwiping(): boolean;
  35136. /**
  35137. * Use this method to simulate a pointer up on a mesh
  35138. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35139. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35140. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35141. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35142. */
  35143. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35144. private _processPointerUp;
  35145. /**
  35146. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35147. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35148. * @returns true if the pointer was captured
  35149. */
  35150. isPointerCaptured(pointerId?: number): boolean;
  35151. /**
  35152. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35153. * @param attachUp defines if you want to attach events to pointerup
  35154. * @param attachDown defines if you want to attach events to pointerdown
  35155. * @param attachMove defines if you want to attach events to pointermove
  35156. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35157. */
  35158. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35159. /**
  35160. * Detaches all event handlers
  35161. */
  35162. detachControl(): void;
  35163. /**
  35164. * Force the value of meshUnderPointer
  35165. * @param mesh defines the mesh to use
  35166. */
  35167. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35168. /**
  35169. * Gets the mesh under the pointer
  35170. * @returns a Mesh or null if no mesh is under the pointer
  35171. */
  35172. getPointerOverMesh(): Nullable<AbstractMesh>;
  35173. }
  35174. }
  35175. declare module BABYLON {
  35176. /**
  35177. * Helper class used to generate session unique ID
  35178. */
  35179. export class UniqueIdGenerator {
  35180. private static _UniqueIdCounter;
  35181. /**
  35182. * Gets an unique (relatively to the current scene) Id
  35183. */
  35184. static get UniqueId(): number;
  35185. }
  35186. }
  35187. declare module BABYLON {
  35188. /**
  35189. * This class defines the direct association between an animation and a target
  35190. */
  35191. export class TargetedAnimation {
  35192. /**
  35193. * Animation to perform
  35194. */
  35195. animation: Animation;
  35196. /**
  35197. * Target to animate
  35198. */
  35199. target: any;
  35200. /**
  35201. * Serialize the object
  35202. * @returns the JSON object representing the current entity
  35203. */
  35204. serialize(): any;
  35205. }
  35206. /**
  35207. * Use this class to create coordinated animations on multiple targets
  35208. */
  35209. export class AnimationGroup implements IDisposable {
  35210. /** The name of the animation group */
  35211. name: string;
  35212. private _scene;
  35213. private _targetedAnimations;
  35214. private _animatables;
  35215. private _from;
  35216. private _to;
  35217. private _isStarted;
  35218. private _isPaused;
  35219. private _speedRatio;
  35220. private _loopAnimation;
  35221. private _isAdditive;
  35222. /**
  35223. * Gets or sets the unique id of the node
  35224. */
  35225. uniqueId: number;
  35226. /**
  35227. * This observable will notify when one animation have ended
  35228. */
  35229. onAnimationEndObservable: Observable<TargetedAnimation>;
  35230. /**
  35231. * Observer raised when one animation loops
  35232. */
  35233. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35234. /**
  35235. * Observer raised when all animations have looped
  35236. */
  35237. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35238. /**
  35239. * This observable will notify when all animations have ended.
  35240. */
  35241. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35242. /**
  35243. * This observable will notify when all animations have paused.
  35244. */
  35245. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35246. /**
  35247. * This observable will notify when all animations are playing.
  35248. */
  35249. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35250. /**
  35251. * Gets the first frame
  35252. */
  35253. get from(): number;
  35254. /**
  35255. * Gets the last frame
  35256. */
  35257. get to(): number;
  35258. /**
  35259. * Define if the animations are started
  35260. */
  35261. get isStarted(): boolean;
  35262. /**
  35263. * Gets a value indicating that the current group is playing
  35264. */
  35265. get isPlaying(): boolean;
  35266. /**
  35267. * Gets or sets the speed ratio to use for all animations
  35268. */
  35269. get speedRatio(): number;
  35270. /**
  35271. * Gets or sets the speed ratio to use for all animations
  35272. */
  35273. set speedRatio(value: number);
  35274. /**
  35275. * Gets or sets if all animations should loop or not
  35276. */
  35277. get loopAnimation(): boolean;
  35278. set loopAnimation(value: boolean);
  35279. /**
  35280. * Gets or sets if all animations should be evaluated additively
  35281. */
  35282. get isAdditive(): boolean;
  35283. set isAdditive(value: boolean);
  35284. /**
  35285. * Gets the targeted animations for this animation group
  35286. */
  35287. get targetedAnimations(): Array<TargetedAnimation>;
  35288. /**
  35289. * returning the list of animatables controlled by this animation group.
  35290. */
  35291. get animatables(): Array<Animatable>;
  35292. /**
  35293. * Instantiates a new Animation Group.
  35294. * This helps managing several animations at once.
  35295. * @see http://doc.babylonjs.com/how_to/group
  35296. * @param name Defines the name of the group
  35297. * @param scene Defines the scene the group belongs to
  35298. */
  35299. constructor(
  35300. /** The name of the animation group */
  35301. name: string, scene?: Nullable<Scene>);
  35302. /**
  35303. * Add an animation (with its target) in the group
  35304. * @param animation defines the animation we want to add
  35305. * @param target defines the target of the animation
  35306. * @returns the TargetedAnimation object
  35307. */
  35308. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35309. /**
  35310. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35311. * It can add constant keys at begin or end
  35312. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35313. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35314. * @returns the animation group
  35315. */
  35316. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35317. private _animationLoopCount;
  35318. private _animationLoopFlags;
  35319. private _processLoop;
  35320. /**
  35321. * Start all animations on given targets
  35322. * @param loop defines if animations must loop
  35323. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35324. * @param from defines the from key (optional)
  35325. * @param to defines the to key (optional)
  35326. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35327. * @returns the current animation group
  35328. */
  35329. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35330. /**
  35331. * Pause all animations
  35332. * @returns the animation group
  35333. */
  35334. pause(): AnimationGroup;
  35335. /**
  35336. * Play all animations to initial state
  35337. * This function will start() the animations if they were not started or will restart() them if they were paused
  35338. * @param loop defines if animations must loop
  35339. * @returns the animation group
  35340. */
  35341. play(loop?: boolean): AnimationGroup;
  35342. /**
  35343. * Reset all animations to initial state
  35344. * @returns the animation group
  35345. */
  35346. reset(): AnimationGroup;
  35347. /**
  35348. * Restart animations from key 0
  35349. * @returns the animation group
  35350. */
  35351. restart(): AnimationGroup;
  35352. /**
  35353. * Stop all animations
  35354. * @returns the animation group
  35355. */
  35356. stop(): AnimationGroup;
  35357. /**
  35358. * Set animation weight for all animatables
  35359. * @param weight defines the weight to use
  35360. * @return the animationGroup
  35361. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35362. */
  35363. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35364. /**
  35365. * Synchronize and normalize all animatables with a source animatable
  35366. * @param root defines the root animatable to synchronize with
  35367. * @return the animationGroup
  35368. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35369. */
  35370. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35371. /**
  35372. * Goes to a specific frame in this animation group
  35373. * @param frame the frame number to go to
  35374. * @return the animationGroup
  35375. */
  35376. goToFrame(frame: number): AnimationGroup;
  35377. /**
  35378. * Dispose all associated resources
  35379. */
  35380. dispose(): void;
  35381. private _checkAnimationGroupEnded;
  35382. /**
  35383. * Clone the current animation group and returns a copy
  35384. * @param newName defines the name of the new group
  35385. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35386. * @returns the new aniamtion group
  35387. */
  35388. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35389. /**
  35390. * Serializes the animationGroup to an object
  35391. * @returns Serialized object
  35392. */
  35393. serialize(): any;
  35394. /**
  35395. * Returns a new AnimationGroup object parsed from the source provided.
  35396. * @param parsedAnimationGroup defines the source
  35397. * @param scene defines the scene that will receive the animationGroup
  35398. * @returns a new AnimationGroup
  35399. */
  35400. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35401. /**
  35402. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35403. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35404. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35405. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35406. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35407. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35408. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35409. */
  35410. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35411. /**
  35412. * Returns the string "AnimationGroup"
  35413. * @returns "AnimationGroup"
  35414. */
  35415. getClassName(): string;
  35416. /**
  35417. * Creates a detailled string about the object
  35418. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35419. * @returns a string representing the object
  35420. */
  35421. toString(fullDetails?: boolean): string;
  35422. }
  35423. }
  35424. declare module BABYLON {
  35425. /**
  35426. * Define an interface for all classes that will hold resources
  35427. */
  35428. export interface IDisposable {
  35429. /**
  35430. * Releases all held resources
  35431. */
  35432. dispose(): void;
  35433. }
  35434. /** Interface defining initialization parameters for Scene class */
  35435. export interface SceneOptions {
  35436. /**
  35437. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35438. * It will improve performance when the number of geometries becomes important.
  35439. */
  35440. useGeometryUniqueIdsMap?: boolean;
  35441. /**
  35442. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35443. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35444. */
  35445. useMaterialMeshMap?: boolean;
  35446. /**
  35447. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35448. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35449. */
  35450. useClonedMeshMap?: boolean;
  35451. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35452. virtual?: boolean;
  35453. }
  35454. /**
  35455. * Represents a scene to be rendered by the engine.
  35456. * @see http://doc.babylonjs.com/features/scene
  35457. */
  35458. export class Scene extends AbstractScene implements IAnimatable {
  35459. /** The fog is deactivated */
  35460. static readonly FOGMODE_NONE: number;
  35461. /** The fog density is following an exponential function */
  35462. static readonly FOGMODE_EXP: number;
  35463. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35464. static readonly FOGMODE_EXP2: number;
  35465. /** The fog density is following a linear function. */
  35466. static readonly FOGMODE_LINEAR: number;
  35467. /**
  35468. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35469. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35470. */
  35471. static MinDeltaTime: number;
  35472. /**
  35473. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35475. */
  35476. static MaxDeltaTime: number;
  35477. /**
  35478. * Factory used to create the default material.
  35479. * @param name The name of the material to create
  35480. * @param scene The scene to create the material for
  35481. * @returns The default material
  35482. */
  35483. static DefaultMaterialFactory(scene: Scene): Material;
  35484. /**
  35485. * Factory used to create the a collision coordinator.
  35486. * @returns The collision coordinator
  35487. */
  35488. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35489. /** @hidden */
  35490. _inputManager: InputManager;
  35491. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35492. cameraToUseForPointers: Nullable<Camera>;
  35493. /** @hidden */
  35494. readonly _isScene: boolean;
  35495. /** @hidden */
  35496. _blockEntityCollection: boolean;
  35497. /**
  35498. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35499. */
  35500. autoClear: boolean;
  35501. /**
  35502. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35503. */
  35504. autoClearDepthAndStencil: boolean;
  35505. /**
  35506. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35507. */
  35508. clearColor: Color4;
  35509. /**
  35510. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35511. */
  35512. ambientColor: Color3;
  35513. /**
  35514. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35515. * It should only be one of the following (if not the default embedded one):
  35516. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35517. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35518. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35519. * The material properties need to be setup according to the type of texture in use.
  35520. */
  35521. environmentBRDFTexture: BaseTexture;
  35522. /** @hidden */
  35523. protected _environmentTexture: Nullable<BaseTexture>;
  35524. /**
  35525. * Texture used in all pbr material as the reflection texture.
  35526. * As in the majority of the scene they are the same (exception for multi room and so on),
  35527. * this is easier to reference from here than from all the materials.
  35528. */
  35529. get environmentTexture(): Nullable<BaseTexture>;
  35530. /**
  35531. * Texture used in all pbr material as the reflection texture.
  35532. * As in the majority of the scene they are the same (exception for multi room and so on),
  35533. * this is easier to set here than in all the materials.
  35534. */
  35535. set environmentTexture(value: Nullable<BaseTexture>);
  35536. /** @hidden */
  35537. protected _environmentIntensity: number;
  35538. /**
  35539. * Intensity of the environment in all pbr material.
  35540. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35541. * As in the majority of the scene they are the same (exception for multi room and so on),
  35542. * this is easier to reference from here than from all the materials.
  35543. */
  35544. get environmentIntensity(): number;
  35545. /**
  35546. * Intensity of the environment in all pbr material.
  35547. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35548. * As in the majority of the scene they are the same (exception for multi room and so on),
  35549. * this is easier to set here than in all the materials.
  35550. */
  35551. set environmentIntensity(value: number);
  35552. /** @hidden */
  35553. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35554. /**
  35555. * Default image processing configuration used either in the rendering
  35556. * Forward main pass or through the imageProcessingPostProcess if present.
  35557. * As in the majority of the scene they are the same (exception for multi camera),
  35558. * this is easier to reference from here than from all the materials and post process.
  35559. *
  35560. * No setter as we it is a shared configuration, you can set the values instead.
  35561. */
  35562. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35563. private _forceWireframe;
  35564. /**
  35565. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35566. */
  35567. set forceWireframe(value: boolean);
  35568. get forceWireframe(): boolean;
  35569. private _skipFrustumClipping;
  35570. /**
  35571. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35572. */
  35573. set skipFrustumClipping(value: boolean);
  35574. get skipFrustumClipping(): boolean;
  35575. private _forcePointsCloud;
  35576. /**
  35577. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35578. */
  35579. set forcePointsCloud(value: boolean);
  35580. get forcePointsCloud(): boolean;
  35581. /**
  35582. * Gets or sets the active clipplane 1
  35583. */
  35584. clipPlane: Nullable<Plane>;
  35585. /**
  35586. * Gets or sets the active clipplane 2
  35587. */
  35588. clipPlane2: Nullable<Plane>;
  35589. /**
  35590. * Gets or sets the active clipplane 3
  35591. */
  35592. clipPlane3: Nullable<Plane>;
  35593. /**
  35594. * Gets or sets the active clipplane 4
  35595. */
  35596. clipPlane4: Nullable<Plane>;
  35597. /**
  35598. * Gets or sets the active clipplane 5
  35599. */
  35600. clipPlane5: Nullable<Plane>;
  35601. /**
  35602. * Gets or sets the active clipplane 6
  35603. */
  35604. clipPlane6: Nullable<Plane>;
  35605. /**
  35606. * Gets or sets a boolean indicating if animations are enabled
  35607. */
  35608. animationsEnabled: boolean;
  35609. private _animationPropertiesOverride;
  35610. /**
  35611. * Gets or sets the animation properties override
  35612. */
  35613. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35614. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35615. /**
  35616. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35617. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35618. */
  35619. useConstantAnimationDeltaTime: boolean;
  35620. /**
  35621. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35622. * Please note that it requires to run a ray cast through the scene on every frame
  35623. */
  35624. constantlyUpdateMeshUnderPointer: boolean;
  35625. /**
  35626. * Defines the HTML cursor to use when hovering over interactive elements
  35627. */
  35628. hoverCursor: string;
  35629. /**
  35630. * Defines the HTML default cursor to use (empty by default)
  35631. */
  35632. defaultCursor: string;
  35633. /**
  35634. * Defines whether cursors are handled by the scene.
  35635. */
  35636. doNotHandleCursors: boolean;
  35637. /**
  35638. * This is used to call preventDefault() on pointer down
  35639. * in order to block unwanted artifacts like system double clicks
  35640. */
  35641. preventDefaultOnPointerDown: boolean;
  35642. /**
  35643. * This is used to call preventDefault() on pointer up
  35644. * in order to block unwanted artifacts like system double clicks
  35645. */
  35646. preventDefaultOnPointerUp: boolean;
  35647. /**
  35648. * Gets or sets user defined metadata
  35649. */
  35650. metadata: any;
  35651. /**
  35652. * For internal use only. Please do not use.
  35653. */
  35654. reservedDataStore: any;
  35655. /**
  35656. * Gets the name of the plugin used to load this scene (null by default)
  35657. */
  35658. loadingPluginName: string;
  35659. /**
  35660. * Use this array to add regular expressions used to disable offline support for specific urls
  35661. */
  35662. disableOfflineSupportExceptionRules: RegExp[];
  35663. /**
  35664. * An event triggered when the scene is disposed.
  35665. */
  35666. onDisposeObservable: Observable<Scene>;
  35667. private _onDisposeObserver;
  35668. /** Sets a function to be executed when this scene is disposed. */
  35669. set onDispose(callback: () => void);
  35670. /**
  35671. * An event triggered before rendering the scene (right after animations and physics)
  35672. */
  35673. onBeforeRenderObservable: Observable<Scene>;
  35674. private _onBeforeRenderObserver;
  35675. /** Sets a function to be executed before rendering this scene */
  35676. set beforeRender(callback: Nullable<() => void>);
  35677. /**
  35678. * An event triggered after rendering the scene
  35679. */
  35680. onAfterRenderObservable: Observable<Scene>;
  35681. /**
  35682. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35683. */
  35684. onAfterRenderCameraObservable: Observable<Camera>;
  35685. private _onAfterRenderObserver;
  35686. /** Sets a function to be executed after rendering this scene */
  35687. set afterRender(callback: Nullable<() => void>);
  35688. /**
  35689. * An event triggered before animating the scene
  35690. */
  35691. onBeforeAnimationsObservable: Observable<Scene>;
  35692. /**
  35693. * An event triggered after animations processing
  35694. */
  35695. onAfterAnimationsObservable: Observable<Scene>;
  35696. /**
  35697. * An event triggered before draw calls are ready to be sent
  35698. */
  35699. onBeforeDrawPhaseObservable: Observable<Scene>;
  35700. /**
  35701. * An event triggered after draw calls have been sent
  35702. */
  35703. onAfterDrawPhaseObservable: Observable<Scene>;
  35704. /**
  35705. * An event triggered when the scene is ready
  35706. */
  35707. onReadyObservable: Observable<Scene>;
  35708. /**
  35709. * An event triggered before rendering a camera
  35710. */
  35711. onBeforeCameraRenderObservable: Observable<Camera>;
  35712. private _onBeforeCameraRenderObserver;
  35713. /** Sets a function to be executed before rendering a camera*/
  35714. set beforeCameraRender(callback: () => void);
  35715. /**
  35716. * An event triggered after rendering a camera
  35717. */
  35718. onAfterCameraRenderObservable: Observable<Camera>;
  35719. private _onAfterCameraRenderObserver;
  35720. /** Sets a function to be executed after rendering a camera*/
  35721. set afterCameraRender(callback: () => void);
  35722. /**
  35723. * An event triggered when active meshes evaluation is about to start
  35724. */
  35725. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35726. /**
  35727. * An event triggered when active meshes evaluation is done
  35728. */
  35729. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35730. /**
  35731. * An event triggered when particles rendering is about to start
  35732. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35733. */
  35734. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35735. /**
  35736. * An event triggered when particles rendering is done
  35737. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35738. */
  35739. onAfterParticlesRenderingObservable: Observable<Scene>;
  35740. /**
  35741. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35742. */
  35743. onDataLoadedObservable: Observable<Scene>;
  35744. /**
  35745. * An event triggered when a camera is created
  35746. */
  35747. onNewCameraAddedObservable: Observable<Camera>;
  35748. /**
  35749. * An event triggered when a camera is removed
  35750. */
  35751. onCameraRemovedObservable: Observable<Camera>;
  35752. /**
  35753. * An event triggered when a light is created
  35754. */
  35755. onNewLightAddedObservable: Observable<Light>;
  35756. /**
  35757. * An event triggered when a light is removed
  35758. */
  35759. onLightRemovedObservable: Observable<Light>;
  35760. /**
  35761. * An event triggered when a geometry is created
  35762. */
  35763. onNewGeometryAddedObservable: Observable<Geometry>;
  35764. /**
  35765. * An event triggered when a geometry is removed
  35766. */
  35767. onGeometryRemovedObservable: Observable<Geometry>;
  35768. /**
  35769. * An event triggered when a transform node is created
  35770. */
  35771. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35772. /**
  35773. * An event triggered when a transform node is removed
  35774. */
  35775. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35776. /**
  35777. * An event triggered when a mesh is created
  35778. */
  35779. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35780. /**
  35781. * An event triggered when a mesh is removed
  35782. */
  35783. onMeshRemovedObservable: Observable<AbstractMesh>;
  35784. /**
  35785. * An event triggered when a skeleton is created
  35786. */
  35787. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35788. /**
  35789. * An event triggered when a skeleton is removed
  35790. */
  35791. onSkeletonRemovedObservable: Observable<Skeleton>;
  35792. /**
  35793. * An event triggered when a material is created
  35794. */
  35795. onNewMaterialAddedObservable: Observable<Material>;
  35796. /**
  35797. * An event triggered when a material is removed
  35798. */
  35799. onMaterialRemovedObservable: Observable<Material>;
  35800. /**
  35801. * An event triggered when a texture is created
  35802. */
  35803. onNewTextureAddedObservable: Observable<BaseTexture>;
  35804. /**
  35805. * An event triggered when a texture is removed
  35806. */
  35807. onTextureRemovedObservable: Observable<BaseTexture>;
  35808. /**
  35809. * An event triggered when render targets are about to be rendered
  35810. * Can happen multiple times per frame.
  35811. */
  35812. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35813. /**
  35814. * An event triggered when render targets were rendered.
  35815. * Can happen multiple times per frame.
  35816. */
  35817. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35818. /**
  35819. * An event triggered before calculating deterministic simulation step
  35820. */
  35821. onBeforeStepObservable: Observable<Scene>;
  35822. /**
  35823. * An event triggered after calculating deterministic simulation step
  35824. */
  35825. onAfterStepObservable: Observable<Scene>;
  35826. /**
  35827. * An event triggered when the activeCamera property is updated
  35828. */
  35829. onActiveCameraChanged: Observable<Scene>;
  35830. /**
  35831. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35832. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35833. * 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)
  35834. */
  35835. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35836. /**
  35837. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35838. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35839. * 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)
  35840. */
  35841. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35842. /**
  35843. * This Observable will when a mesh has been imported into the scene.
  35844. */
  35845. onMeshImportedObservable: Observable<AbstractMesh>;
  35846. /**
  35847. * This Observable will when an animation file has been imported into the scene.
  35848. */
  35849. onAnimationFileImportedObservable: Observable<Scene>;
  35850. /**
  35851. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35852. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35853. */
  35854. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35855. /** @hidden */
  35856. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35857. /**
  35858. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35859. */
  35860. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35861. /**
  35862. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35863. */
  35864. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35865. /**
  35866. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35867. */
  35868. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35869. /** Callback called when a pointer move is detected */
  35870. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35871. /** Callback called when a pointer down is detected */
  35872. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35873. /** Callback called when a pointer up is detected */
  35874. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35875. /** Callback called when a pointer pick is detected */
  35876. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35877. /**
  35878. * 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).
  35879. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35880. */
  35881. onPrePointerObservable: Observable<PointerInfoPre>;
  35882. /**
  35883. * Observable event triggered each time an input event is received from the rendering canvas
  35884. */
  35885. onPointerObservable: Observable<PointerInfo>;
  35886. /**
  35887. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35888. */
  35889. get unTranslatedPointer(): Vector2;
  35890. /**
  35891. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35892. */
  35893. static get DragMovementThreshold(): number;
  35894. static set DragMovementThreshold(value: number);
  35895. /**
  35896. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35897. */
  35898. static get LongPressDelay(): number;
  35899. static set LongPressDelay(value: number);
  35900. /**
  35901. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35902. */
  35903. static get DoubleClickDelay(): number;
  35904. static set DoubleClickDelay(value: number);
  35905. /** If you need to check double click without raising a single click at first click, enable this flag */
  35906. static get ExclusiveDoubleClickMode(): boolean;
  35907. static set ExclusiveDoubleClickMode(value: boolean);
  35908. /** @hidden */
  35909. _mirroredCameraPosition: Nullable<Vector3>;
  35910. /**
  35911. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35912. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35913. */
  35914. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35915. /**
  35916. * Observable event triggered each time an keyboard event is received from the hosting window
  35917. */
  35918. onKeyboardObservable: Observable<KeyboardInfo>;
  35919. private _useRightHandedSystem;
  35920. /**
  35921. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35922. */
  35923. set useRightHandedSystem(value: boolean);
  35924. get useRightHandedSystem(): boolean;
  35925. private _timeAccumulator;
  35926. private _currentStepId;
  35927. private _currentInternalStep;
  35928. /**
  35929. * Sets the step Id used by deterministic lock step
  35930. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35931. * @param newStepId defines the step Id
  35932. */
  35933. setStepId(newStepId: number): void;
  35934. /**
  35935. * Gets the step Id used by deterministic lock step
  35936. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35937. * @returns the step Id
  35938. */
  35939. getStepId(): number;
  35940. /**
  35941. * Gets the internal step used by deterministic lock step
  35942. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35943. * @returns the internal step
  35944. */
  35945. getInternalStep(): number;
  35946. private _fogEnabled;
  35947. /**
  35948. * Gets or sets a boolean indicating if fog is enabled on this scene
  35949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35950. * (Default is true)
  35951. */
  35952. set fogEnabled(value: boolean);
  35953. get fogEnabled(): boolean;
  35954. private _fogMode;
  35955. /**
  35956. * Gets or sets the fog mode to use
  35957. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35958. * | mode | value |
  35959. * | --- | --- |
  35960. * | FOGMODE_NONE | 0 |
  35961. * | FOGMODE_EXP | 1 |
  35962. * | FOGMODE_EXP2 | 2 |
  35963. * | FOGMODE_LINEAR | 3 |
  35964. */
  35965. set fogMode(value: number);
  35966. get fogMode(): number;
  35967. /**
  35968. * Gets or sets the fog color to use
  35969. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35970. * (Default is Color3(0.2, 0.2, 0.3))
  35971. */
  35972. fogColor: Color3;
  35973. /**
  35974. * Gets or sets the fog density to use
  35975. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35976. * (Default is 0.1)
  35977. */
  35978. fogDensity: number;
  35979. /**
  35980. * Gets or sets the fog start distance to use
  35981. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35982. * (Default is 0)
  35983. */
  35984. fogStart: number;
  35985. /**
  35986. * Gets or sets the fog end distance to use
  35987. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35988. * (Default is 1000)
  35989. */
  35990. fogEnd: number;
  35991. private _shadowsEnabled;
  35992. /**
  35993. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35994. */
  35995. set shadowsEnabled(value: boolean);
  35996. get shadowsEnabled(): boolean;
  35997. private _lightsEnabled;
  35998. /**
  35999. * Gets or sets a boolean indicating if lights are enabled on this scene
  36000. */
  36001. set lightsEnabled(value: boolean);
  36002. get lightsEnabled(): boolean;
  36003. /** All of the active cameras added to this scene. */
  36004. activeCameras: Camera[];
  36005. /** @hidden */
  36006. _activeCamera: Nullable<Camera>;
  36007. /** Gets or sets the current active camera */
  36008. get activeCamera(): Nullable<Camera>;
  36009. set activeCamera(value: Nullable<Camera>);
  36010. private _defaultMaterial;
  36011. /** The default material used on meshes when no material is affected */
  36012. get defaultMaterial(): Material;
  36013. /** The default material used on meshes when no material is affected */
  36014. set defaultMaterial(value: Material);
  36015. private _texturesEnabled;
  36016. /**
  36017. * Gets or sets a boolean indicating if textures are enabled on this scene
  36018. */
  36019. set texturesEnabled(value: boolean);
  36020. get texturesEnabled(): boolean;
  36021. /**
  36022. * Gets or sets a boolean indicating if particles are enabled on this scene
  36023. */
  36024. particlesEnabled: boolean;
  36025. /**
  36026. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36027. */
  36028. spritesEnabled: boolean;
  36029. private _skeletonsEnabled;
  36030. /**
  36031. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36032. */
  36033. set skeletonsEnabled(value: boolean);
  36034. get skeletonsEnabled(): boolean;
  36035. /**
  36036. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36037. */
  36038. lensFlaresEnabled: boolean;
  36039. /**
  36040. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36042. */
  36043. collisionsEnabled: boolean;
  36044. private _collisionCoordinator;
  36045. /** @hidden */
  36046. get collisionCoordinator(): ICollisionCoordinator;
  36047. /**
  36048. * Defines the gravity applied to this scene (used only for collisions)
  36049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36050. */
  36051. gravity: Vector3;
  36052. /**
  36053. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36054. */
  36055. postProcessesEnabled: boolean;
  36056. /**
  36057. * The list of postprocesses added to the scene
  36058. */
  36059. postProcesses: PostProcess[];
  36060. /**
  36061. * Gets the current postprocess manager
  36062. */
  36063. postProcessManager: PostProcessManager;
  36064. /**
  36065. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36066. */
  36067. renderTargetsEnabled: boolean;
  36068. /**
  36069. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36070. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36071. */
  36072. dumpNextRenderTargets: boolean;
  36073. /**
  36074. * The list of user defined render targets added to the scene
  36075. */
  36076. customRenderTargets: RenderTargetTexture[];
  36077. /**
  36078. * Defines if texture loading must be delayed
  36079. * If true, textures will only be loaded when they need to be rendered
  36080. */
  36081. useDelayedTextureLoading: boolean;
  36082. /**
  36083. * Gets the list of meshes imported to the scene through SceneLoader
  36084. */
  36085. importedMeshesFiles: String[];
  36086. /**
  36087. * Gets or sets a boolean indicating if probes are enabled on this scene
  36088. */
  36089. probesEnabled: boolean;
  36090. /**
  36091. * Gets or sets the current offline provider to use to store scene data
  36092. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36093. */
  36094. offlineProvider: IOfflineProvider;
  36095. /**
  36096. * Gets or sets the action manager associated with the scene
  36097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36098. */
  36099. actionManager: AbstractActionManager;
  36100. private _meshesForIntersections;
  36101. /**
  36102. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36103. */
  36104. proceduralTexturesEnabled: boolean;
  36105. private _engine;
  36106. private _totalVertices;
  36107. /** @hidden */
  36108. _activeIndices: PerfCounter;
  36109. /** @hidden */
  36110. _activeParticles: PerfCounter;
  36111. /** @hidden */
  36112. _activeBones: PerfCounter;
  36113. private _animationRatio;
  36114. /** @hidden */
  36115. _animationTimeLast: number;
  36116. /** @hidden */
  36117. _animationTime: number;
  36118. /**
  36119. * Gets or sets a general scale for animation speed
  36120. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36121. */
  36122. animationTimeScale: number;
  36123. /** @hidden */
  36124. _cachedMaterial: Nullable<Material>;
  36125. /** @hidden */
  36126. _cachedEffect: Nullable<Effect>;
  36127. /** @hidden */
  36128. _cachedVisibility: Nullable<number>;
  36129. private _renderId;
  36130. private _frameId;
  36131. private _executeWhenReadyTimeoutId;
  36132. private _intermediateRendering;
  36133. private _viewUpdateFlag;
  36134. private _projectionUpdateFlag;
  36135. /** @hidden */
  36136. _toBeDisposed: Nullable<IDisposable>[];
  36137. private _activeRequests;
  36138. /** @hidden */
  36139. _pendingData: any[];
  36140. private _isDisposed;
  36141. /**
  36142. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36143. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36144. */
  36145. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36146. private _activeMeshes;
  36147. private _processedMaterials;
  36148. private _renderTargets;
  36149. /** @hidden */
  36150. _activeParticleSystems: SmartArray<IParticleSystem>;
  36151. private _activeSkeletons;
  36152. private _softwareSkinnedMeshes;
  36153. private _renderingManager;
  36154. /** @hidden */
  36155. _activeAnimatables: Animatable[];
  36156. private _transformMatrix;
  36157. private _sceneUbo;
  36158. /** @hidden */
  36159. _viewMatrix: Matrix;
  36160. private _projectionMatrix;
  36161. /** @hidden */
  36162. _forcedViewPosition: Nullable<Vector3>;
  36163. /** @hidden */
  36164. _frustumPlanes: Plane[];
  36165. /**
  36166. * Gets the list of frustum planes (built from the active camera)
  36167. */
  36168. get frustumPlanes(): Plane[];
  36169. /**
  36170. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36171. * This is useful if there are more lights that the maximum simulteanous authorized
  36172. */
  36173. requireLightSorting: boolean;
  36174. /** @hidden */
  36175. readonly useMaterialMeshMap: boolean;
  36176. /** @hidden */
  36177. readonly useClonedMeshMap: boolean;
  36178. private _externalData;
  36179. private _uid;
  36180. /**
  36181. * @hidden
  36182. * Backing store of defined scene components.
  36183. */
  36184. _components: ISceneComponent[];
  36185. /**
  36186. * @hidden
  36187. * Backing store of defined scene components.
  36188. */
  36189. _serializableComponents: ISceneSerializableComponent[];
  36190. /**
  36191. * List of components to register on the next registration step.
  36192. */
  36193. private _transientComponents;
  36194. /**
  36195. * Registers the transient components if needed.
  36196. */
  36197. private _registerTransientComponents;
  36198. /**
  36199. * @hidden
  36200. * Add a component to the scene.
  36201. * Note that the ccomponent could be registered on th next frame if this is called after
  36202. * the register component stage.
  36203. * @param component Defines the component to add to the scene
  36204. */
  36205. _addComponent(component: ISceneComponent): void;
  36206. /**
  36207. * @hidden
  36208. * Gets a component from the scene.
  36209. * @param name defines the name of the component to retrieve
  36210. * @returns the component or null if not present
  36211. */
  36212. _getComponent(name: string): Nullable<ISceneComponent>;
  36213. /**
  36214. * @hidden
  36215. * Defines the actions happening before camera updates.
  36216. */
  36217. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36218. /**
  36219. * @hidden
  36220. * Defines the actions happening before clear the canvas.
  36221. */
  36222. _beforeClearStage: Stage<SimpleStageAction>;
  36223. /**
  36224. * @hidden
  36225. * Defines the actions when collecting render targets for the frame.
  36226. */
  36227. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36228. /**
  36229. * @hidden
  36230. * Defines the actions happening for one camera in the frame.
  36231. */
  36232. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36233. /**
  36234. * @hidden
  36235. * Defines the actions happening during the per mesh ready checks.
  36236. */
  36237. _isReadyForMeshStage: Stage<MeshStageAction>;
  36238. /**
  36239. * @hidden
  36240. * Defines the actions happening before evaluate active mesh checks.
  36241. */
  36242. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36243. /**
  36244. * @hidden
  36245. * Defines the actions happening during the evaluate sub mesh checks.
  36246. */
  36247. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36248. /**
  36249. * @hidden
  36250. * Defines the actions happening during the active mesh stage.
  36251. */
  36252. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36253. /**
  36254. * @hidden
  36255. * Defines the actions happening during the per camera render target step.
  36256. */
  36257. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36258. /**
  36259. * @hidden
  36260. * Defines the actions happening just before the active camera is drawing.
  36261. */
  36262. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36263. /**
  36264. * @hidden
  36265. * Defines the actions happening just before a render target is drawing.
  36266. */
  36267. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36268. /**
  36269. * @hidden
  36270. * Defines the actions happening just before a rendering group is drawing.
  36271. */
  36272. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36273. /**
  36274. * @hidden
  36275. * Defines the actions happening just before a mesh is drawing.
  36276. */
  36277. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36278. /**
  36279. * @hidden
  36280. * Defines the actions happening just after a mesh has been drawn.
  36281. */
  36282. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36283. /**
  36284. * @hidden
  36285. * Defines the actions happening just after a rendering group has been drawn.
  36286. */
  36287. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36288. /**
  36289. * @hidden
  36290. * Defines the actions happening just after the active camera has been drawn.
  36291. */
  36292. _afterCameraDrawStage: Stage<CameraStageAction>;
  36293. /**
  36294. * @hidden
  36295. * Defines the actions happening just after a render target has been drawn.
  36296. */
  36297. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36298. /**
  36299. * @hidden
  36300. * Defines the actions happening just after rendering all cameras and computing intersections.
  36301. */
  36302. _afterRenderStage: Stage<SimpleStageAction>;
  36303. /**
  36304. * @hidden
  36305. * Defines the actions happening when a pointer move event happens.
  36306. */
  36307. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36308. /**
  36309. * @hidden
  36310. * Defines the actions happening when a pointer down event happens.
  36311. */
  36312. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36313. /**
  36314. * @hidden
  36315. * Defines the actions happening when a pointer up event happens.
  36316. */
  36317. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36318. /**
  36319. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36320. */
  36321. private geometriesByUniqueId;
  36322. /**
  36323. * Creates a new Scene
  36324. * @param engine defines the engine to use to render this scene
  36325. * @param options defines the scene options
  36326. */
  36327. constructor(engine: Engine, options?: SceneOptions);
  36328. /**
  36329. * Gets a string idenfifying the name of the class
  36330. * @returns "Scene" string
  36331. */
  36332. getClassName(): string;
  36333. private _defaultMeshCandidates;
  36334. /**
  36335. * @hidden
  36336. */
  36337. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36338. private _defaultSubMeshCandidates;
  36339. /**
  36340. * @hidden
  36341. */
  36342. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36343. /**
  36344. * Sets the default candidate providers for the scene.
  36345. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36346. * and getCollidingSubMeshCandidates to their default function
  36347. */
  36348. setDefaultCandidateProviders(): void;
  36349. /**
  36350. * Gets the mesh that is currently under the pointer
  36351. */
  36352. get meshUnderPointer(): Nullable<AbstractMesh>;
  36353. /**
  36354. * Gets or sets the current on-screen X position of the pointer
  36355. */
  36356. get pointerX(): number;
  36357. set pointerX(value: number);
  36358. /**
  36359. * Gets or sets the current on-screen Y position of the pointer
  36360. */
  36361. get pointerY(): number;
  36362. set pointerY(value: number);
  36363. /**
  36364. * Gets the cached material (ie. the latest rendered one)
  36365. * @returns the cached material
  36366. */
  36367. getCachedMaterial(): Nullable<Material>;
  36368. /**
  36369. * Gets the cached effect (ie. the latest rendered one)
  36370. * @returns the cached effect
  36371. */
  36372. getCachedEffect(): Nullable<Effect>;
  36373. /**
  36374. * Gets the cached visibility state (ie. the latest rendered one)
  36375. * @returns the cached visibility state
  36376. */
  36377. getCachedVisibility(): Nullable<number>;
  36378. /**
  36379. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36380. * @param material defines the current material
  36381. * @param effect defines the current effect
  36382. * @param visibility defines the current visibility state
  36383. * @returns true if one parameter is not cached
  36384. */
  36385. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36386. /**
  36387. * Gets the engine associated with the scene
  36388. * @returns an Engine
  36389. */
  36390. getEngine(): Engine;
  36391. /**
  36392. * Gets the total number of vertices rendered per frame
  36393. * @returns the total number of vertices rendered per frame
  36394. */
  36395. getTotalVertices(): number;
  36396. /**
  36397. * Gets the performance counter for total vertices
  36398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36399. */
  36400. get totalVerticesPerfCounter(): PerfCounter;
  36401. /**
  36402. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36403. * @returns the total number of active indices rendered per frame
  36404. */
  36405. getActiveIndices(): number;
  36406. /**
  36407. * Gets the performance counter for active indices
  36408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36409. */
  36410. get totalActiveIndicesPerfCounter(): PerfCounter;
  36411. /**
  36412. * Gets the total number of active particles rendered per frame
  36413. * @returns the total number of active particles rendered per frame
  36414. */
  36415. getActiveParticles(): number;
  36416. /**
  36417. * Gets the performance counter for active particles
  36418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36419. */
  36420. get activeParticlesPerfCounter(): PerfCounter;
  36421. /**
  36422. * Gets the total number of active bones rendered per frame
  36423. * @returns the total number of active bones rendered per frame
  36424. */
  36425. getActiveBones(): number;
  36426. /**
  36427. * Gets the performance counter for active bones
  36428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36429. */
  36430. get activeBonesPerfCounter(): PerfCounter;
  36431. /**
  36432. * Gets the array of active meshes
  36433. * @returns an array of AbstractMesh
  36434. */
  36435. getActiveMeshes(): SmartArray<AbstractMesh>;
  36436. /**
  36437. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36438. * @returns a number
  36439. */
  36440. getAnimationRatio(): number;
  36441. /**
  36442. * Gets an unique Id for the current render phase
  36443. * @returns a number
  36444. */
  36445. getRenderId(): number;
  36446. /**
  36447. * Gets an unique Id for the current frame
  36448. * @returns a number
  36449. */
  36450. getFrameId(): number;
  36451. /** Call this function if you want to manually increment the render Id*/
  36452. incrementRenderId(): void;
  36453. private _createUbo;
  36454. /**
  36455. * Use this method to simulate a pointer move on a mesh
  36456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36459. * @returns the current scene
  36460. */
  36461. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36462. /**
  36463. * Use this method to simulate a pointer down on a mesh
  36464. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36465. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36466. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36467. * @returns the current scene
  36468. */
  36469. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36470. /**
  36471. * Use this method to simulate a pointer up on a mesh
  36472. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36473. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36474. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36475. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36476. * @returns the current scene
  36477. */
  36478. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36479. /**
  36480. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36481. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36482. * @returns true if the pointer was captured
  36483. */
  36484. isPointerCaptured(pointerId?: number): boolean;
  36485. /**
  36486. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36487. * @param attachUp defines if you want to attach events to pointerup
  36488. * @param attachDown defines if you want to attach events to pointerdown
  36489. * @param attachMove defines if you want to attach events to pointermove
  36490. */
  36491. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36492. /** Detaches all event handlers*/
  36493. detachControl(): void;
  36494. /**
  36495. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36496. * Delay loaded resources are not taking in account
  36497. * @return true if all required resources are ready
  36498. */
  36499. isReady(): boolean;
  36500. /** Resets all cached information relative to material (including effect and visibility) */
  36501. resetCachedMaterial(): void;
  36502. /**
  36503. * Registers a function to be called before every frame render
  36504. * @param func defines the function to register
  36505. */
  36506. registerBeforeRender(func: () => void): void;
  36507. /**
  36508. * Unregisters a function called before every frame render
  36509. * @param func defines the function to unregister
  36510. */
  36511. unregisterBeforeRender(func: () => void): void;
  36512. /**
  36513. * Registers a function to be called after every frame render
  36514. * @param func defines the function to register
  36515. */
  36516. registerAfterRender(func: () => void): void;
  36517. /**
  36518. * Unregisters a function called after every frame render
  36519. * @param func defines the function to unregister
  36520. */
  36521. unregisterAfterRender(func: () => void): void;
  36522. private _executeOnceBeforeRender;
  36523. /**
  36524. * The provided function will run before render once and will be disposed afterwards.
  36525. * A timeout delay can be provided so that the function will be executed in N ms.
  36526. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36527. * @param func The function to be executed.
  36528. * @param timeout optional delay in ms
  36529. */
  36530. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36531. /** @hidden */
  36532. _addPendingData(data: any): void;
  36533. /** @hidden */
  36534. _removePendingData(data: any): void;
  36535. /**
  36536. * Returns the number of items waiting to be loaded
  36537. * @returns the number of items waiting to be loaded
  36538. */
  36539. getWaitingItemsCount(): number;
  36540. /**
  36541. * Returns a boolean indicating if the scene is still loading data
  36542. */
  36543. get isLoading(): boolean;
  36544. /**
  36545. * Registers a function to be executed when the scene is ready
  36546. * @param {Function} func - the function to be executed
  36547. */
  36548. executeWhenReady(func: () => void): void;
  36549. /**
  36550. * Returns a promise that resolves when the scene is ready
  36551. * @returns A promise that resolves when the scene is ready
  36552. */
  36553. whenReadyAsync(): Promise<void>;
  36554. /** @hidden */
  36555. _checkIsReady(): void;
  36556. /**
  36557. * Gets all animatable attached to the scene
  36558. */
  36559. get animatables(): Animatable[];
  36560. /**
  36561. * Resets the last animation time frame.
  36562. * Useful to override when animations start running when loading a scene for the first time.
  36563. */
  36564. resetLastAnimationTimeFrame(): void;
  36565. /**
  36566. * Gets the current view matrix
  36567. * @returns a Matrix
  36568. */
  36569. getViewMatrix(): Matrix;
  36570. /**
  36571. * Gets the current projection matrix
  36572. * @returns a Matrix
  36573. */
  36574. getProjectionMatrix(): Matrix;
  36575. /**
  36576. * Gets the current transform matrix
  36577. * @returns a Matrix made of View * Projection
  36578. */
  36579. getTransformMatrix(): Matrix;
  36580. /**
  36581. * Sets the current transform matrix
  36582. * @param viewL defines the View matrix to use
  36583. * @param projectionL defines the Projection matrix to use
  36584. * @param viewR defines the right View matrix to use (if provided)
  36585. * @param projectionR defines the right Projection matrix to use (if provided)
  36586. */
  36587. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36588. /**
  36589. * Gets the uniform buffer used to store scene data
  36590. * @returns a UniformBuffer
  36591. */
  36592. getSceneUniformBuffer(): UniformBuffer;
  36593. /**
  36594. * Gets an unique (relatively to the current scene) Id
  36595. * @returns an unique number for the scene
  36596. */
  36597. getUniqueId(): number;
  36598. /**
  36599. * Add a mesh to the list of scene's meshes
  36600. * @param newMesh defines the mesh to add
  36601. * @param recursive if all child meshes should also be added to the scene
  36602. */
  36603. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36604. /**
  36605. * Remove a mesh for the list of scene's meshes
  36606. * @param toRemove defines the mesh to remove
  36607. * @param recursive if all child meshes should also be removed from the scene
  36608. * @returns the index where the mesh was in the mesh list
  36609. */
  36610. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36611. /**
  36612. * Add a transform node to the list of scene's transform nodes
  36613. * @param newTransformNode defines the transform node to add
  36614. */
  36615. addTransformNode(newTransformNode: TransformNode): void;
  36616. /**
  36617. * Remove a transform node for the list of scene's transform nodes
  36618. * @param toRemove defines the transform node to remove
  36619. * @returns the index where the transform node was in the transform node list
  36620. */
  36621. removeTransformNode(toRemove: TransformNode): number;
  36622. /**
  36623. * Remove a skeleton for the list of scene's skeletons
  36624. * @param toRemove defines the skeleton to remove
  36625. * @returns the index where the skeleton was in the skeleton list
  36626. */
  36627. removeSkeleton(toRemove: Skeleton): number;
  36628. /**
  36629. * Remove a morph target for the list of scene's morph targets
  36630. * @param toRemove defines the morph target to remove
  36631. * @returns the index where the morph target was in the morph target list
  36632. */
  36633. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36634. /**
  36635. * Remove a light for the list of scene's lights
  36636. * @param toRemove defines the light to remove
  36637. * @returns the index where the light was in the light list
  36638. */
  36639. removeLight(toRemove: Light): number;
  36640. /**
  36641. * Remove a camera for the list of scene's cameras
  36642. * @param toRemove defines the camera to remove
  36643. * @returns the index where the camera was in the camera list
  36644. */
  36645. removeCamera(toRemove: Camera): number;
  36646. /**
  36647. * Remove a particle system for the list of scene's particle systems
  36648. * @param toRemove defines the particle system to remove
  36649. * @returns the index where the particle system was in the particle system list
  36650. */
  36651. removeParticleSystem(toRemove: IParticleSystem): number;
  36652. /**
  36653. * Remove a animation for the list of scene's animations
  36654. * @param toRemove defines the animation to remove
  36655. * @returns the index where the animation was in the animation list
  36656. */
  36657. removeAnimation(toRemove: Animation): number;
  36658. /**
  36659. * Will stop the animation of the given target
  36660. * @param target - the target
  36661. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36662. * @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)
  36663. */
  36664. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36665. /**
  36666. * Removes the given animation group from this scene.
  36667. * @param toRemove The animation group to remove
  36668. * @returns The index of the removed animation group
  36669. */
  36670. removeAnimationGroup(toRemove: AnimationGroup): number;
  36671. /**
  36672. * Removes the given multi-material from this scene.
  36673. * @param toRemove The multi-material to remove
  36674. * @returns The index of the removed multi-material
  36675. */
  36676. removeMultiMaterial(toRemove: MultiMaterial): number;
  36677. /**
  36678. * Removes the given material from this scene.
  36679. * @param toRemove The material to remove
  36680. * @returns The index of the removed material
  36681. */
  36682. removeMaterial(toRemove: Material): number;
  36683. /**
  36684. * Removes the given action manager from this scene.
  36685. * @param toRemove The action manager to remove
  36686. * @returns The index of the removed action manager
  36687. */
  36688. removeActionManager(toRemove: AbstractActionManager): number;
  36689. /**
  36690. * Removes the given texture from this scene.
  36691. * @param toRemove The texture to remove
  36692. * @returns The index of the removed texture
  36693. */
  36694. removeTexture(toRemove: BaseTexture): number;
  36695. /**
  36696. * Adds the given light to this scene
  36697. * @param newLight The light to add
  36698. */
  36699. addLight(newLight: Light): void;
  36700. /**
  36701. * Sorts the list list based on light priorities
  36702. */
  36703. sortLightsByPriority(): void;
  36704. /**
  36705. * Adds the given camera to this scene
  36706. * @param newCamera The camera to add
  36707. */
  36708. addCamera(newCamera: Camera): void;
  36709. /**
  36710. * Adds the given skeleton to this scene
  36711. * @param newSkeleton The skeleton to add
  36712. */
  36713. addSkeleton(newSkeleton: Skeleton): void;
  36714. /**
  36715. * Adds the given particle system to this scene
  36716. * @param newParticleSystem The particle system to add
  36717. */
  36718. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36719. /**
  36720. * Adds the given animation to this scene
  36721. * @param newAnimation The animation to add
  36722. */
  36723. addAnimation(newAnimation: Animation): void;
  36724. /**
  36725. * Adds the given animation group to this scene.
  36726. * @param newAnimationGroup The animation group to add
  36727. */
  36728. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36729. /**
  36730. * Adds the given multi-material to this scene
  36731. * @param newMultiMaterial The multi-material to add
  36732. */
  36733. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36734. /**
  36735. * Adds the given material to this scene
  36736. * @param newMaterial The material to add
  36737. */
  36738. addMaterial(newMaterial: Material): void;
  36739. /**
  36740. * Adds the given morph target to this scene
  36741. * @param newMorphTargetManager The morph target to add
  36742. */
  36743. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36744. /**
  36745. * Adds the given geometry to this scene
  36746. * @param newGeometry The geometry to add
  36747. */
  36748. addGeometry(newGeometry: Geometry): void;
  36749. /**
  36750. * Adds the given action manager to this scene
  36751. * @param newActionManager The action manager to add
  36752. */
  36753. addActionManager(newActionManager: AbstractActionManager): void;
  36754. /**
  36755. * Adds the given texture to this scene.
  36756. * @param newTexture The texture to add
  36757. */
  36758. addTexture(newTexture: BaseTexture): void;
  36759. /**
  36760. * Switch active camera
  36761. * @param newCamera defines the new active camera
  36762. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36763. */
  36764. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36765. /**
  36766. * sets the active camera of the scene using its ID
  36767. * @param id defines the camera's ID
  36768. * @return the new active camera or null if none found.
  36769. */
  36770. setActiveCameraByID(id: string): Nullable<Camera>;
  36771. /**
  36772. * sets the active camera of the scene using its name
  36773. * @param name defines the camera's name
  36774. * @returns the new active camera or null if none found.
  36775. */
  36776. setActiveCameraByName(name: string): Nullable<Camera>;
  36777. /**
  36778. * get an animation group using its name
  36779. * @param name defines the material's name
  36780. * @return the animation group or null if none found.
  36781. */
  36782. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36783. /**
  36784. * Get a material using its unique id
  36785. * @param uniqueId defines the material's unique id
  36786. * @return the material or null if none found.
  36787. */
  36788. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36789. /**
  36790. * get a material using its id
  36791. * @param id defines the material's ID
  36792. * @return the material or null if none found.
  36793. */
  36794. getMaterialByID(id: string): Nullable<Material>;
  36795. /**
  36796. * Gets a the last added material using a given id
  36797. * @param id defines the material's ID
  36798. * @return the last material with the given id or null if none found.
  36799. */
  36800. getLastMaterialByID(id: string): Nullable<Material>;
  36801. /**
  36802. * Gets a material using its name
  36803. * @param name defines the material's name
  36804. * @return the material or null if none found.
  36805. */
  36806. getMaterialByName(name: string): Nullable<Material>;
  36807. /**
  36808. * Get a texture using its unique id
  36809. * @param uniqueId defines the texture's unique id
  36810. * @return the texture or null if none found.
  36811. */
  36812. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36813. /**
  36814. * Gets a camera using its id
  36815. * @param id defines the id to look for
  36816. * @returns the camera or null if not found
  36817. */
  36818. getCameraByID(id: string): Nullable<Camera>;
  36819. /**
  36820. * Gets a camera using its unique id
  36821. * @param uniqueId defines the unique id to look for
  36822. * @returns the camera or null if not found
  36823. */
  36824. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36825. /**
  36826. * Gets a camera using its name
  36827. * @param name defines the camera's name
  36828. * @return the camera or null if none found.
  36829. */
  36830. getCameraByName(name: string): Nullable<Camera>;
  36831. /**
  36832. * Gets a bone using its id
  36833. * @param id defines the bone's id
  36834. * @return the bone or null if not found
  36835. */
  36836. getBoneByID(id: string): Nullable<Bone>;
  36837. /**
  36838. * Gets a bone using its id
  36839. * @param name defines the bone's name
  36840. * @return the bone or null if not found
  36841. */
  36842. getBoneByName(name: string): Nullable<Bone>;
  36843. /**
  36844. * Gets a light node using its name
  36845. * @param name defines the the light's name
  36846. * @return the light or null if none found.
  36847. */
  36848. getLightByName(name: string): Nullable<Light>;
  36849. /**
  36850. * Gets a light node using its id
  36851. * @param id defines the light's id
  36852. * @return the light or null if none found.
  36853. */
  36854. getLightByID(id: string): Nullable<Light>;
  36855. /**
  36856. * Gets a light node using its scene-generated unique ID
  36857. * @param uniqueId defines the light's unique id
  36858. * @return the light or null if none found.
  36859. */
  36860. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36861. /**
  36862. * Gets a particle system by id
  36863. * @param id defines the particle system id
  36864. * @return the corresponding system or null if none found
  36865. */
  36866. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36867. /**
  36868. * Gets a geometry using its ID
  36869. * @param id defines the geometry's id
  36870. * @return the geometry or null if none found.
  36871. */
  36872. getGeometryByID(id: string): Nullable<Geometry>;
  36873. private _getGeometryByUniqueID;
  36874. /**
  36875. * Add a new geometry to this scene
  36876. * @param geometry defines the geometry to be added to the scene.
  36877. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36878. * @return a boolean defining if the geometry was added or not
  36879. */
  36880. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36881. /**
  36882. * Removes an existing geometry
  36883. * @param geometry defines the geometry to be removed from the scene
  36884. * @return a boolean defining if the geometry was removed or not
  36885. */
  36886. removeGeometry(geometry: Geometry): boolean;
  36887. /**
  36888. * Gets the list of geometries attached to the scene
  36889. * @returns an array of Geometry
  36890. */
  36891. getGeometries(): Geometry[];
  36892. /**
  36893. * Gets the first added mesh found of a given ID
  36894. * @param id defines the id to search for
  36895. * @return the mesh found or null if not found at all
  36896. */
  36897. getMeshByID(id: string): Nullable<AbstractMesh>;
  36898. /**
  36899. * Gets a list of meshes using their id
  36900. * @param id defines the id to search for
  36901. * @returns a list of meshes
  36902. */
  36903. getMeshesByID(id: string): Array<AbstractMesh>;
  36904. /**
  36905. * Gets the first added transform node found of a given ID
  36906. * @param id defines the id to search for
  36907. * @return the found transform node or null if not found at all.
  36908. */
  36909. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36910. /**
  36911. * Gets a transform node with its auto-generated unique id
  36912. * @param uniqueId efines the unique id to search for
  36913. * @return the found transform node or null if not found at all.
  36914. */
  36915. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36916. /**
  36917. * Gets a list of transform nodes using their id
  36918. * @param id defines the id to search for
  36919. * @returns a list of transform nodes
  36920. */
  36921. getTransformNodesByID(id: string): Array<TransformNode>;
  36922. /**
  36923. * Gets a mesh with its auto-generated unique id
  36924. * @param uniqueId defines the unique id to search for
  36925. * @return the found mesh or null if not found at all.
  36926. */
  36927. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36928. /**
  36929. * Gets a the last added mesh using a given id
  36930. * @param id defines the id to search for
  36931. * @return the found mesh or null if not found at all.
  36932. */
  36933. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36934. /**
  36935. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36936. * @param id defines the id to search for
  36937. * @return the found node or null if not found at all
  36938. */
  36939. getLastEntryByID(id: string): Nullable<Node>;
  36940. /**
  36941. * Gets a node (Mesh, Camera, Light) using a given id
  36942. * @param id defines the id to search for
  36943. * @return the found node or null if not found at all
  36944. */
  36945. getNodeByID(id: string): Nullable<Node>;
  36946. /**
  36947. * Gets a node (Mesh, Camera, Light) using a given name
  36948. * @param name defines the name to search for
  36949. * @return the found node or null if not found at all.
  36950. */
  36951. getNodeByName(name: string): Nullable<Node>;
  36952. /**
  36953. * Gets a mesh using a given name
  36954. * @param name defines the name to search for
  36955. * @return the found mesh or null if not found at all.
  36956. */
  36957. getMeshByName(name: string): Nullable<AbstractMesh>;
  36958. /**
  36959. * Gets a transform node using a given name
  36960. * @param name defines the name to search for
  36961. * @return the found transform node or null if not found at all.
  36962. */
  36963. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36964. /**
  36965. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36966. * @param id defines the id to search for
  36967. * @return the found skeleton or null if not found at all.
  36968. */
  36969. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36970. /**
  36971. * Gets a skeleton using a given auto generated unique id
  36972. * @param uniqueId defines the unique id to search for
  36973. * @return the found skeleton or null if not found at all.
  36974. */
  36975. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36976. /**
  36977. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36978. * @param id defines the id to search for
  36979. * @return the found skeleton or null if not found at all.
  36980. */
  36981. getSkeletonById(id: string): Nullable<Skeleton>;
  36982. /**
  36983. * Gets a skeleton using a given name
  36984. * @param name defines the name to search for
  36985. * @return the found skeleton or null if not found at all.
  36986. */
  36987. getSkeletonByName(name: string): Nullable<Skeleton>;
  36988. /**
  36989. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36990. * @param id defines the id to search for
  36991. * @return the found morph target manager or null if not found at all.
  36992. */
  36993. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36994. /**
  36995. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36996. * @param id defines the id to search for
  36997. * @return the found morph target or null if not found at all.
  36998. */
  36999. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37000. /**
  37001. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37002. * @param name defines the name to search for
  37003. * @return the found morph target or null if not found at all.
  37004. */
  37005. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37006. /**
  37007. * Gets a boolean indicating if the given mesh is active
  37008. * @param mesh defines the mesh to look for
  37009. * @returns true if the mesh is in the active list
  37010. */
  37011. isActiveMesh(mesh: AbstractMesh): boolean;
  37012. /**
  37013. * Return a unique id as a string which can serve as an identifier for the scene
  37014. */
  37015. get uid(): string;
  37016. /**
  37017. * Add an externaly attached data from its key.
  37018. * This method call will fail and return false, if such key already exists.
  37019. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37020. * @param key the unique key that identifies the data
  37021. * @param data the data object to associate to the key for this Engine instance
  37022. * @return true if no such key were already present and the data was added successfully, false otherwise
  37023. */
  37024. addExternalData<T>(key: string, data: T): boolean;
  37025. /**
  37026. * Get an externaly attached data from its key
  37027. * @param key the unique key that identifies the data
  37028. * @return the associated data, if present (can be null), or undefined if not present
  37029. */
  37030. getExternalData<T>(key: string): Nullable<T>;
  37031. /**
  37032. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37033. * @param key the unique key that identifies the data
  37034. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37035. * @return the associated data, can be null if the factory returned null.
  37036. */
  37037. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37038. /**
  37039. * Remove an externaly attached data from the Engine instance
  37040. * @param key the unique key that identifies the data
  37041. * @return true if the data was successfully removed, false if it doesn't exist
  37042. */
  37043. removeExternalData(key: string): boolean;
  37044. private _evaluateSubMesh;
  37045. /**
  37046. * Clear the processed materials smart array preventing retention point in material dispose.
  37047. */
  37048. freeProcessedMaterials(): void;
  37049. private _preventFreeActiveMeshesAndRenderingGroups;
  37050. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37051. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37052. * when disposing several meshes in a row or a hierarchy of meshes.
  37053. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37054. */
  37055. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37056. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37057. /**
  37058. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37059. */
  37060. freeActiveMeshes(): void;
  37061. /**
  37062. * Clear the info related to rendering groups preventing retention points during dispose.
  37063. */
  37064. freeRenderingGroups(): void;
  37065. /** @hidden */
  37066. _isInIntermediateRendering(): boolean;
  37067. /**
  37068. * Lambda returning the list of potentially active meshes.
  37069. */
  37070. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37071. /**
  37072. * Lambda returning the list of potentially active sub meshes.
  37073. */
  37074. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37075. /**
  37076. * Lambda returning the list of potentially intersecting sub meshes.
  37077. */
  37078. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37079. /**
  37080. * Lambda returning the list of potentially colliding sub meshes.
  37081. */
  37082. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37083. private _activeMeshesFrozen;
  37084. private _skipEvaluateActiveMeshesCompletely;
  37085. /**
  37086. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37087. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37088. * @returns the current scene
  37089. */
  37090. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37091. /**
  37092. * Use this function to restart evaluating active meshes on every frame
  37093. * @returns the current scene
  37094. */
  37095. unfreezeActiveMeshes(): Scene;
  37096. private _evaluateActiveMeshes;
  37097. private _activeMesh;
  37098. /**
  37099. * Update the transform matrix to update from the current active camera
  37100. * @param force defines a boolean used to force the update even if cache is up to date
  37101. */
  37102. updateTransformMatrix(force?: boolean): void;
  37103. private _bindFrameBuffer;
  37104. /** @hidden */
  37105. _allowPostProcessClearColor: boolean;
  37106. /** @hidden */
  37107. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37108. private _processSubCameras;
  37109. private _checkIntersections;
  37110. /** @hidden */
  37111. _advancePhysicsEngineStep(step: number): void;
  37112. /**
  37113. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37114. */
  37115. getDeterministicFrameTime: () => number;
  37116. /** @hidden */
  37117. _animate(): void;
  37118. /** Execute all animations (for a frame) */
  37119. animate(): void;
  37120. /**
  37121. * Render the scene
  37122. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37123. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37124. */
  37125. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37126. /**
  37127. * Freeze all materials
  37128. * A frozen material will not be updatable but should be faster to render
  37129. */
  37130. freezeMaterials(): void;
  37131. /**
  37132. * Unfreeze all materials
  37133. * A frozen material will not be updatable but should be faster to render
  37134. */
  37135. unfreezeMaterials(): void;
  37136. /**
  37137. * Releases all held ressources
  37138. */
  37139. dispose(): void;
  37140. /**
  37141. * Gets if the scene is already disposed
  37142. */
  37143. get isDisposed(): boolean;
  37144. /**
  37145. * Call this function to reduce memory footprint of the scene.
  37146. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37147. */
  37148. clearCachedVertexData(): void;
  37149. /**
  37150. * This function will remove the local cached buffer data from texture.
  37151. * It will save memory but will prevent the texture from being rebuilt
  37152. */
  37153. cleanCachedTextureBuffer(): void;
  37154. /**
  37155. * Get the world extend vectors with an optional filter
  37156. *
  37157. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37158. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37159. */
  37160. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37161. min: Vector3;
  37162. max: Vector3;
  37163. };
  37164. /**
  37165. * Creates a ray that can be used to pick in the scene
  37166. * @param x defines the x coordinate of the origin (on-screen)
  37167. * @param y defines the y coordinate of the origin (on-screen)
  37168. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37169. * @param camera defines the camera to use for the picking
  37170. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37171. * @returns a Ray
  37172. */
  37173. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37174. /**
  37175. * Creates a ray that can be used to pick in the scene
  37176. * @param x defines the x coordinate of the origin (on-screen)
  37177. * @param y defines the y coordinate of the origin (on-screen)
  37178. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37179. * @param result defines the ray where to store the picking ray
  37180. * @param camera defines the camera to use for the picking
  37181. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37182. * @returns the current scene
  37183. */
  37184. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37185. /**
  37186. * Creates a ray that can be used to pick in the scene
  37187. * @param x defines the x coordinate of the origin (on-screen)
  37188. * @param y defines the y coordinate of the origin (on-screen)
  37189. * @param camera defines the camera to use for the picking
  37190. * @returns a Ray
  37191. */
  37192. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37193. /**
  37194. * Creates a ray that can be used to pick in the scene
  37195. * @param x defines the x coordinate of the origin (on-screen)
  37196. * @param y defines the y coordinate of the origin (on-screen)
  37197. * @param result defines the ray where to store the picking ray
  37198. * @param camera defines the camera to use for the picking
  37199. * @returns the current scene
  37200. */
  37201. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37202. /** Launch a ray to try to pick a mesh in the scene
  37203. * @param x position on screen
  37204. * @param y position on screen
  37205. * @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
  37206. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37207. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37208. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37209. * @returns a PickingInfo
  37210. */
  37211. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37212. /** Use the given ray to pick a mesh in the scene
  37213. * @param ray The ray to use to pick meshes
  37214. * @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
  37215. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37216. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37217. * @returns a PickingInfo
  37218. */
  37219. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37220. /**
  37221. * Launch a ray to try to pick a mesh in the scene
  37222. * @param x X position on screen
  37223. * @param y Y position on screen
  37224. * @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
  37225. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37226. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37227. * @returns an array of PickingInfo
  37228. */
  37229. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37230. /**
  37231. * Launch a ray to try to pick a mesh in the scene
  37232. * @param ray Ray to use
  37233. * @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
  37234. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37235. * @returns an array of PickingInfo
  37236. */
  37237. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37238. /**
  37239. * Force the value of meshUnderPointer
  37240. * @param mesh defines the mesh to use
  37241. */
  37242. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37243. /**
  37244. * Gets the mesh under the pointer
  37245. * @returns a Mesh or null if no mesh is under the pointer
  37246. */
  37247. getPointerOverMesh(): Nullable<AbstractMesh>;
  37248. /** @hidden */
  37249. _rebuildGeometries(): void;
  37250. /** @hidden */
  37251. _rebuildTextures(): void;
  37252. private _getByTags;
  37253. /**
  37254. * Get a list of meshes by tags
  37255. * @param tagsQuery defines the tags query to use
  37256. * @param forEach defines a predicate used to filter results
  37257. * @returns an array of Mesh
  37258. */
  37259. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37260. /**
  37261. * Get a list of cameras by tags
  37262. * @param tagsQuery defines the tags query to use
  37263. * @param forEach defines a predicate used to filter results
  37264. * @returns an array of Camera
  37265. */
  37266. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37267. /**
  37268. * Get a list of lights by tags
  37269. * @param tagsQuery defines the tags query to use
  37270. * @param forEach defines a predicate used to filter results
  37271. * @returns an array of Light
  37272. */
  37273. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37274. /**
  37275. * Get a list of materials by tags
  37276. * @param tagsQuery defines the tags query to use
  37277. * @param forEach defines a predicate used to filter results
  37278. * @returns an array of Material
  37279. */
  37280. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37281. /**
  37282. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37283. * This allowed control for front to back rendering or reversly depending of the special needs.
  37284. *
  37285. * @param renderingGroupId The rendering group id corresponding to its index
  37286. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37287. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37288. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37289. */
  37290. 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;
  37291. /**
  37292. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37293. *
  37294. * @param renderingGroupId The rendering group id corresponding to its index
  37295. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37296. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37297. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37298. */
  37299. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37300. /**
  37301. * Gets the current auto clear configuration for one rendering group of the rendering
  37302. * manager.
  37303. * @param index the rendering group index to get the information for
  37304. * @returns The auto clear setup for the requested rendering group
  37305. */
  37306. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37307. private _blockMaterialDirtyMechanism;
  37308. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37309. get blockMaterialDirtyMechanism(): boolean;
  37310. set blockMaterialDirtyMechanism(value: boolean);
  37311. /**
  37312. * Will flag all materials as dirty to trigger new shader compilation
  37313. * @param flag defines the flag used to specify which material part must be marked as dirty
  37314. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37315. */
  37316. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37317. /** @hidden */
  37318. _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;
  37319. /** @hidden */
  37320. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37321. /** @hidden */
  37322. _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;
  37323. /** @hidden */
  37324. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37325. /** @hidden */
  37326. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37327. /** @hidden */
  37328. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37329. }
  37330. }
  37331. declare module BABYLON {
  37332. /**
  37333. * Set of assets to keep when moving a scene into an asset container.
  37334. */
  37335. export class KeepAssets extends AbstractScene {
  37336. }
  37337. /**
  37338. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37339. */
  37340. export class InstantiatedEntries {
  37341. /**
  37342. * List of new root nodes (eg. nodes with no parent)
  37343. */
  37344. rootNodes: TransformNode[];
  37345. /**
  37346. * List of new skeletons
  37347. */
  37348. skeletons: Skeleton[];
  37349. /**
  37350. * List of new animation groups
  37351. */
  37352. animationGroups: AnimationGroup[];
  37353. }
  37354. /**
  37355. * Container with a set of assets that can be added or removed from a scene.
  37356. */
  37357. export class AssetContainer extends AbstractScene {
  37358. private _wasAddedToScene;
  37359. /**
  37360. * The scene the AssetContainer belongs to.
  37361. */
  37362. scene: Scene;
  37363. /**
  37364. * Instantiates an AssetContainer.
  37365. * @param scene The scene the AssetContainer belongs to.
  37366. */
  37367. constructor(scene: Scene);
  37368. /**
  37369. * Instantiate or clone all meshes and add the new ones to the scene.
  37370. * Skeletons and animation groups will all be cloned
  37371. * @param nameFunction defines an optional function used to get new names for clones
  37372. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37373. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37374. */
  37375. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37376. /**
  37377. * Adds all the assets from the container to the scene.
  37378. */
  37379. addAllToScene(): void;
  37380. /**
  37381. * Removes all the assets in the container from the scene
  37382. */
  37383. removeAllFromScene(): void;
  37384. /**
  37385. * Disposes all the assets in the container
  37386. */
  37387. dispose(): void;
  37388. private _moveAssets;
  37389. /**
  37390. * Removes all the assets contained in the scene and adds them to the container.
  37391. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37392. */
  37393. moveAllFromScene(keepAssets?: KeepAssets): void;
  37394. /**
  37395. * 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.
  37396. * @returns the root mesh
  37397. */
  37398. createRootMesh(): Mesh;
  37399. /**
  37400. * Merge animations from this asset container into a scene
  37401. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37402. * @param animatables set of animatables to retarget to a node from the scene
  37403. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37404. */
  37405. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37406. }
  37407. }
  37408. declare module BABYLON {
  37409. /**
  37410. * Defines how the parser contract is defined.
  37411. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37412. */
  37413. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37414. /**
  37415. * Defines how the individual parser contract is defined.
  37416. * These parser can parse an individual asset
  37417. */
  37418. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37419. /**
  37420. * Base class of the scene acting as a container for the different elements composing a scene.
  37421. * This class is dynamically extended by the different components of the scene increasing
  37422. * flexibility and reducing coupling
  37423. */
  37424. export abstract class AbstractScene {
  37425. /**
  37426. * Stores the list of available parsers in the application.
  37427. */
  37428. private static _BabylonFileParsers;
  37429. /**
  37430. * Stores the list of available individual parsers in the application.
  37431. */
  37432. private static _IndividualBabylonFileParsers;
  37433. /**
  37434. * Adds a parser in the list of available ones
  37435. * @param name Defines the name of the parser
  37436. * @param parser Defines the parser to add
  37437. */
  37438. static AddParser(name: string, parser: BabylonFileParser): void;
  37439. /**
  37440. * Gets a general parser from the list of avaialble ones
  37441. * @param name Defines the name of the parser
  37442. * @returns the requested parser or null
  37443. */
  37444. static GetParser(name: string): Nullable<BabylonFileParser>;
  37445. /**
  37446. * Adds n individual parser in the list of available ones
  37447. * @param name Defines the name of the parser
  37448. * @param parser Defines the parser to add
  37449. */
  37450. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37451. /**
  37452. * Gets an individual parser from the list of avaialble ones
  37453. * @param name Defines the name of the parser
  37454. * @returns the requested parser or null
  37455. */
  37456. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37457. /**
  37458. * Parser json data and populate both a scene and its associated container object
  37459. * @param jsonData Defines the data to parse
  37460. * @param scene Defines the scene to parse the data for
  37461. * @param container Defines the container attached to the parsing sequence
  37462. * @param rootUrl Defines the root url of the data
  37463. */
  37464. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37465. /**
  37466. * Gets the list of root nodes (ie. nodes with no parent)
  37467. */
  37468. rootNodes: Node[];
  37469. /** All of the cameras added to this scene
  37470. * @see http://doc.babylonjs.com/babylon101/cameras
  37471. */
  37472. cameras: Camera[];
  37473. /**
  37474. * All of the lights added to this scene
  37475. * @see http://doc.babylonjs.com/babylon101/lights
  37476. */
  37477. lights: Light[];
  37478. /**
  37479. * All of the (abstract) meshes added to this scene
  37480. */
  37481. meshes: AbstractMesh[];
  37482. /**
  37483. * The list of skeletons added to the scene
  37484. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37485. */
  37486. skeletons: Skeleton[];
  37487. /**
  37488. * All of the particle systems added to this scene
  37489. * @see http://doc.babylonjs.com/babylon101/particles
  37490. */
  37491. particleSystems: IParticleSystem[];
  37492. /**
  37493. * Gets a list of Animations associated with the scene
  37494. */
  37495. animations: Animation[];
  37496. /**
  37497. * All of the animation groups added to this scene
  37498. * @see http://doc.babylonjs.com/how_to/group
  37499. */
  37500. animationGroups: AnimationGroup[];
  37501. /**
  37502. * All of the multi-materials added to this scene
  37503. * @see http://doc.babylonjs.com/how_to/multi_materials
  37504. */
  37505. multiMaterials: MultiMaterial[];
  37506. /**
  37507. * All of the materials added to this scene
  37508. * In the context of a Scene, it is not supposed to be modified manually.
  37509. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37510. * Note also that the order of the Material within the array is not significant and might change.
  37511. * @see http://doc.babylonjs.com/babylon101/materials
  37512. */
  37513. materials: Material[];
  37514. /**
  37515. * The list of morph target managers added to the scene
  37516. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37517. */
  37518. morphTargetManagers: MorphTargetManager[];
  37519. /**
  37520. * The list of geometries used in the scene.
  37521. */
  37522. geometries: Geometry[];
  37523. /**
  37524. * All of the tranform nodes added to this scene
  37525. * In the context of a Scene, it is not supposed to be modified manually.
  37526. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37527. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37528. * @see http://doc.babylonjs.com/how_to/transformnode
  37529. */
  37530. transformNodes: TransformNode[];
  37531. /**
  37532. * ActionManagers available on the scene.
  37533. */
  37534. actionManagers: AbstractActionManager[];
  37535. /**
  37536. * Textures to keep.
  37537. */
  37538. textures: BaseTexture[];
  37539. /**
  37540. * Environment texture for the scene
  37541. */
  37542. environmentTexture: Nullable<BaseTexture>;
  37543. /**
  37544. * @returns all meshes, lights, cameras, transformNodes and bones
  37545. */
  37546. getNodes(): Array<Node>;
  37547. }
  37548. }
  37549. declare module BABYLON {
  37550. /**
  37551. * Interface used to define options for Sound class
  37552. */
  37553. export interface ISoundOptions {
  37554. /**
  37555. * Does the sound autoplay once loaded.
  37556. */
  37557. autoplay?: boolean;
  37558. /**
  37559. * Does the sound loop after it finishes playing once.
  37560. */
  37561. loop?: boolean;
  37562. /**
  37563. * Sound's volume
  37564. */
  37565. volume?: number;
  37566. /**
  37567. * Is it a spatial sound?
  37568. */
  37569. spatialSound?: boolean;
  37570. /**
  37571. * Maximum distance to hear that sound
  37572. */
  37573. maxDistance?: number;
  37574. /**
  37575. * Uses user defined attenuation function
  37576. */
  37577. useCustomAttenuation?: boolean;
  37578. /**
  37579. * Define the roll off factor of spatial sounds.
  37580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37581. */
  37582. rolloffFactor?: number;
  37583. /**
  37584. * Define the reference distance the sound should be heard perfectly.
  37585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37586. */
  37587. refDistance?: number;
  37588. /**
  37589. * Define the distance attenuation model the sound will follow.
  37590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37591. */
  37592. distanceModel?: string;
  37593. /**
  37594. * Defines the playback speed (1 by default)
  37595. */
  37596. playbackRate?: number;
  37597. /**
  37598. * Defines if the sound is from a streaming source
  37599. */
  37600. streaming?: boolean;
  37601. /**
  37602. * Defines an optional length (in seconds) inside the sound file
  37603. */
  37604. length?: number;
  37605. /**
  37606. * Defines an optional offset (in seconds) inside the sound file
  37607. */
  37608. offset?: number;
  37609. /**
  37610. * If true, URLs will not be required to state the audio file codec to use.
  37611. */
  37612. skipCodecCheck?: boolean;
  37613. }
  37614. /**
  37615. * Defines a sound that can be played in the application.
  37616. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37618. */
  37619. export class Sound {
  37620. /**
  37621. * The name of the sound in the scene.
  37622. */
  37623. name: string;
  37624. /**
  37625. * Does the sound autoplay once loaded.
  37626. */
  37627. autoplay: boolean;
  37628. /**
  37629. * Does the sound loop after it finishes playing once.
  37630. */
  37631. loop: boolean;
  37632. /**
  37633. * Does the sound use a custom attenuation curve to simulate the falloff
  37634. * happening when the source gets further away from the camera.
  37635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37636. */
  37637. useCustomAttenuation: boolean;
  37638. /**
  37639. * The sound track id this sound belongs to.
  37640. */
  37641. soundTrackId: number;
  37642. /**
  37643. * Is this sound currently played.
  37644. */
  37645. isPlaying: boolean;
  37646. /**
  37647. * Is this sound currently paused.
  37648. */
  37649. isPaused: boolean;
  37650. /**
  37651. * Does this sound enables spatial sound.
  37652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37653. */
  37654. spatialSound: boolean;
  37655. /**
  37656. * Define the reference distance the sound should be heard perfectly.
  37657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37658. */
  37659. refDistance: number;
  37660. /**
  37661. * Define the roll off factor of spatial sounds.
  37662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37663. */
  37664. rolloffFactor: number;
  37665. /**
  37666. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37668. */
  37669. maxDistance: number;
  37670. /**
  37671. * Define the distance attenuation model the sound will follow.
  37672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37673. */
  37674. distanceModel: string;
  37675. /**
  37676. * @hidden
  37677. * Back Compat
  37678. **/
  37679. onended: () => any;
  37680. /**
  37681. * Observable event when the current playing sound finishes.
  37682. */
  37683. onEndedObservable: Observable<Sound>;
  37684. private _panningModel;
  37685. private _playbackRate;
  37686. private _streaming;
  37687. private _startTime;
  37688. private _startOffset;
  37689. private _position;
  37690. /** @hidden */
  37691. _positionInEmitterSpace: boolean;
  37692. private _localDirection;
  37693. private _volume;
  37694. private _isReadyToPlay;
  37695. private _isDirectional;
  37696. private _readyToPlayCallback;
  37697. private _audioBuffer;
  37698. private _soundSource;
  37699. private _streamingSource;
  37700. private _soundPanner;
  37701. private _soundGain;
  37702. private _inputAudioNode;
  37703. private _outputAudioNode;
  37704. private _coneInnerAngle;
  37705. private _coneOuterAngle;
  37706. private _coneOuterGain;
  37707. private _scene;
  37708. private _connectedTransformNode;
  37709. private _customAttenuationFunction;
  37710. private _registerFunc;
  37711. private _isOutputConnected;
  37712. private _htmlAudioElement;
  37713. private _urlType;
  37714. private _length?;
  37715. private _offset?;
  37716. /** @hidden */
  37717. static _SceneComponentInitialization: (scene: Scene) => void;
  37718. /**
  37719. * Create a sound and attach it to a scene
  37720. * @param name Name of your sound
  37721. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37722. * @param scene defines the scene the sound belongs to
  37723. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37724. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37725. */
  37726. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37727. /**
  37728. * Release the sound and its associated resources
  37729. */
  37730. dispose(): void;
  37731. /**
  37732. * Gets if the sounds is ready to be played or not.
  37733. * @returns true if ready, otherwise false
  37734. */
  37735. isReady(): boolean;
  37736. private _soundLoaded;
  37737. /**
  37738. * Sets the data of the sound from an audiobuffer
  37739. * @param audioBuffer The audioBuffer containing the data
  37740. */
  37741. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37742. /**
  37743. * Updates the current sounds options such as maxdistance, loop...
  37744. * @param options A JSON object containing values named as the object properties
  37745. */
  37746. updateOptions(options: ISoundOptions): void;
  37747. private _createSpatialParameters;
  37748. private _updateSpatialParameters;
  37749. /**
  37750. * Switch the panning model to HRTF:
  37751. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37753. */
  37754. switchPanningModelToHRTF(): void;
  37755. /**
  37756. * Switch the panning model to Equal Power:
  37757. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37759. */
  37760. switchPanningModelToEqualPower(): void;
  37761. private _switchPanningModel;
  37762. /**
  37763. * Connect this sound to a sound track audio node like gain...
  37764. * @param soundTrackAudioNode the sound track audio node to connect to
  37765. */
  37766. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37767. /**
  37768. * Transform this sound into a directional source
  37769. * @param coneInnerAngle Size of the inner cone in degree
  37770. * @param coneOuterAngle Size of the outer cone in degree
  37771. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37772. */
  37773. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37774. /**
  37775. * Gets or sets the inner angle for the directional cone.
  37776. */
  37777. get directionalConeInnerAngle(): number;
  37778. /**
  37779. * Gets or sets the inner angle for the directional cone.
  37780. */
  37781. set directionalConeInnerAngle(value: number);
  37782. /**
  37783. * Gets or sets the outer angle for the directional cone.
  37784. */
  37785. get directionalConeOuterAngle(): number;
  37786. /**
  37787. * Gets or sets the outer angle for the directional cone.
  37788. */
  37789. set directionalConeOuterAngle(value: number);
  37790. /**
  37791. * Sets the position of the emitter if spatial sound is enabled
  37792. * @param newPosition Defines the new posisiton
  37793. */
  37794. setPosition(newPosition: Vector3): void;
  37795. /**
  37796. * Sets the local direction of the emitter if spatial sound is enabled
  37797. * @param newLocalDirection Defines the new local direction
  37798. */
  37799. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37800. private _updateDirection;
  37801. /** @hidden */
  37802. updateDistanceFromListener(): void;
  37803. /**
  37804. * Sets a new custom attenuation function for the sound.
  37805. * @param callback Defines the function used for the attenuation
  37806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37807. */
  37808. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37809. /**
  37810. * Play the sound
  37811. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37812. * @param offset (optional) Start the sound at a specific time in seconds
  37813. * @param length (optional) Sound duration (in seconds)
  37814. */
  37815. play(time?: number, offset?: number, length?: number): void;
  37816. private _onended;
  37817. /**
  37818. * Stop the sound
  37819. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37820. */
  37821. stop(time?: number): void;
  37822. /**
  37823. * Put the sound in pause
  37824. */
  37825. pause(): void;
  37826. /**
  37827. * Sets a dedicated volume for this sounds
  37828. * @param newVolume Define the new volume of the sound
  37829. * @param time Define time for gradual change to new volume
  37830. */
  37831. setVolume(newVolume: number, time?: number): void;
  37832. /**
  37833. * Set the sound play back rate
  37834. * @param newPlaybackRate Define the playback rate the sound should be played at
  37835. */
  37836. setPlaybackRate(newPlaybackRate: number): void;
  37837. /**
  37838. * Gets the volume of the sound.
  37839. * @returns the volume of the sound
  37840. */
  37841. getVolume(): number;
  37842. /**
  37843. * Attach the sound to a dedicated mesh
  37844. * @param transformNode The transform node to connect the sound with
  37845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37846. */
  37847. attachToMesh(transformNode: TransformNode): void;
  37848. /**
  37849. * Detach the sound from the previously attached mesh
  37850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37851. */
  37852. detachFromMesh(): void;
  37853. private _onRegisterAfterWorldMatrixUpdate;
  37854. /**
  37855. * Clone the current sound in the scene.
  37856. * @returns the new sound clone
  37857. */
  37858. clone(): Nullable<Sound>;
  37859. /**
  37860. * Gets the current underlying audio buffer containing the data
  37861. * @returns the audio buffer
  37862. */
  37863. getAudioBuffer(): Nullable<AudioBuffer>;
  37864. /**
  37865. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37866. * @returns the source node
  37867. */
  37868. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37869. /**
  37870. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37871. * @returns the gain node
  37872. */
  37873. getSoundGain(): Nullable<GainNode>;
  37874. /**
  37875. * Serializes the Sound in a JSON representation
  37876. * @returns the JSON representation of the sound
  37877. */
  37878. serialize(): any;
  37879. /**
  37880. * Parse a JSON representation of a sound to innstantiate in a given scene
  37881. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37882. * @param scene Define the scene the new parsed sound should be created in
  37883. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37884. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37885. * @returns the newly parsed sound
  37886. */
  37887. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37888. }
  37889. }
  37890. declare module BABYLON {
  37891. /**
  37892. * This defines an action helpful to play a defined sound on a triggered action.
  37893. */
  37894. export class PlaySoundAction extends Action {
  37895. private _sound;
  37896. /**
  37897. * Instantiate the action
  37898. * @param triggerOptions defines the trigger options
  37899. * @param sound defines the sound to play
  37900. * @param condition defines the trigger related conditions
  37901. */
  37902. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37903. /** @hidden */
  37904. _prepare(): void;
  37905. /**
  37906. * Execute the action and play the sound.
  37907. */
  37908. execute(): void;
  37909. /**
  37910. * Serializes the actions and its related information.
  37911. * @param parent defines the object to serialize in
  37912. * @returns the serialized object
  37913. */
  37914. serialize(parent: any): any;
  37915. }
  37916. /**
  37917. * This defines an action helpful to stop a defined sound on a triggered action.
  37918. */
  37919. export class StopSoundAction extends Action {
  37920. private _sound;
  37921. /**
  37922. * Instantiate the action
  37923. * @param triggerOptions defines the trigger options
  37924. * @param sound defines the sound to stop
  37925. * @param condition defines the trigger related conditions
  37926. */
  37927. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37928. /** @hidden */
  37929. _prepare(): void;
  37930. /**
  37931. * Execute the action and stop the sound.
  37932. */
  37933. execute(): void;
  37934. /**
  37935. * Serializes the actions and its related information.
  37936. * @param parent defines the object to serialize in
  37937. * @returns the serialized object
  37938. */
  37939. serialize(parent: any): any;
  37940. }
  37941. }
  37942. declare module BABYLON {
  37943. /**
  37944. * This defines an action responsible to change the value of a property
  37945. * by interpolating between its current value and the newly set one once triggered.
  37946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37947. */
  37948. export class InterpolateValueAction extends Action {
  37949. /**
  37950. * Defines the path of the property where the value should be interpolated
  37951. */
  37952. propertyPath: string;
  37953. /**
  37954. * Defines the target value at the end of the interpolation.
  37955. */
  37956. value: any;
  37957. /**
  37958. * Defines the time it will take for the property to interpolate to the value.
  37959. */
  37960. duration: number;
  37961. /**
  37962. * Defines if the other scene animations should be stopped when the action has been triggered
  37963. */
  37964. stopOtherAnimations?: boolean;
  37965. /**
  37966. * Defines a callback raised once the interpolation animation has been done.
  37967. */
  37968. onInterpolationDone?: () => void;
  37969. /**
  37970. * Observable triggered once the interpolation animation has been done.
  37971. */
  37972. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37973. private _target;
  37974. private _effectiveTarget;
  37975. private _property;
  37976. /**
  37977. * Instantiate the action
  37978. * @param triggerOptions defines the trigger options
  37979. * @param target defines the object containing the value to interpolate
  37980. * @param propertyPath defines the path to the property in the target object
  37981. * @param value defines the target value at the end of the interpolation
  37982. * @param duration deines the time it will take for the property to interpolate to the value.
  37983. * @param condition defines the trigger related conditions
  37984. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37985. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37986. */
  37987. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37988. /** @hidden */
  37989. _prepare(): void;
  37990. /**
  37991. * Execute the action starts the value interpolation.
  37992. */
  37993. execute(): void;
  37994. /**
  37995. * Serializes the actions and its related information.
  37996. * @param parent defines the object to serialize in
  37997. * @returns the serialized object
  37998. */
  37999. serialize(parent: any): any;
  38000. }
  38001. }
  38002. declare module BABYLON {
  38003. /**
  38004. * Options allowed during the creation of a sound track.
  38005. */
  38006. export interface ISoundTrackOptions {
  38007. /**
  38008. * The volume the sound track should take during creation
  38009. */
  38010. volume?: number;
  38011. /**
  38012. * Define if the sound track is the main sound track of the scene
  38013. */
  38014. mainTrack?: boolean;
  38015. }
  38016. /**
  38017. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38018. * It will be also used in a future release to apply effects on a specific track.
  38019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38020. */
  38021. export class SoundTrack {
  38022. /**
  38023. * The unique identifier of the sound track in the scene.
  38024. */
  38025. id: number;
  38026. /**
  38027. * The list of sounds included in the sound track.
  38028. */
  38029. soundCollection: Array<Sound>;
  38030. private _outputAudioNode;
  38031. private _scene;
  38032. private _connectedAnalyser;
  38033. private _options;
  38034. private _isInitialized;
  38035. /**
  38036. * Creates a new sound track.
  38037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38038. * @param scene Define the scene the sound track belongs to
  38039. * @param options
  38040. */
  38041. constructor(scene: Scene, options?: ISoundTrackOptions);
  38042. private _initializeSoundTrackAudioGraph;
  38043. /**
  38044. * Release the sound track and its associated resources
  38045. */
  38046. dispose(): void;
  38047. /**
  38048. * Adds a sound to this sound track
  38049. * @param sound define the cound to add
  38050. * @ignoreNaming
  38051. */
  38052. AddSound(sound: Sound): void;
  38053. /**
  38054. * Removes a sound to this sound track
  38055. * @param sound define the cound to remove
  38056. * @ignoreNaming
  38057. */
  38058. RemoveSound(sound: Sound): void;
  38059. /**
  38060. * Set a global volume for the full sound track.
  38061. * @param newVolume Define the new volume of the sound track
  38062. */
  38063. setVolume(newVolume: number): void;
  38064. /**
  38065. * Switch the panning model to HRTF:
  38066. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38068. */
  38069. switchPanningModelToHRTF(): void;
  38070. /**
  38071. * Switch the panning model to Equal Power:
  38072. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38074. */
  38075. switchPanningModelToEqualPower(): void;
  38076. /**
  38077. * Connect the sound track to an audio analyser allowing some amazing
  38078. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38080. * @param analyser The analyser to connect to the engine
  38081. */
  38082. connectToAnalyser(analyser: Analyser): void;
  38083. }
  38084. }
  38085. declare module BABYLON {
  38086. interface AbstractScene {
  38087. /**
  38088. * The list of sounds used in the scene.
  38089. */
  38090. sounds: Nullable<Array<Sound>>;
  38091. }
  38092. interface Scene {
  38093. /**
  38094. * @hidden
  38095. * Backing field
  38096. */
  38097. _mainSoundTrack: SoundTrack;
  38098. /**
  38099. * The main sound track played by the scene.
  38100. * It cotains your primary collection of sounds.
  38101. */
  38102. mainSoundTrack: SoundTrack;
  38103. /**
  38104. * The list of sound tracks added to the scene
  38105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38106. */
  38107. soundTracks: Nullable<Array<SoundTrack>>;
  38108. /**
  38109. * Gets a sound using a given name
  38110. * @param name defines the name to search for
  38111. * @return the found sound or null if not found at all.
  38112. */
  38113. getSoundByName(name: string): Nullable<Sound>;
  38114. /**
  38115. * Gets or sets if audio support is enabled
  38116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38117. */
  38118. audioEnabled: boolean;
  38119. /**
  38120. * Gets or sets if audio will be output to headphones
  38121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38122. */
  38123. headphone: boolean;
  38124. /**
  38125. * Gets or sets custom audio listener position provider
  38126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38127. */
  38128. audioListenerPositionProvider: Nullable<() => Vector3>;
  38129. /**
  38130. * Gets or sets a refresh rate when using 3D audio positioning
  38131. */
  38132. audioPositioningRefreshRate: number;
  38133. }
  38134. /**
  38135. * Defines the sound scene component responsible to manage any sounds
  38136. * in a given scene.
  38137. */
  38138. export class AudioSceneComponent implements ISceneSerializableComponent {
  38139. /**
  38140. * The component name helpfull to identify the component in the list of scene components.
  38141. */
  38142. readonly name: string;
  38143. /**
  38144. * The scene the component belongs to.
  38145. */
  38146. scene: Scene;
  38147. private _audioEnabled;
  38148. /**
  38149. * Gets whether audio is enabled or not.
  38150. * Please use related enable/disable method to switch state.
  38151. */
  38152. get audioEnabled(): boolean;
  38153. private _headphone;
  38154. /**
  38155. * Gets whether audio is outputing to headphone or not.
  38156. * Please use the according Switch methods to change output.
  38157. */
  38158. get headphone(): boolean;
  38159. /**
  38160. * Gets or sets a refresh rate when using 3D audio positioning
  38161. */
  38162. audioPositioningRefreshRate: number;
  38163. private _audioListenerPositionProvider;
  38164. /**
  38165. * Gets the current audio listener position provider
  38166. */
  38167. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38168. /**
  38169. * Sets a custom listener position for all sounds in the scene
  38170. * By default, this is the position of the first active camera
  38171. */
  38172. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38173. /**
  38174. * Creates a new instance of the component for the given scene
  38175. * @param scene Defines the scene to register the component in
  38176. */
  38177. constructor(scene: Scene);
  38178. /**
  38179. * Registers the component in a given scene
  38180. */
  38181. register(): void;
  38182. /**
  38183. * Rebuilds the elements related to this component in case of
  38184. * context lost for instance.
  38185. */
  38186. rebuild(): void;
  38187. /**
  38188. * Serializes the component data to the specified json object
  38189. * @param serializationObject The object to serialize to
  38190. */
  38191. serialize(serializationObject: any): void;
  38192. /**
  38193. * Adds all the elements from the container to the scene
  38194. * @param container the container holding the elements
  38195. */
  38196. addFromContainer(container: AbstractScene): void;
  38197. /**
  38198. * Removes all the elements in the container from the scene
  38199. * @param container contains the elements to remove
  38200. * @param dispose if the removed element should be disposed (default: false)
  38201. */
  38202. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38203. /**
  38204. * Disposes the component and the associated ressources.
  38205. */
  38206. dispose(): void;
  38207. /**
  38208. * Disables audio in the associated scene.
  38209. */
  38210. disableAudio(): void;
  38211. /**
  38212. * Enables audio in the associated scene.
  38213. */
  38214. enableAudio(): void;
  38215. /**
  38216. * Switch audio to headphone output.
  38217. */
  38218. switchAudioModeForHeadphones(): void;
  38219. /**
  38220. * Switch audio to normal speakers.
  38221. */
  38222. switchAudioModeForNormalSpeakers(): void;
  38223. private _cachedCameraDirection;
  38224. private _cachedCameraPosition;
  38225. private _lastCheck;
  38226. private _afterRender;
  38227. }
  38228. }
  38229. declare module BABYLON {
  38230. /**
  38231. * Wraps one or more Sound objects and selects one with random weight for playback.
  38232. */
  38233. export class WeightedSound {
  38234. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38235. loop: boolean;
  38236. private _coneInnerAngle;
  38237. private _coneOuterAngle;
  38238. private _volume;
  38239. /** A Sound is currently playing. */
  38240. isPlaying: boolean;
  38241. /** A Sound is currently paused. */
  38242. isPaused: boolean;
  38243. private _sounds;
  38244. private _weights;
  38245. private _currentIndex?;
  38246. /**
  38247. * Creates a new WeightedSound from the list of sounds given.
  38248. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38249. * @param sounds Array of Sounds that will be selected from.
  38250. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38251. */
  38252. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38253. /**
  38254. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38255. */
  38256. get directionalConeInnerAngle(): number;
  38257. /**
  38258. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38259. */
  38260. set directionalConeInnerAngle(value: number);
  38261. /**
  38262. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38263. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38264. */
  38265. get directionalConeOuterAngle(): number;
  38266. /**
  38267. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38268. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38269. */
  38270. set directionalConeOuterAngle(value: number);
  38271. /**
  38272. * Playback volume.
  38273. */
  38274. get volume(): number;
  38275. /**
  38276. * Playback volume.
  38277. */
  38278. set volume(value: number);
  38279. private _onended;
  38280. /**
  38281. * Suspend playback
  38282. */
  38283. pause(): void;
  38284. /**
  38285. * Stop playback
  38286. */
  38287. stop(): void;
  38288. /**
  38289. * Start playback.
  38290. * @param startOffset Position the clip head at a specific time in seconds.
  38291. */
  38292. play(startOffset?: number): void;
  38293. }
  38294. }
  38295. declare module BABYLON {
  38296. /**
  38297. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38299. */
  38300. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38301. /**
  38302. * Gets the name of the behavior.
  38303. */
  38304. get name(): string;
  38305. /**
  38306. * The easing function used by animations
  38307. */
  38308. static EasingFunction: BackEase;
  38309. /**
  38310. * The easing mode used by animations
  38311. */
  38312. static EasingMode: number;
  38313. /**
  38314. * The duration of the animation, in milliseconds
  38315. */
  38316. transitionDuration: number;
  38317. /**
  38318. * Length of the distance animated by the transition when lower radius is reached
  38319. */
  38320. lowerRadiusTransitionRange: number;
  38321. /**
  38322. * Length of the distance animated by the transition when upper radius is reached
  38323. */
  38324. upperRadiusTransitionRange: number;
  38325. private _autoTransitionRange;
  38326. /**
  38327. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38328. */
  38329. get autoTransitionRange(): boolean;
  38330. /**
  38331. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38332. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38333. */
  38334. set autoTransitionRange(value: boolean);
  38335. private _attachedCamera;
  38336. private _onAfterCheckInputsObserver;
  38337. private _onMeshTargetChangedObserver;
  38338. /**
  38339. * Initializes the behavior.
  38340. */
  38341. init(): void;
  38342. /**
  38343. * Attaches the behavior to its arc rotate camera.
  38344. * @param camera Defines the camera to attach the behavior to
  38345. */
  38346. attach(camera: ArcRotateCamera): void;
  38347. /**
  38348. * Detaches the behavior from its current arc rotate camera.
  38349. */
  38350. detach(): void;
  38351. private _radiusIsAnimating;
  38352. private _radiusBounceTransition;
  38353. private _animatables;
  38354. private _cachedWheelPrecision;
  38355. /**
  38356. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38357. * @param radiusLimit The limit to check against.
  38358. * @return Bool to indicate if at limit.
  38359. */
  38360. private _isRadiusAtLimit;
  38361. /**
  38362. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38363. * @param radiusDelta The delta by which to animate to. Can be negative.
  38364. */
  38365. private _applyBoundRadiusAnimation;
  38366. /**
  38367. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38368. */
  38369. protected _clearAnimationLocks(): void;
  38370. /**
  38371. * Stops and removes all animations that have been applied to the camera
  38372. */
  38373. stopAllAnimations(): void;
  38374. }
  38375. }
  38376. declare module BABYLON {
  38377. /**
  38378. * 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.
  38379. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38380. */
  38381. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38382. /**
  38383. * Gets the name of the behavior.
  38384. */
  38385. get name(): string;
  38386. private _mode;
  38387. private _radiusScale;
  38388. private _positionScale;
  38389. private _defaultElevation;
  38390. private _elevationReturnTime;
  38391. private _elevationReturnWaitTime;
  38392. private _zoomStopsAnimation;
  38393. private _framingTime;
  38394. /**
  38395. * The easing function used by animations
  38396. */
  38397. static EasingFunction: ExponentialEase;
  38398. /**
  38399. * The easing mode used by animations
  38400. */
  38401. static EasingMode: number;
  38402. /**
  38403. * Sets the current mode used by the behavior
  38404. */
  38405. set mode(mode: number);
  38406. /**
  38407. * Gets current mode used by the behavior.
  38408. */
  38409. get mode(): number;
  38410. /**
  38411. * Sets the scale applied to the radius (1 by default)
  38412. */
  38413. set radiusScale(radius: number);
  38414. /**
  38415. * Gets the scale applied to the radius
  38416. */
  38417. get radiusScale(): number;
  38418. /**
  38419. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38420. */
  38421. set positionScale(scale: number);
  38422. /**
  38423. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38424. */
  38425. get positionScale(): number;
  38426. /**
  38427. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38428. * behaviour is triggered, in radians.
  38429. */
  38430. set defaultElevation(elevation: number);
  38431. /**
  38432. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38433. * behaviour is triggered, in radians.
  38434. */
  38435. get defaultElevation(): number;
  38436. /**
  38437. * Sets the time (in milliseconds) taken to return to the default beta position.
  38438. * Negative value indicates camera should not return to default.
  38439. */
  38440. set elevationReturnTime(speed: number);
  38441. /**
  38442. * Gets the time (in milliseconds) taken to return to the default beta position.
  38443. * Negative value indicates camera should not return to default.
  38444. */
  38445. get elevationReturnTime(): number;
  38446. /**
  38447. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38448. */
  38449. set elevationReturnWaitTime(time: number);
  38450. /**
  38451. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38452. */
  38453. get elevationReturnWaitTime(): number;
  38454. /**
  38455. * Sets the flag that indicates if user zooming should stop animation.
  38456. */
  38457. set zoomStopsAnimation(flag: boolean);
  38458. /**
  38459. * Gets the flag that indicates if user zooming should stop animation.
  38460. */
  38461. get zoomStopsAnimation(): boolean;
  38462. /**
  38463. * Sets the transition time when framing the mesh, in milliseconds
  38464. */
  38465. set framingTime(time: number);
  38466. /**
  38467. * Gets the transition time when framing the mesh, in milliseconds
  38468. */
  38469. get framingTime(): number;
  38470. /**
  38471. * Define if the behavior should automatically change the configured
  38472. * camera limits and sensibilities.
  38473. */
  38474. autoCorrectCameraLimitsAndSensibility: boolean;
  38475. private _onPrePointerObservableObserver;
  38476. private _onAfterCheckInputsObserver;
  38477. private _onMeshTargetChangedObserver;
  38478. private _attachedCamera;
  38479. private _isPointerDown;
  38480. private _lastInteractionTime;
  38481. /**
  38482. * Initializes the behavior.
  38483. */
  38484. init(): void;
  38485. /**
  38486. * Attaches the behavior to its arc rotate camera.
  38487. * @param camera Defines the camera to attach the behavior to
  38488. */
  38489. attach(camera: ArcRotateCamera): void;
  38490. /**
  38491. * Detaches the behavior from its current arc rotate camera.
  38492. */
  38493. detach(): void;
  38494. private _animatables;
  38495. private _betaIsAnimating;
  38496. private _betaTransition;
  38497. private _radiusTransition;
  38498. private _vectorTransition;
  38499. /**
  38500. * Targets the given mesh and updates zoom level accordingly.
  38501. * @param mesh The mesh to target.
  38502. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38503. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38504. */
  38505. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38506. /**
  38507. * Targets the given mesh with its children and updates zoom level accordingly.
  38508. * @param mesh The mesh to target.
  38509. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38510. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38511. */
  38512. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38513. /**
  38514. * Targets the given meshes with their children and updates zoom level accordingly.
  38515. * @param meshes The mesh to target.
  38516. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38517. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38518. */
  38519. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38520. /**
  38521. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38522. * @param minimumWorld Determines the smaller position of the bounding box extend
  38523. * @param maximumWorld Determines the bigger position of the bounding box extend
  38524. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38525. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38526. */
  38527. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38528. /**
  38529. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38530. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38531. * frustum width.
  38532. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38533. * to fully enclose the mesh in the viewing frustum.
  38534. */
  38535. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38536. /**
  38537. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38538. * is automatically returned to its default position (expected to be above ground plane).
  38539. */
  38540. private _maintainCameraAboveGround;
  38541. /**
  38542. * Returns the frustum slope based on the canvas ratio and camera FOV
  38543. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38544. */
  38545. private _getFrustumSlope;
  38546. /**
  38547. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38548. */
  38549. private _clearAnimationLocks;
  38550. /**
  38551. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38552. */
  38553. private _applyUserInteraction;
  38554. /**
  38555. * Stops and removes all animations that have been applied to the camera
  38556. */
  38557. stopAllAnimations(): void;
  38558. /**
  38559. * Gets a value indicating if the user is moving the camera
  38560. */
  38561. get isUserIsMoving(): boolean;
  38562. /**
  38563. * The camera can move all the way towards the mesh.
  38564. */
  38565. static IgnoreBoundsSizeMode: number;
  38566. /**
  38567. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38568. */
  38569. static FitFrustumSidesMode: number;
  38570. }
  38571. }
  38572. declare module BABYLON {
  38573. /**
  38574. * Base class for Camera Pointer Inputs.
  38575. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38576. * for example usage.
  38577. */
  38578. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38579. /**
  38580. * Defines the camera the input is attached to.
  38581. */
  38582. abstract camera: Camera;
  38583. /**
  38584. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38585. */
  38586. protected _altKey: boolean;
  38587. protected _ctrlKey: boolean;
  38588. protected _metaKey: boolean;
  38589. protected _shiftKey: boolean;
  38590. /**
  38591. * Which mouse buttons were pressed at time of last mouse event.
  38592. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38593. */
  38594. protected _buttonsPressed: number;
  38595. /**
  38596. * Defines the buttons associated with the input to handle camera move.
  38597. */
  38598. buttons: number[];
  38599. /**
  38600. * Attach the input controls to a specific dom element to get the input from.
  38601. * @param element Defines the element the controls should be listened from
  38602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38603. */
  38604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38605. /**
  38606. * Detach the current controls from the specified dom element.
  38607. * @param element Defines the element to stop listening the inputs from
  38608. */
  38609. detachControl(element: Nullable<HTMLElement>): void;
  38610. /**
  38611. * Gets the class name of the current input.
  38612. * @returns the class name
  38613. */
  38614. getClassName(): string;
  38615. /**
  38616. * Get the friendly name associated with the input class.
  38617. * @returns the input friendly name
  38618. */
  38619. getSimpleName(): string;
  38620. /**
  38621. * Called on pointer POINTERDOUBLETAP event.
  38622. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38623. */
  38624. protected onDoubleTap(type: string): void;
  38625. /**
  38626. * Called on pointer POINTERMOVE event if only a single touch is active.
  38627. * Override this method to provide functionality.
  38628. */
  38629. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38630. /**
  38631. * Called on pointer POINTERMOVE event if multiple touches are active.
  38632. * Override this method to provide functionality.
  38633. */
  38634. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38635. /**
  38636. * Called on JS contextmenu event.
  38637. * Override this method to provide functionality.
  38638. */
  38639. protected onContextMenu(evt: PointerEvent): void;
  38640. /**
  38641. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38642. * press.
  38643. * Override this method to provide functionality.
  38644. */
  38645. protected onButtonDown(evt: PointerEvent): void;
  38646. /**
  38647. * Called each time a new POINTERUP event occurs. Ie, for each button
  38648. * release.
  38649. * Override this method to provide functionality.
  38650. */
  38651. protected onButtonUp(evt: PointerEvent): void;
  38652. /**
  38653. * Called when window becomes inactive.
  38654. * Override this method to provide functionality.
  38655. */
  38656. protected onLostFocus(): void;
  38657. private _pointerInput;
  38658. private _observer;
  38659. private _onLostFocus;
  38660. private pointA;
  38661. private pointB;
  38662. }
  38663. }
  38664. declare module BABYLON {
  38665. /**
  38666. * Manage the pointers inputs to control an arc rotate camera.
  38667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38668. */
  38669. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38670. /**
  38671. * Defines the camera the input is attached to.
  38672. */
  38673. camera: ArcRotateCamera;
  38674. /**
  38675. * Gets the class name of the current input.
  38676. * @returns the class name
  38677. */
  38678. getClassName(): string;
  38679. /**
  38680. * Defines the buttons associated with the input to handle camera move.
  38681. */
  38682. buttons: number[];
  38683. /**
  38684. * Defines the pointer angular sensibility along the X axis or how fast is
  38685. * the camera rotating.
  38686. */
  38687. angularSensibilityX: number;
  38688. /**
  38689. * Defines the pointer angular sensibility along the Y axis or how fast is
  38690. * the camera rotating.
  38691. */
  38692. angularSensibilityY: number;
  38693. /**
  38694. * Defines the pointer pinch precision or how fast is the camera zooming.
  38695. */
  38696. pinchPrecision: number;
  38697. /**
  38698. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38699. * from 0.
  38700. * It defines the percentage of current camera.radius to use as delta when
  38701. * pinch zoom is used.
  38702. */
  38703. pinchDeltaPercentage: number;
  38704. /**
  38705. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38706. * that any object in the plane at the camera's target point will scale
  38707. * perfectly with finger motion.
  38708. * Overrides pinchDeltaPercentage and pinchPrecision.
  38709. */
  38710. useNaturalPinchZoom: boolean;
  38711. /**
  38712. * Defines the pointer panning sensibility or how fast is the camera moving.
  38713. */
  38714. panningSensibility: number;
  38715. /**
  38716. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38717. */
  38718. multiTouchPanning: boolean;
  38719. /**
  38720. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38721. * zoom (pinch) through multitouch.
  38722. */
  38723. multiTouchPanAndZoom: boolean;
  38724. /**
  38725. * Revers pinch action direction.
  38726. */
  38727. pinchInwards: boolean;
  38728. private _isPanClick;
  38729. private _twoFingerActivityCount;
  38730. private _isPinching;
  38731. /**
  38732. * Called on pointer POINTERMOVE event if only a single touch is active.
  38733. */
  38734. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38735. /**
  38736. * Called on pointer POINTERDOUBLETAP event.
  38737. */
  38738. protected onDoubleTap(type: string): void;
  38739. /**
  38740. * Called on pointer POINTERMOVE event if multiple touches are active.
  38741. */
  38742. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38743. /**
  38744. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38745. * press.
  38746. */
  38747. protected onButtonDown(evt: PointerEvent): void;
  38748. /**
  38749. * Called each time a new POINTERUP event occurs. Ie, for each button
  38750. * release.
  38751. */
  38752. protected onButtonUp(evt: PointerEvent): void;
  38753. /**
  38754. * Called when window becomes inactive.
  38755. */
  38756. protected onLostFocus(): void;
  38757. }
  38758. }
  38759. declare module BABYLON {
  38760. /**
  38761. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38763. */
  38764. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38765. /**
  38766. * Defines the camera the input is attached to.
  38767. */
  38768. camera: ArcRotateCamera;
  38769. /**
  38770. * Defines the list of key codes associated with the up action (increase alpha)
  38771. */
  38772. keysUp: number[];
  38773. /**
  38774. * Defines the list of key codes associated with the down action (decrease alpha)
  38775. */
  38776. keysDown: number[];
  38777. /**
  38778. * Defines the list of key codes associated with the left action (increase beta)
  38779. */
  38780. keysLeft: number[];
  38781. /**
  38782. * Defines the list of key codes associated with the right action (decrease beta)
  38783. */
  38784. keysRight: number[];
  38785. /**
  38786. * Defines the list of key codes associated with the reset action.
  38787. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38788. */
  38789. keysReset: number[];
  38790. /**
  38791. * Defines the panning sensibility of the inputs.
  38792. * (How fast is the camera panning)
  38793. */
  38794. panningSensibility: number;
  38795. /**
  38796. * Defines the zooming sensibility of the inputs.
  38797. * (How fast is the camera zooming)
  38798. */
  38799. zoomingSensibility: number;
  38800. /**
  38801. * Defines whether maintaining the alt key down switch the movement mode from
  38802. * orientation to zoom.
  38803. */
  38804. useAltToZoom: boolean;
  38805. /**
  38806. * Rotation speed of the camera
  38807. */
  38808. angularSpeed: number;
  38809. private _keys;
  38810. private _ctrlPressed;
  38811. private _altPressed;
  38812. private _onCanvasBlurObserver;
  38813. private _onKeyboardObserver;
  38814. private _engine;
  38815. private _scene;
  38816. /**
  38817. * Attach the input controls to a specific dom element to get the input from.
  38818. * @param element Defines the element the controls should be listened from
  38819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38820. */
  38821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38822. /**
  38823. * Detach the current controls from the specified dom element.
  38824. * @param element Defines the element to stop listening the inputs from
  38825. */
  38826. detachControl(element: Nullable<HTMLElement>): void;
  38827. /**
  38828. * Update the current camera state depending on the inputs that have been used this frame.
  38829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38830. */
  38831. checkInputs(): void;
  38832. /**
  38833. * Gets the class name of the current intput.
  38834. * @returns the class name
  38835. */
  38836. getClassName(): string;
  38837. /**
  38838. * Get the friendly name associated with the input class.
  38839. * @returns the input friendly name
  38840. */
  38841. getSimpleName(): string;
  38842. }
  38843. }
  38844. declare module BABYLON {
  38845. /**
  38846. * Manage the mouse wheel inputs to control an arc rotate camera.
  38847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38848. */
  38849. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38850. /**
  38851. * Defines the camera the input is attached to.
  38852. */
  38853. camera: ArcRotateCamera;
  38854. /**
  38855. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38856. */
  38857. wheelPrecision: number;
  38858. /**
  38859. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38860. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38861. */
  38862. wheelDeltaPercentage: number;
  38863. private _wheel;
  38864. private _observer;
  38865. private computeDeltaFromMouseWheelLegacyEvent;
  38866. /**
  38867. * Attach the input controls to a specific dom element to get the input from.
  38868. * @param element Defines the element the controls should be listened from
  38869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38870. */
  38871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38872. /**
  38873. * Detach the current controls from the specified dom element.
  38874. * @param element Defines the element to stop listening the inputs from
  38875. */
  38876. detachControl(element: Nullable<HTMLElement>): void;
  38877. /**
  38878. * Gets the class name of the current intput.
  38879. * @returns the class name
  38880. */
  38881. getClassName(): string;
  38882. /**
  38883. * Get the friendly name associated with the input class.
  38884. * @returns the input friendly name
  38885. */
  38886. getSimpleName(): string;
  38887. }
  38888. }
  38889. declare module BABYLON {
  38890. /**
  38891. * Default Inputs manager for the ArcRotateCamera.
  38892. * It groups all the default supported inputs for ease of use.
  38893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38894. */
  38895. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38896. /**
  38897. * Instantiates a new ArcRotateCameraInputsManager.
  38898. * @param camera Defines the camera the inputs belong to
  38899. */
  38900. constructor(camera: ArcRotateCamera);
  38901. /**
  38902. * Add mouse wheel input support to the input manager.
  38903. * @returns the current input manager
  38904. */
  38905. addMouseWheel(): ArcRotateCameraInputsManager;
  38906. /**
  38907. * Add pointers input support to the input manager.
  38908. * @returns the current input manager
  38909. */
  38910. addPointers(): ArcRotateCameraInputsManager;
  38911. /**
  38912. * Add keyboard input support to the input manager.
  38913. * @returns the current input manager
  38914. */
  38915. addKeyboard(): ArcRotateCameraInputsManager;
  38916. }
  38917. }
  38918. declare module BABYLON {
  38919. /**
  38920. * This represents an orbital type of camera.
  38921. *
  38922. * 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.
  38923. * 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.
  38924. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38925. */
  38926. export class ArcRotateCamera extends TargetCamera {
  38927. /**
  38928. * Defines the rotation angle of the camera along the longitudinal axis.
  38929. */
  38930. alpha: number;
  38931. /**
  38932. * Defines the rotation angle of the camera along the latitudinal axis.
  38933. */
  38934. beta: number;
  38935. /**
  38936. * Defines the radius of the camera from it s target point.
  38937. */
  38938. radius: number;
  38939. protected _target: Vector3;
  38940. protected _targetHost: Nullable<AbstractMesh>;
  38941. /**
  38942. * Defines the target point of the camera.
  38943. * The camera looks towards it form the radius distance.
  38944. */
  38945. get target(): Vector3;
  38946. set target(value: Vector3);
  38947. /**
  38948. * Define the current local position of the camera in the scene
  38949. */
  38950. get position(): Vector3;
  38951. set position(newPosition: Vector3);
  38952. protected _upVector: Vector3;
  38953. protected _upToYMatrix: Matrix;
  38954. protected _YToUpMatrix: Matrix;
  38955. /**
  38956. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38957. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38958. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38959. */
  38960. set upVector(vec: Vector3);
  38961. get upVector(): Vector3;
  38962. /**
  38963. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38964. */
  38965. setMatUp(): void;
  38966. /**
  38967. * Current inertia value on the longitudinal axis.
  38968. * The bigger this number the longer it will take for the camera to stop.
  38969. */
  38970. inertialAlphaOffset: number;
  38971. /**
  38972. * Current inertia value on the latitudinal axis.
  38973. * The bigger this number the longer it will take for the camera to stop.
  38974. */
  38975. inertialBetaOffset: number;
  38976. /**
  38977. * Current inertia value on the radius axis.
  38978. * The bigger this number the longer it will take for the camera to stop.
  38979. */
  38980. inertialRadiusOffset: number;
  38981. /**
  38982. * Minimum allowed angle on the longitudinal axis.
  38983. * This can help limiting how the Camera is able to move in the scene.
  38984. */
  38985. lowerAlphaLimit: Nullable<number>;
  38986. /**
  38987. * Maximum allowed angle on the longitudinal axis.
  38988. * This can help limiting how the Camera is able to move in the scene.
  38989. */
  38990. upperAlphaLimit: Nullable<number>;
  38991. /**
  38992. * Minimum allowed angle on the latitudinal axis.
  38993. * This can help limiting how the Camera is able to move in the scene.
  38994. */
  38995. lowerBetaLimit: number;
  38996. /**
  38997. * Maximum allowed angle on the latitudinal axis.
  38998. * This can help limiting how the Camera is able to move in the scene.
  38999. */
  39000. upperBetaLimit: number;
  39001. /**
  39002. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39003. * This can help limiting how the Camera is able to move in the scene.
  39004. */
  39005. lowerRadiusLimit: Nullable<number>;
  39006. /**
  39007. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39008. * This can help limiting how the Camera is able to move in the scene.
  39009. */
  39010. upperRadiusLimit: Nullable<number>;
  39011. /**
  39012. * Defines the current inertia value used during panning of the camera along the X axis.
  39013. */
  39014. inertialPanningX: number;
  39015. /**
  39016. * Defines the current inertia value used during panning of the camera along the Y axis.
  39017. */
  39018. inertialPanningY: number;
  39019. /**
  39020. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39021. * Basically if your fingers moves away from more than this distance you will be considered
  39022. * in pinch mode.
  39023. */
  39024. pinchToPanMaxDistance: number;
  39025. /**
  39026. * Defines the maximum distance the camera can pan.
  39027. * This could help keeping the cammera always in your scene.
  39028. */
  39029. panningDistanceLimit: Nullable<number>;
  39030. /**
  39031. * Defines the target of the camera before paning.
  39032. */
  39033. panningOriginTarget: Vector3;
  39034. /**
  39035. * Defines the value of the inertia used during panning.
  39036. * 0 would mean stop inertia and one would mean no decelleration at all.
  39037. */
  39038. panningInertia: number;
  39039. /**
  39040. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39041. */
  39042. get angularSensibilityX(): number;
  39043. set angularSensibilityX(value: number);
  39044. /**
  39045. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39046. */
  39047. get angularSensibilityY(): number;
  39048. set angularSensibilityY(value: number);
  39049. /**
  39050. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39051. */
  39052. get pinchPrecision(): number;
  39053. set pinchPrecision(value: number);
  39054. /**
  39055. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39056. * It will be used instead of pinchDeltaPrecision if different from 0.
  39057. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39058. */
  39059. get pinchDeltaPercentage(): number;
  39060. set pinchDeltaPercentage(value: number);
  39061. /**
  39062. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39063. * and pinch delta percentage.
  39064. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39065. * that any object in the plane at the camera's target point will scale
  39066. * perfectly with finger motion.
  39067. */
  39068. get useNaturalPinchZoom(): boolean;
  39069. set useNaturalPinchZoom(value: boolean);
  39070. /**
  39071. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39072. */
  39073. get panningSensibility(): number;
  39074. set panningSensibility(value: number);
  39075. /**
  39076. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39077. */
  39078. get keysUp(): number[];
  39079. set keysUp(value: number[]);
  39080. /**
  39081. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39082. */
  39083. get keysDown(): number[];
  39084. set keysDown(value: number[]);
  39085. /**
  39086. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39087. */
  39088. get keysLeft(): number[];
  39089. set keysLeft(value: number[]);
  39090. /**
  39091. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39092. */
  39093. get keysRight(): number[];
  39094. set keysRight(value: number[]);
  39095. /**
  39096. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39097. */
  39098. get wheelPrecision(): number;
  39099. set wheelPrecision(value: number);
  39100. /**
  39101. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39102. * It will be used instead of pinchDeltaPrecision if different from 0.
  39103. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39104. */
  39105. get wheelDeltaPercentage(): number;
  39106. set wheelDeltaPercentage(value: number);
  39107. /**
  39108. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39109. */
  39110. zoomOnFactor: number;
  39111. /**
  39112. * Defines a screen offset for the camera position.
  39113. */
  39114. targetScreenOffset: Vector2;
  39115. /**
  39116. * Allows the camera to be completely reversed.
  39117. * If false the camera can not arrive upside down.
  39118. */
  39119. allowUpsideDown: boolean;
  39120. /**
  39121. * Define if double tap/click is used to restore the previously saved state of the camera.
  39122. */
  39123. useInputToRestoreState: boolean;
  39124. /** @hidden */
  39125. _viewMatrix: Matrix;
  39126. /** @hidden */
  39127. _useCtrlForPanning: boolean;
  39128. /** @hidden */
  39129. _panningMouseButton: number;
  39130. /**
  39131. * Defines the input associated to the camera.
  39132. */
  39133. inputs: ArcRotateCameraInputsManager;
  39134. /** @hidden */
  39135. _reset: () => void;
  39136. /**
  39137. * Defines the allowed panning axis.
  39138. */
  39139. panningAxis: Vector3;
  39140. protected _localDirection: Vector3;
  39141. protected _transformedDirection: Vector3;
  39142. private _bouncingBehavior;
  39143. /**
  39144. * Gets the bouncing behavior of the camera if it has been enabled.
  39145. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39146. */
  39147. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39148. /**
  39149. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39151. */
  39152. get useBouncingBehavior(): boolean;
  39153. set useBouncingBehavior(value: boolean);
  39154. private _framingBehavior;
  39155. /**
  39156. * Gets the framing behavior of the camera if it has been enabled.
  39157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39158. */
  39159. get framingBehavior(): Nullable<FramingBehavior>;
  39160. /**
  39161. * Defines if the framing behavior of the camera is enabled on the camera.
  39162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39163. */
  39164. get useFramingBehavior(): boolean;
  39165. set useFramingBehavior(value: boolean);
  39166. private _autoRotationBehavior;
  39167. /**
  39168. * Gets the auto rotation behavior of the camera if it has been enabled.
  39169. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39170. */
  39171. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39172. /**
  39173. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39174. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39175. */
  39176. get useAutoRotationBehavior(): boolean;
  39177. set useAutoRotationBehavior(value: boolean);
  39178. /**
  39179. * Observable triggered when the mesh target has been changed on the camera.
  39180. */
  39181. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39182. /**
  39183. * Event raised when the camera is colliding with a mesh.
  39184. */
  39185. onCollide: (collidedMesh: AbstractMesh) => void;
  39186. /**
  39187. * Defines whether the camera should check collision with the objects oh the scene.
  39188. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39189. */
  39190. checkCollisions: boolean;
  39191. /**
  39192. * Defines the collision radius of the camera.
  39193. * This simulates a sphere around the camera.
  39194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39195. */
  39196. collisionRadius: Vector3;
  39197. protected _collider: Collider;
  39198. protected _previousPosition: Vector3;
  39199. protected _collisionVelocity: Vector3;
  39200. protected _newPosition: Vector3;
  39201. protected _previousAlpha: number;
  39202. protected _previousBeta: number;
  39203. protected _previousRadius: number;
  39204. protected _collisionTriggered: boolean;
  39205. protected _targetBoundingCenter: Nullable<Vector3>;
  39206. private _computationVector;
  39207. /**
  39208. * Instantiates a new ArcRotateCamera in a given scene
  39209. * @param name Defines the name of the camera
  39210. * @param alpha Defines the camera rotation along the logitudinal axis
  39211. * @param beta Defines the camera rotation along the latitudinal axis
  39212. * @param radius Defines the camera distance from its target
  39213. * @param target Defines the camera target
  39214. * @param scene Defines the scene the camera belongs to
  39215. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39216. */
  39217. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39218. /** @hidden */
  39219. _initCache(): void;
  39220. /** @hidden */
  39221. _updateCache(ignoreParentClass?: boolean): void;
  39222. protected _getTargetPosition(): Vector3;
  39223. private _storedAlpha;
  39224. private _storedBeta;
  39225. private _storedRadius;
  39226. private _storedTarget;
  39227. private _storedTargetScreenOffset;
  39228. /**
  39229. * Stores the current state of the camera (alpha, beta, radius and target)
  39230. * @returns the camera itself
  39231. */
  39232. storeState(): Camera;
  39233. /**
  39234. * @hidden
  39235. * Restored camera state. You must call storeState() first
  39236. */
  39237. _restoreStateValues(): boolean;
  39238. /** @hidden */
  39239. _isSynchronizedViewMatrix(): boolean;
  39240. /**
  39241. * Attached controls to the current camera.
  39242. * @param element Defines the element the controls should be listened from
  39243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39244. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39245. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39246. */
  39247. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39248. /**
  39249. * Detach the current controls from the camera.
  39250. * The camera will stop reacting to inputs.
  39251. * @param element Defines the element to stop listening the inputs from
  39252. */
  39253. detachControl(element: HTMLElement): void;
  39254. /** @hidden */
  39255. _checkInputs(): void;
  39256. protected _checkLimits(): void;
  39257. /**
  39258. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39259. */
  39260. rebuildAnglesAndRadius(): void;
  39261. /**
  39262. * Use a position to define the current camera related information like alpha, beta and radius
  39263. * @param position Defines the position to set the camera at
  39264. */
  39265. setPosition(position: Vector3): void;
  39266. /**
  39267. * Defines the target the camera should look at.
  39268. * This will automatically adapt alpha beta and radius to fit within the new target.
  39269. * @param target Defines the new target as a Vector or a mesh
  39270. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39271. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39272. */
  39273. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39274. /** @hidden */
  39275. _getViewMatrix(): Matrix;
  39276. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39277. /**
  39278. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39279. * @param meshes Defines the mesh to zoom on
  39280. * @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)
  39281. */
  39282. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39283. /**
  39284. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39285. * The target will be changed but the radius
  39286. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39287. * @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)
  39288. */
  39289. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39290. min: Vector3;
  39291. max: Vector3;
  39292. distance: number;
  39293. }, doNotUpdateMaxZ?: boolean): void;
  39294. /**
  39295. * @override
  39296. * Override Camera.createRigCamera
  39297. */
  39298. createRigCamera(name: string, cameraIndex: number): Camera;
  39299. /**
  39300. * @hidden
  39301. * @override
  39302. * Override Camera._updateRigCameras
  39303. */
  39304. _updateRigCameras(): void;
  39305. /**
  39306. * Destroy the camera and release the current resources hold by it.
  39307. */
  39308. dispose(): void;
  39309. /**
  39310. * Gets the current object class name.
  39311. * @return the class name
  39312. */
  39313. getClassName(): string;
  39314. }
  39315. }
  39316. declare module BABYLON {
  39317. /**
  39318. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39320. */
  39321. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39322. /**
  39323. * Gets the name of the behavior.
  39324. */
  39325. get name(): string;
  39326. private _zoomStopsAnimation;
  39327. private _idleRotationSpeed;
  39328. private _idleRotationWaitTime;
  39329. private _idleRotationSpinupTime;
  39330. /**
  39331. * Sets the flag that indicates if user zooming should stop animation.
  39332. */
  39333. set zoomStopsAnimation(flag: boolean);
  39334. /**
  39335. * Gets the flag that indicates if user zooming should stop animation.
  39336. */
  39337. get zoomStopsAnimation(): boolean;
  39338. /**
  39339. * Sets the default speed at which the camera rotates around the model.
  39340. */
  39341. set idleRotationSpeed(speed: number);
  39342. /**
  39343. * Gets the default speed at which the camera rotates around the model.
  39344. */
  39345. get idleRotationSpeed(): number;
  39346. /**
  39347. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39348. */
  39349. set idleRotationWaitTime(time: number);
  39350. /**
  39351. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39352. */
  39353. get idleRotationWaitTime(): number;
  39354. /**
  39355. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39356. */
  39357. set idleRotationSpinupTime(time: number);
  39358. /**
  39359. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39360. */
  39361. get idleRotationSpinupTime(): number;
  39362. /**
  39363. * Gets a value indicating if the camera is currently rotating because of this behavior
  39364. */
  39365. get rotationInProgress(): boolean;
  39366. private _onPrePointerObservableObserver;
  39367. private _onAfterCheckInputsObserver;
  39368. private _attachedCamera;
  39369. private _isPointerDown;
  39370. private _lastFrameTime;
  39371. private _lastInteractionTime;
  39372. private _cameraRotationSpeed;
  39373. /**
  39374. * Initializes the behavior.
  39375. */
  39376. init(): void;
  39377. /**
  39378. * Attaches the behavior to its arc rotate camera.
  39379. * @param camera Defines the camera to attach the behavior to
  39380. */
  39381. attach(camera: ArcRotateCamera): void;
  39382. /**
  39383. * Detaches the behavior from its current arc rotate camera.
  39384. */
  39385. detach(): void;
  39386. /**
  39387. * Returns true if user is scrolling.
  39388. * @return true if user is scrolling.
  39389. */
  39390. private _userIsZooming;
  39391. private _lastFrameRadius;
  39392. private _shouldAnimationStopForInteraction;
  39393. /**
  39394. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39395. */
  39396. private _applyUserInteraction;
  39397. private _userIsMoving;
  39398. }
  39399. }
  39400. declare module BABYLON {
  39401. /**
  39402. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39403. */
  39404. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39405. private ui;
  39406. /**
  39407. * The name of the behavior
  39408. */
  39409. name: string;
  39410. /**
  39411. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39412. */
  39413. distanceAwayFromFace: number;
  39414. /**
  39415. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39416. */
  39417. distanceAwayFromBottomOfFace: number;
  39418. private _faceVectors;
  39419. private _target;
  39420. private _scene;
  39421. private _onRenderObserver;
  39422. private _tmpMatrix;
  39423. private _tmpVector;
  39424. /**
  39425. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39426. * @param ui The transform node that should be attched to the mesh
  39427. */
  39428. constructor(ui: TransformNode);
  39429. /**
  39430. * Initializes the behavior
  39431. */
  39432. init(): void;
  39433. private _closestFace;
  39434. private _zeroVector;
  39435. private _lookAtTmpMatrix;
  39436. private _lookAtToRef;
  39437. /**
  39438. * Attaches the AttachToBoxBehavior to the passed in mesh
  39439. * @param target The mesh that the specified node will be attached to
  39440. */
  39441. attach(target: Mesh): void;
  39442. /**
  39443. * Detaches the behavior from the mesh
  39444. */
  39445. detach(): void;
  39446. }
  39447. }
  39448. declare module BABYLON {
  39449. /**
  39450. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39451. */
  39452. export class FadeInOutBehavior implements Behavior<Mesh> {
  39453. /**
  39454. * Time in milliseconds to delay before fading in (Default: 0)
  39455. */
  39456. delay: number;
  39457. /**
  39458. * Time in milliseconds for the mesh to fade in (Default: 300)
  39459. */
  39460. fadeInTime: number;
  39461. private _millisecondsPerFrame;
  39462. private _hovered;
  39463. private _hoverValue;
  39464. private _ownerNode;
  39465. /**
  39466. * Instatiates the FadeInOutBehavior
  39467. */
  39468. constructor();
  39469. /**
  39470. * The name of the behavior
  39471. */
  39472. get name(): string;
  39473. /**
  39474. * Initializes the behavior
  39475. */
  39476. init(): void;
  39477. /**
  39478. * Attaches the fade behavior on the passed in mesh
  39479. * @param ownerNode The mesh that will be faded in/out once attached
  39480. */
  39481. attach(ownerNode: Mesh): void;
  39482. /**
  39483. * Detaches the behavior from the mesh
  39484. */
  39485. detach(): void;
  39486. /**
  39487. * Triggers the mesh to begin fading in or out
  39488. * @param value if the object should fade in or out (true to fade in)
  39489. */
  39490. fadeIn(value: boolean): void;
  39491. private _update;
  39492. private _setAllVisibility;
  39493. }
  39494. }
  39495. declare module BABYLON {
  39496. /**
  39497. * Class containing a set of static utilities functions for managing Pivots
  39498. * @hidden
  39499. */
  39500. export class PivotTools {
  39501. private static _PivotCached;
  39502. private static _OldPivotPoint;
  39503. private static _PivotTranslation;
  39504. private static _PivotTmpVector;
  39505. /** @hidden */
  39506. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39507. /** @hidden */
  39508. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39509. }
  39510. }
  39511. declare module BABYLON {
  39512. /**
  39513. * Class containing static functions to help procedurally build meshes
  39514. */
  39515. export class PlaneBuilder {
  39516. /**
  39517. * Creates a plane mesh
  39518. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39519. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39520. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39522. * * 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
  39523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39524. * @param name defines the name of the mesh
  39525. * @param options defines the options used to create the mesh
  39526. * @param scene defines the hosting scene
  39527. * @returns the plane mesh
  39528. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39529. */
  39530. static CreatePlane(name: string, options: {
  39531. size?: number;
  39532. width?: number;
  39533. height?: number;
  39534. sideOrientation?: number;
  39535. frontUVs?: Vector4;
  39536. backUVs?: Vector4;
  39537. updatable?: boolean;
  39538. sourcePlane?: Plane;
  39539. }, scene?: Nullable<Scene>): Mesh;
  39540. }
  39541. }
  39542. declare module BABYLON {
  39543. /**
  39544. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39545. */
  39546. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39547. private static _AnyMouseID;
  39548. /**
  39549. * Abstract mesh the behavior is set on
  39550. */
  39551. attachedNode: AbstractMesh;
  39552. private _dragPlane;
  39553. private _scene;
  39554. private _pointerObserver;
  39555. private _beforeRenderObserver;
  39556. private static _planeScene;
  39557. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39558. /**
  39559. * 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)
  39560. */
  39561. maxDragAngle: number;
  39562. /**
  39563. * @hidden
  39564. */
  39565. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39566. /**
  39567. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39568. */
  39569. currentDraggingPointerID: number;
  39570. /**
  39571. * The last position where the pointer hit the drag plane in world space
  39572. */
  39573. lastDragPosition: Vector3;
  39574. /**
  39575. * If the behavior is currently in a dragging state
  39576. */
  39577. dragging: boolean;
  39578. /**
  39579. * 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)
  39580. */
  39581. dragDeltaRatio: number;
  39582. /**
  39583. * If the drag plane orientation should be updated during the dragging (Default: true)
  39584. */
  39585. updateDragPlane: boolean;
  39586. private _debugMode;
  39587. private _moving;
  39588. /**
  39589. * Fires each time the attached mesh is dragged with the pointer
  39590. * * delta between last drag position and current drag position in world space
  39591. * * dragDistance along the drag axis
  39592. * * dragPlaneNormal normal of the current drag plane used during the drag
  39593. * * dragPlanePoint in world space where the drag intersects the drag plane
  39594. */
  39595. onDragObservable: Observable<{
  39596. delta: Vector3;
  39597. dragPlanePoint: Vector3;
  39598. dragPlaneNormal: Vector3;
  39599. dragDistance: number;
  39600. pointerId: number;
  39601. }>;
  39602. /**
  39603. * Fires each time a drag begins (eg. mouse down on mesh)
  39604. */
  39605. onDragStartObservable: Observable<{
  39606. dragPlanePoint: Vector3;
  39607. pointerId: number;
  39608. }>;
  39609. /**
  39610. * Fires each time a drag ends (eg. mouse release after drag)
  39611. */
  39612. onDragEndObservable: Observable<{
  39613. dragPlanePoint: Vector3;
  39614. pointerId: number;
  39615. }>;
  39616. /**
  39617. * If the attached mesh should be moved when dragged
  39618. */
  39619. moveAttached: boolean;
  39620. /**
  39621. * If the drag behavior will react to drag events (Default: true)
  39622. */
  39623. enabled: boolean;
  39624. /**
  39625. * If pointer events should start and release the drag (Default: true)
  39626. */
  39627. startAndReleaseDragOnPointerEvents: boolean;
  39628. /**
  39629. * If camera controls should be detached during the drag
  39630. */
  39631. detachCameraControls: boolean;
  39632. /**
  39633. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39634. */
  39635. useObjectOrientationForDragging: boolean;
  39636. private _options;
  39637. /**
  39638. * Gets the options used by the behavior
  39639. */
  39640. get options(): {
  39641. dragAxis?: Vector3;
  39642. dragPlaneNormal?: Vector3;
  39643. };
  39644. /**
  39645. * Sets the options used by the behavior
  39646. */
  39647. set options(options: {
  39648. dragAxis?: Vector3;
  39649. dragPlaneNormal?: Vector3;
  39650. });
  39651. /**
  39652. * Creates a pointer drag behavior that can be attached to a mesh
  39653. * @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)
  39654. */
  39655. constructor(options?: {
  39656. dragAxis?: Vector3;
  39657. dragPlaneNormal?: Vector3;
  39658. });
  39659. /**
  39660. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39661. */
  39662. validateDrag: (targetPosition: Vector3) => boolean;
  39663. /**
  39664. * The name of the behavior
  39665. */
  39666. get name(): string;
  39667. /**
  39668. * Initializes the behavior
  39669. */
  39670. init(): void;
  39671. private _tmpVector;
  39672. private _alternatePickedPoint;
  39673. private _worldDragAxis;
  39674. private _targetPosition;
  39675. private _attachedElement;
  39676. /**
  39677. * Attaches the drag behavior the passed in mesh
  39678. * @param ownerNode The mesh that will be dragged around once attached
  39679. * @param predicate Predicate to use for pick filtering
  39680. */
  39681. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39682. /**
  39683. * Force relase the drag action by code.
  39684. */
  39685. releaseDrag(): void;
  39686. private _startDragRay;
  39687. private _lastPointerRay;
  39688. /**
  39689. * Simulates the start of a pointer drag event on the behavior
  39690. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39691. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39692. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39693. */
  39694. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39695. private _startDrag;
  39696. private _dragDelta;
  39697. private _moveDrag;
  39698. private _pickWithRayOnDragPlane;
  39699. private _pointA;
  39700. private _pointB;
  39701. private _pointC;
  39702. private _lineA;
  39703. private _lineB;
  39704. private _localAxis;
  39705. private _lookAt;
  39706. private _updateDragPlanePosition;
  39707. /**
  39708. * Detaches the behavior from the mesh
  39709. */
  39710. detach(): void;
  39711. }
  39712. }
  39713. declare module BABYLON {
  39714. /**
  39715. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39716. */
  39717. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39718. private _dragBehaviorA;
  39719. private _dragBehaviorB;
  39720. private _startDistance;
  39721. private _initialScale;
  39722. private _targetScale;
  39723. private _ownerNode;
  39724. private _sceneRenderObserver;
  39725. /**
  39726. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39727. */
  39728. constructor();
  39729. /**
  39730. * The name of the behavior
  39731. */
  39732. get name(): string;
  39733. /**
  39734. * Initializes the behavior
  39735. */
  39736. init(): void;
  39737. private _getCurrentDistance;
  39738. /**
  39739. * Attaches the scale behavior the passed in mesh
  39740. * @param ownerNode The mesh that will be scaled around once attached
  39741. */
  39742. attach(ownerNode: Mesh): void;
  39743. /**
  39744. * Detaches the behavior from the mesh
  39745. */
  39746. detach(): void;
  39747. }
  39748. }
  39749. declare module BABYLON {
  39750. /**
  39751. * 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
  39752. */
  39753. export class SixDofDragBehavior implements Behavior<Mesh> {
  39754. private static _virtualScene;
  39755. private _ownerNode;
  39756. private _sceneRenderObserver;
  39757. private _scene;
  39758. private _targetPosition;
  39759. private _virtualOriginMesh;
  39760. private _virtualDragMesh;
  39761. private _pointerObserver;
  39762. private _moving;
  39763. private _startingOrientation;
  39764. private _attachedElement;
  39765. /**
  39766. * 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)
  39767. */
  39768. private zDragFactor;
  39769. /**
  39770. * If the object should rotate to face the drag origin
  39771. */
  39772. rotateDraggedObject: boolean;
  39773. /**
  39774. * If the behavior is currently in a dragging state
  39775. */
  39776. dragging: boolean;
  39777. /**
  39778. * 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)
  39779. */
  39780. dragDeltaRatio: number;
  39781. /**
  39782. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39783. */
  39784. currentDraggingPointerID: number;
  39785. /**
  39786. * If camera controls should be detached during the drag
  39787. */
  39788. detachCameraControls: boolean;
  39789. /**
  39790. * Fires each time a drag starts
  39791. */
  39792. onDragStartObservable: Observable<{}>;
  39793. /**
  39794. * Fires each time a drag ends (eg. mouse release after drag)
  39795. */
  39796. onDragEndObservable: Observable<{}>;
  39797. /**
  39798. * 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
  39799. */
  39800. constructor();
  39801. /**
  39802. * The name of the behavior
  39803. */
  39804. get name(): string;
  39805. /**
  39806. * Initializes the behavior
  39807. */
  39808. init(): void;
  39809. /**
  39810. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39811. */
  39812. private get _pointerCamera();
  39813. /**
  39814. * Attaches the scale behavior the passed in mesh
  39815. * @param ownerNode The mesh that will be scaled around once attached
  39816. */
  39817. attach(ownerNode: Mesh): void;
  39818. /**
  39819. * Detaches the behavior from the mesh
  39820. */
  39821. detach(): void;
  39822. }
  39823. }
  39824. declare module BABYLON {
  39825. /**
  39826. * Class used to apply inverse kinematics to bones
  39827. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39828. */
  39829. export class BoneIKController {
  39830. private static _tmpVecs;
  39831. private static _tmpQuat;
  39832. private static _tmpMats;
  39833. /**
  39834. * Gets or sets the target mesh
  39835. */
  39836. targetMesh: AbstractMesh;
  39837. /** Gets or sets the mesh used as pole */
  39838. poleTargetMesh: AbstractMesh;
  39839. /**
  39840. * Gets or sets the bone used as pole
  39841. */
  39842. poleTargetBone: Nullable<Bone>;
  39843. /**
  39844. * Gets or sets the target position
  39845. */
  39846. targetPosition: Vector3;
  39847. /**
  39848. * Gets or sets the pole target position
  39849. */
  39850. poleTargetPosition: Vector3;
  39851. /**
  39852. * Gets or sets the pole target local offset
  39853. */
  39854. poleTargetLocalOffset: Vector3;
  39855. /**
  39856. * Gets or sets the pole angle
  39857. */
  39858. poleAngle: number;
  39859. /**
  39860. * Gets or sets the mesh associated with the controller
  39861. */
  39862. mesh: AbstractMesh;
  39863. /**
  39864. * 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)
  39865. */
  39866. slerpAmount: number;
  39867. private _bone1Quat;
  39868. private _bone1Mat;
  39869. private _bone2Ang;
  39870. private _bone1;
  39871. private _bone2;
  39872. private _bone1Length;
  39873. private _bone2Length;
  39874. private _maxAngle;
  39875. private _maxReach;
  39876. private _rightHandedSystem;
  39877. private _bendAxis;
  39878. private _slerping;
  39879. private _adjustRoll;
  39880. /**
  39881. * Gets or sets maximum allowed angle
  39882. */
  39883. get maxAngle(): number;
  39884. set maxAngle(value: number);
  39885. /**
  39886. * Creates a new BoneIKController
  39887. * @param mesh defines the mesh to control
  39888. * @param bone defines the bone to control
  39889. * @param options defines options to set up the controller
  39890. */
  39891. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39892. targetMesh?: AbstractMesh;
  39893. poleTargetMesh?: AbstractMesh;
  39894. poleTargetBone?: Bone;
  39895. poleTargetLocalOffset?: Vector3;
  39896. poleAngle?: number;
  39897. bendAxis?: Vector3;
  39898. maxAngle?: number;
  39899. slerpAmount?: number;
  39900. });
  39901. private _setMaxAngle;
  39902. /**
  39903. * Force the controller to update the bones
  39904. */
  39905. update(): void;
  39906. }
  39907. }
  39908. declare module BABYLON {
  39909. /**
  39910. * Class used to make a bone look toward a point in space
  39911. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39912. */
  39913. export class BoneLookController {
  39914. private static _tmpVecs;
  39915. private static _tmpQuat;
  39916. private static _tmpMats;
  39917. /**
  39918. * The target Vector3 that the bone will look at
  39919. */
  39920. target: Vector3;
  39921. /**
  39922. * The mesh that the bone is attached to
  39923. */
  39924. mesh: AbstractMesh;
  39925. /**
  39926. * The bone that will be looking to the target
  39927. */
  39928. bone: Bone;
  39929. /**
  39930. * The up axis of the coordinate system that is used when the bone is rotated
  39931. */
  39932. upAxis: Vector3;
  39933. /**
  39934. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39935. */
  39936. upAxisSpace: Space;
  39937. /**
  39938. * Used to make an adjustment to the yaw of the bone
  39939. */
  39940. adjustYaw: number;
  39941. /**
  39942. * Used to make an adjustment to the pitch of the bone
  39943. */
  39944. adjustPitch: number;
  39945. /**
  39946. * Used to make an adjustment to the roll of the bone
  39947. */
  39948. adjustRoll: number;
  39949. /**
  39950. * 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)
  39951. */
  39952. slerpAmount: number;
  39953. private _minYaw;
  39954. private _maxYaw;
  39955. private _minPitch;
  39956. private _maxPitch;
  39957. private _minYawSin;
  39958. private _minYawCos;
  39959. private _maxYawSin;
  39960. private _maxYawCos;
  39961. private _midYawConstraint;
  39962. private _minPitchTan;
  39963. private _maxPitchTan;
  39964. private _boneQuat;
  39965. private _slerping;
  39966. private _transformYawPitch;
  39967. private _transformYawPitchInv;
  39968. private _firstFrameSkipped;
  39969. private _yawRange;
  39970. private _fowardAxis;
  39971. /**
  39972. * Gets or sets the minimum yaw angle that the bone can look to
  39973. */
  39974. get minYaw(): number;
  39975. set minYaw(value: number);
  39976. /**
  39977. * Gets or sets the maximum yaw angle that the bone can look to
  39978. */
  39979. get maxYaw(): number;
  39980. set maxYaw(value: number);
  39981. /**
  39982. * Gets or sets the minimum pitch angle that the bone can look to
  39983. */
  39984. get minPitch(): number;
  39985. set minPitch(value: number);
  39986. /**
  39987. * Gets or sets the maximum pitch angle that the bone can look to
  39988. */
  39989. get maxPitch(): number;
  39990. set maxPitch(value: number);
  39991. /**
  39992. * Create a BoneLookController
  39993. * @param mesh the mesh that the bone belongs to
  39994. * @param bone the bone that will be looking to the target
  39995. * @param target the target Vector3 to look at
  39996. * @param options optional settings:
  39997. * * maxYaw: the maximum angle the bone will yaw to
  39998. * * minYaw: the minimum angle the bone will yaw to
  39999. * * maxPitch: the maximum angle the bone will pitch to
  40000. * * minPitch: the minimum angle the bone will yaw to
  40001. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40002. * * upAxis: the up axis of the coordinate system
  40003. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40004. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40005. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40006. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40007. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40008. * * adjustRoll: used to make an adjustment to the roll of the bone
  40009. **/
  40010. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40011. maxYaw?: number;
  40012. minYaw?: number;
  40013. maxPitch?: number;
  40014. minPitch?: number;
  40015. slerpAmount?: number;
  40016. upAxis?: Vector3;
  40017. upAxisSpace?: Space;
  40018. yawAxis?: Vector3;
  40019. pitchAxis?: Vector3;
  40020. adjustYaw?: number;
  40021. adjustPitch?: number;
  40022. adjustRoll?: number;
  40023. });
  40024. /**
  40025. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40026. */
  40027. update(): void;
  40028. private _getAngleDiff;
  40029. private _getAngleBetween;
  40030. private _isAngleBetween;
  40031. }
  40032. }
  40033. declare module BABYLON {
  40034. /**
  40035. * Manage the gamepad inputs to control an arc rotate camera.
  40036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40037. */
  40038. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40039. /**
  40040. * Defines the camera the input is attached to.
  40041. */
  40042. camera: ArcRotateCamera;
  40043. /**
  40044. * Defines the gamepad the input is gathering event from.
  40045. */
  40046. gamepad: Nullable<Gamepad>;
  40047. /**
  40048. * Defines the gamepad rotation sensiblity.
  40049. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40050. */
  40051. gamepadRotationSensibility: number;
  40052. /**
  40053. * Defines the gamepad move sensiblity.
  40054. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40055. */
  40056. gamepadMoveSensibility: number;
  40057. private _yAxisScale;
  40058. /**
  40059. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40060. */
  40061. get invertYAxis(): boolean;
  40062. set invertYAxis(value: boolean);
  40063. private _onGamepadConnectedObserver;
  40064. private _onGamepadDisconnectedObserver;
  40065. /**
  40066. * Attach the input controls to a specific dom element to get the input from.
  40067. * @param element Defines the element the controls should be listened from
  40068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40069. */
  40070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40071. /**
  40072. * Detach the current controls from the specified dom element.
  40073. * @param element Defines the element to stop listening the inputs from
  40074. */
  40075. detachControl(element: Nullable<HTMLElement>): void;
  40076. /**
  40077. * Update the current camera state depending on the inputs that have been used this frame.
  40078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40079. */
  40080. checkInputs(): void;
  40081. /**
  40082. * Gets the class name of the current intput.
  40083. * @returns the class name
  40084. */
  40085. getClassName(): string;
  40086. /**
  40087. * Get the friendly name associated with the input class.
  40088. * @returns the input friendly name
  40089. */
  40090. getSimpleName(): string;
  40091. }
  40092. }
  40093. declare module BABYLON {
  40094. interface ArcRotateCameraInputsManager {
  40095. /**
  40096. * Add orientation input support to the input manager.
  40097. * @returns the current input manager
  40098. */
  40099. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40100. }
  40101. /**
  40102. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40104. */
  40105. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40106. /**
  40107. * Defines the camera the input is attached to.
  40108. */
  40109. camera: ArcRotateCamera;
  40110. /**
  40111. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40112. */
  40113. alphaCorrection: number;
  40114. /**
  40115. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40116. */
  40117. gammaCorrection: number;
  40118. private _alpha;
  40119. private _gamma;
  40120. private _dirty;
  40121. private _deviceOrientationHandler;
  40122. /**
  40123. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40124. */
  40125. constructor();
  40126. /**
  40127. * Attach the input controls to a specific dom element to get the input from.
  40128. * @param element Defines the element the controls should be listened from
  40129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40130. */
  40131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40132. /** @hidden */
  40133. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40134. /**
  40135. * Update the current camera state depending on the inputs that have been used this frame.
  40136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40137. */
  40138. checkInputs(): void;
  40139. /**
  40140. * Detach the current controls from the specified dom element.
  40141. * @param element Defines the element to stop listening the inputs from
  40142. */
  40143. detachControl(element: Nullable<HTMLElement>): void;
  40144. /**
  40145. * Gets the class name of the current intput.
  40146. * @returns the class name
  40147. */
  40148. getClassName(): string;
  40149. /**
  40150. * Get the friendly name associated with the input class.
  40151. * @returns the input friendly name
  40152. */
  40153. getSimpleName(): string;
  40154. }
  40155. }
  40156. declare module BABYLON {
  40157. /**
  40158. * Listen to mouse events to control the camera.
  40159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40160. */
  40161. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40162. /**
  40163. * Defines the camera the input is attached to.
  40164. */
  40165. camera: FlyCamera;
  40166. /**
  40167. * Defines if touch is enabled. (Default is true.)
  40168. */
  40169. touchEnabled: boolean;
  40170. /**
  40171. * Defines the buttons associated with the input to handle camera rotation.
  40172. */
  40173. buttons: number[];
  40174. /**
  40175. * Assign buttons for Yaw control.
  40176. */
  40177. buttonsYaw: number[];
  40178. /**
  40179. * Assign buttons for Pitch control.
  40180. */
  40181. buttonsPitch: number[];
  40182. /**
  40183. * Assign buttons for Roll control.
  40184. */
  40185. buttonsRoll: number[];
  40186. /**
  40187. * Detect if any button is being pressed while mouse is moved.
  40188. * -1 = Mouse locked.
  40189. * 0 = Left button.
  40190. * 1 = Middle Button.
  40191. * 2 = Right Button.
  40192. */
  40193. activeButton: number;
  40194. /**
  40195. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40196. * Higher values reduce its sensitivity.
  40197. */
  40198. angularSensibility: number;
  40199. private _mousemoveCallback;
  40200. private _observer;
  40201. private _rollObserver;
  40202. private previousPosition;
  40203. private noPreventDefault;
  40204. private element;
  40205. /**
  40206. * Listen to mouse events to control the camera.
  40207. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40209. */
  40210. constructor(touchEnabled?: boolean);
  40211. /**
  40212. * Attach the mouse control to the HTML DOM element.
  40213. * @param element Defines the element that listens to the input events.
  40214. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40215. */
  40216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40217. /**
  40218. * Detach the current controls from the specified dom element.
  40219. * @param element Defines the element to stop listening the inputs from
  40220. */
  40221. detachControl(element: Nullable<HTMLElement>): void;
  40222. /**
  40223. * Gets the class name of the current input.
  40224. * @returns the class name.
  40225. */
  40226. getClassName(): string;
  40227. /**
  40228. * Get the friendly name associated with the input class.
  40229. * @returns the input's friendly name.
  40230. */
  40231. getSimpleName(): string;
  40232. private _pointerInput;
  40233. private _onMouseMove;
  40234. /**
  40235. * Rotate camera by mouse offset.
  40236. */
  40237. private rotateCamera;
  40238. }
  40239. }
  40240. declare module BABYLON {
  40241. /**
  40242. * Default Inputs manager for the FlyCamera.
  40243. * It groups all the default supported inputs for ease of use.
  40244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40245. */
  40246. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40247. /**
  40248. * Instantiates a new FlyCameraInputsManager.
  40249. * @param camera Defines the camera the inputs belong to.
  40250. */
  40251. constructor(camera: FlyCamera);
  40252. /**
  40253. * Add keyboard input support to the input manager.
  40254. * @returns the new FlyCameraKeyboardMoveInput().
  40255. */
  40256. addKeyboard(): FlyCameraInputsManager;
  40257. /**
  40258. * Add mouse input support to the input manager.
  40259. * @param touchEnabled Enable touch screen support.
  40260. * @returns the new FlyCameraMouseInput().
  40261. */
  40262. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40263. }
  40264. }
  40265. declare module BABYLON {
  40266. /**
  40267. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40268. * such as in a 3D Space Shooter or a Flight Simulator.
  40269. */
  40270. export class FlyCamera extends TargetCamera {
  40271. /**
  40272. * Define the collision ellipsoid of the camera.
  40273. * This is helpful for simulating a camera body, like a player's body.
  40274. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40275. */
  40276. ellipsoid: Vector3;
  40277. /**
  40278. * Define an offset for the position of the ellipsoid around the camera.
  40279. * This can be helpful if the camera is attached away from the player's body center,
  40280. * such as at its head.
  40281. */
  40282. ellipsoidOffset: Vector3;
  40283. /**
  40284. * Enable or disable collisions of the camera with the rest of the scene objects.
  40285. */
  40286. checkCollisions: boolean;
  40287. /**
  40288. * Enable or disable gravity on the camera.
  40289. */
  40290. applyGravity: boolean;
  40291. /**
  40292. * Define the current direction the camera is moving to.
  40293. */
  40294. cameraDirection: Vector3;
  40295. /**
  40296. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40297. * This overrides and empties cameraRotation.
  40298. */
  40299. rotationQuaternion: Quaternion;
  40300. /**
  40301. * Track Roll to maintain the wanted Rolling when looking around.
  40302. */
  40303. _trackRoll: number;
  40304. /**
  40305. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40306. */
  40307. rollCorrect: number;
  40308. /**
  40309. * Mimic a banked turn, Rolling the camera when Yawing.
  40310. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40311. */
  40312. bankedTurn: boolean;
  40313. /**
  40314. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40315. */
  40316. bankedTurnLimit: number;
  40317. /**
  40318. * Value of 0 disables the banked Roll.
  40319. * Value of 1 is equal to the Yaw angle in radians.
  40320. */
  40321. bankedTurnMultiplier: number;
  40322. /**
  40323. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40324. */
  40325. inputs: FlyCameraInputsManager;
  40326. /**
  40327. * Gets the input sensibility for mouse input.
  40328. * Higher values reduce sensitivity.
  40329. */
  40330. get angularSensibility(): number;
  40331. /**
  40332. * Sets the input sensibility for a mouse input.
  40333. * Higher values reduce sensitivity.
  40334. */
  40335. set angularSensibility(value: number);
  40336. /**
  40337. * Get the keys for camera movement forward.
  40338. */
  40339. get keysForward(): number[];
  40340. /**
  40341. * Set the keys for camera movement forward.
  40342. */
  40343. set keysForward(value: number[]);
  40344. /**
  40345. * Get the keys for camera movement backward.
  40346. */
  40347. get keysBackward(): number[];
  40348. set keysBackward(value: number[]);
  40349. /**
  40350. * Get the keys for camera movement up.
  40351. */
  40352. get keysUp(): number[];
  40353. /**
  40354. * Set the keys for camera movement up.
  40355. */
  40356. set keysUp(value: number[]);
  40357. /**
  40358. * Get the keys for camera movement down.
  40359. */
  40360. get keysDown(): number[];
  40361. /**
  40362. * Set the keys for camera movement down.
  40363. */
  40364. set keysDown(value: number[]);
  40365. /**
  40366. * Get the keys for camera movement left.
  40367. */
  40368. get keysLeft(): number[];
  40369. /**
  40370. * Set the keys for camera movement left.
  40371. */
  40372. set keysLeft(value: number[]);
  40373. /**
  40374. * Set the keys for camera movement right.
  40375. */
  40376. get keysRight(): number[];
  40377. /**
  40378. * Set the keys for camera movement right.
  40379. */
  40380. set keysRight(value: number[]);
  40381. /**
  40382. * Event raised when the camera collides with a mesh in the scene.
  40383. */
  40384. onCollide: (collidedMesh: AbstractMesh) => void;
  40385. private _collider;
  40386. private _needMoveForGravity;
  40387. private _oldPosition;
  40388. private _diffPosition;
  40389. private _newPosition;
  40390. /** @hidden */
  40391. _localDirection: Vector3;
  40392. /** @hidden */
  40393. _transformedDirection: Vector3;
  40394. /**
  40395. * Instantiates a FlyCamera.
  40396. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40397. * such as in a 3D Space Shooter or a Flight Simulator.
  40398. * @param name Define the name of the camera in the scene.
  40399. * @param position Define the starting position of the camera in the scene.
  40400. * @param scene Define the scene the camera belongs to.
  40401. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40402. */
  40403. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40404. /**
  40405. * Attach a control to the HTML DOM element.
  40406. * @param element Defines the element that listens to the input events.
  40407. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40408. */
  40409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40410. /**
  40411. * Detach a control from the HTML DOM element.
  40412. * The camera will stop reacting to that input.
  40413. * @param element Defines the element that listens to the input events.
  40414. */
  40415. detachControl(element: HTMLElement): void;
  40416. private _collisionMask;
  40417. /**
  40418. * Get the mask that the camera ignores in collision events.
  40419. */
  40420. get collisionMask(): number;
  40421. /**
  40422. * Set the mask that the camera ignores in collision events.
  40423. */
  40424. set collisionMask(mask: number);
  40425. /** @hidden */
  40426. _collideWithWorld(displacement: Vector3): void;
  40427. /** @hidden */
  40428. private _onCollisionPositionChange;
  40429. /** @hidden */
  40430. _checkInputs(): void;
  40431. /** @hidden */
  40432. _decideIfNeedsToMove(): boolean;
  40433. /** @hidden */
  40434. _updatePosition(): void;
  40435. /**
  40436. * Restore the Roll to its target value at the rate specified.
  40437. * @param rate - Higher means slower restoring.
  40438. * @hidden
  40439. */
  40440. restoreRoll(rate: number): void;
  40441. /**
  40442. * Destroy the camera and release the current resources held by it.
  40443. */
  40444. dispose(): void;
  40445. /**
  40446. * Get the current object class name.
  40447. * @returns the class name.
  40448. */
  40449. getClassName(): string;
  40450. }
  40451. }
  40452. declare module BABYLON {
  40453. /**
  40454. * Listen to keyboard events to control the camera.
  40455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40456. */
  40457. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40458. /**
  40459. * Defines the camera the input is attached to.
  40460. */
  40461. camera: FlyCamera;
  40462. /**
  40463. * The list of keyboard keys used to control the forward move of the camera.
  40464. */
  40465. keysForward: number[];
  40466. /**
  40467. * The list of keyboard keys used to control the backward move of the camera.
  40468. */
  40469. keysBackward: number[];
  40470. /**
  40471. * The list of keyboard keys used to control the forward move of the camera.
  40472. */
  40473. keysUp: number[];
  40474. /**
  40475. * The list of keyboard keys used to control the backward move of the camera.
  40476. */
  40477. keysDown: number[];
  40478. /**
  40479. * The list of keyboard keys used to control the right strafe move of the camera.
  40480. */
  40481. keysRight: number[];
  40482. /**
  40483. * The list of keyboard keys used to control the left strafe move of the camera.
  40484. */
  40485. keysLeft: number[];
  40486. private _keys;
  40487. private _onCanvasBlurObserver;
  40488. private _onKeyboardObserver;
  40489. private _engine;
  40490. private _scene;
  40491. /**
  40492. * Attach the input controls to a specific dom element to get the input from.
  40493. * @param element Defines the element the controls should be listened from
  40494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40495. */
  40496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40497. /**
  40498. * Detach the current controls from the specified dom element.
  40499. * @param element Defines the element to stop listening the inputs from
  40500. */
  40501. detachControl(element: Nullable<HTMLElement>): void;
  40502. /**
  40503. * Gets the class name of the current intput.
  40504. * @returns the class name
  40505. */
  40506. getClassName(): string;
  40507. /** @hidden */
  40508. _onLostFocus(e: FocusEvent): void;
  40509. /**
  40510. * Get the friendly name associated with the input class.
  40511. * @returns the input friendly name
  40512. */
  40513. getSimpleName(): string;
  40514. /**
  40515. * Update the current camera state depending on the inputs that have been used this frame.
  40516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40517. */
  40518. checkInputs(): void;
  40519. }
  40520. }
  40521. declare module BABYLON {
  40522. /**
  40523. * Manage the mouse wheel inputs to control a follow camera.
  40524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40525. */
  40526. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40527. /**
  40528. * Defines the camera the input is attached to.
  40529. */
  40530. camera: FollowCamera;
  40531. /**
  40532. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40533. */
  40534. axisControlRadius: boolean;
  40535. /**
  40536. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40537. */
  40538. axisControlHeight: boolean;
  40539. /**
  40540. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40541. */
  40542. axisControlRotation: boolean;
  40543. /**
  40544. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40545. * relation to mouseWheel events.
  40546. */
  40547. wheelPrecision: number;
  40548. /**
  40549. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40550. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40551. */
  40552. wheelDeltaPercentage: number;
  40553. private _wheel;
  40554. private _observer;
  40555. /**
  40556. * Attach the input controls to a specific dom element to get the input from.
  40557. * @param element Defines the element the controls should be listened from
  40558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40559. */
  40560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40561. /**
  40562. * Detach the current controls from the specified dom element.
  40563. * @param element Defines the element to stop listening the inputs from
  40564. */
  40565. detachControl(element: Nullable<HTMLElement>): void;
  40566. /**
  40567. * Gets the class name of the current intput.
  40568. * @returns the class name
  40569. */
  40570. getClassName(): string;
  40571. /**
  40572. * Get the friendly name associated with the input class.
  40573. * @returns the input friendly name
  40574. */
  40575. getSimpleName(): string;
  40576. }
  40577. }
  40578. declare module BABYLON {
  40579. /**
  40580. * Manage the pointers inputs to control an follow camera.
  40581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40582. */
  40583. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40584. /**
  40585. * Defines the camera the input is attached to.
  40586. */
  40587. camera: FollowCamera;
  40588. /**
  40589. * Gets the class name of the current input.
  40590. * @returns the class name
  40591. */
  40592. getClassName(): string;
  40593. /**
  40594. * Defines the pointer angular sensibility along the X axis or how fast is
  40595. * the camera rotating.
  40596. * A negative number will reverse the axis direction.
  40597. */
  40598. angularSensibilityX: number;
  40599. /**
  40600. * Defines the pointer angular sensibility along the Y axis or how fast is
  40601. * the camera rotating.
  40602. * A negative number will reverse the axis direction.
  40603. */
  40604. angularSensibilityY: number;
  40605. /**
  40606. * Defines the pointer pinch precision or how fast is the camera zooming.
  40607. * A negative number will reverse the axis direction.
  40608. */
  40609. pinchPrecision: number;
  40610. /**
  40611. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40612. * from 0.
  40613. * It defines the percentage of current camera.radius to use as delta when
  40614. * pinch zoom is used.
  40615. */
  40616. pinchDeltaPercentage: number;
  40617. /**
  40618. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40619. */
  40620. axisXControlRadius: boolean;
  40621. /**
  40622. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40623. */
  40624. axisXControlHeight: boolean;
  40625. /**
  40626. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40627. */
  40628. axisXControlRotation: boolean;
  40629. /**
  40630. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40631. */
  40632. axisYControlRadius: boolean;
  40633. /**
  40634. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40635. */
  40636. axisYControlHeight: boolean;
  40637. /**
  40638. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40639. */
  40640. axisYControlRotation: boolean;
  40641. /**
  40642. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40643. */
  40644. axisPinchControlRadius: boolean;
  40645. /**
  40646. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40647. */
  40648. axisPinchControlHeight: boolean;
  40649. /**
  40650. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40651. */
  40652. axisPinchControlRotation: boolean;
  40653. /**
  40654. * Log error messages if basic misconfiguration has occurred.
  40655. */
  40656. warningEnable: boolean;
  40657. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40658. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40659. private _warningCounter;
  40660. private _warning;
  40661. }
  40662. }
  40663. declare module BABYLON {
  40664. /**
  40665. * Default Inputs manager for the FollowCamera.
  40666. * It groups all the default supported inputs for ease of use.
  40667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40668. */
  40669. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40670. /**
  40671. * Instantiates a new FollowCameraInputsManager.
  40672. * @param camera Defines the camera the inputs belong to
  40673. */
  40674. constructor(camera: FollowCamera);
  40675. /**
  40676. * Add keyboard input support to the input manager.
  40677. * @returns the current input manager
  40678. */
  40679. addKeyboard(): FollowCameraInputsManager;
  40680. /**
  40681. * Add mouse wheel input support to the input manager.
  40682. * @returns the current input manager
  40683. */
  40684. addMouseWheel(): FollowCameraInputsManager;
  40685. /**
  40686. * Add pointers input support to the input manager.
  40687. * @returns the current input manager
  40688. */
  40689. addPointers(): FollowCameraInputsManager;
  40690. /**
  40691. * Add orientation input support to the input manager.
  40692. * @returns the current input manager
  40693. */
  40694. addVRDeviceOrientation(): FollowCameraInputsManager;
  40695. }
  40696. }
  40697. declare module BABYLON {
  40698. /**
  40699. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40700. * an arc rotate version arcFollowCamera are available.
  40701. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40702. */
  40703. export class FollowCamera extends TargetCamera {
  40704. /**
  40705. * Distance the follow camera should follow an object at
  40706. */
  40707. radius: number;
  40708. /**
  40709. * Minimum allowed distance of the camera to the axis of rotation
  40710. * (The camera can not get closer).
  40711. * This can help limiting how the Camera is able to move in the scene.
  40712. */
  40713. lowerRadiusLimit: Nullable<number>;
  40714. /**
  40715. * Maximum allowed distance of the camera to the axis of rotation
  40716. * (The camera can not get further).
  40717. * This can help limiting how the Camera is able to move in the scene.
  40718. */
  40719. upperRadiusLimit: Nullable<number>;
  40720. /**
  40721. * Define a rotation offset between the camera and the object it follows
  40722. */
  40723. rotationOffset: number;
  40724. /**
  40725. * Minimum allowed angle to camera position relative to target object.
  40726. * This can help limiting how the Camera is able to move in the scene.
  40727. */
  40728. lowerRotationOffsetLimit: Nullable<number>;
  40729. /**
  40730. * Maximum allowed angle to camera position relative to target object.
  40731. * This can help limiting how the Camera is able to move in the scene.
  40732. */
  40733. upperRotationOffsetLimit: Nullable<number>;
  40734. /**
  40735. * Define a height offset between the camera and the object it follows.
  40736. * It can help following an object from the top (like a car chaing a plane)
  40737. */
  40738. heightOffset: number;
  40739. /**
  40740. * Minimum allowed height of camera position relative to target object.
  40741. * This can help limiting how the Camera is able to move in the scene.
  40742. */
  40743. lowerHeightOffsetLimit: Nullable<number>;
  40744. /**
  40745. * Maximum allowed height of camera position relative to target object.
  40746. * This can help limiting how the Camera is able to move in the scene.
  40747. */
  40748. upperHeightOffsetLimit: Nullable<number>;
  40749. /**
  40750. * Define how fast the camera can accelerate to follow it s target.
  40751. */
  40752. cameraAcceleration: number;
  40753. /**
  40754. * Define the speed limit of the camera following an object.
  40755. */
  40756. maxCameraSpeed: number;
  40757. /**
  40758. * Define the target of the camera.
  40759. */
  40760. lockedTarget: Nullable<AbstractMesh>;
  40761. /**
  40762. * Defines the input associated with the camera.
  40763. */
  40764. inputs: FollowCameraInputsManager;
  40765. /**
  40766. * Instantiates the follow camera.
  40767. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40768. * @param name Define the name of the camera in the scene
  40769. * @param position Define the position of the camera
  40770. * @param scene Define the scene the camera belong to
  40771. * @param lockedTarget Define the target of the camera
  40772. */
  40773. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40774. private _follow;
  40775. /**
  40776. * Attached controls to the current camera.
  40777. * @param element Defines the element the controls should be listened from
  40778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40779. */
  40780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40781. /**
  40782. * Detach the current controls from the camera.
  40783. * The camera will stop reacting to inputs.
  40784. * @param element Defines the element to stop listening the inputs from
  40785. */
  40786. detachControl(element: HTMLElement): void;
  40787. /** @hidden */
  40788. _checkInputs(): void;
  40789. private _checkLimits;
  40790. /**
  40791. * Gets the camera class name.
  40792. * @returns the class name
  40793. */
  40794. getClassName(): string;
  40795. }
  40796. /**
  40797. * Arc Rotate version of the follow camera.
  40798. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40799. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40800. */
  40801. export class ArcFollowCamera extends TargetCamera {
  40802. /** The longitudinal angle of the camera */
  40803. alpha: number;
  40804. /** The latitudinal angle of the camera */
  40805. beta: number;
  40806. /** The radius of the camera from its target */
  40807. radius: number;
  40808. /** Define the camera target (the messh it should follow) */
  40809. target: Nullable<AbstractMesh>;
  40810. private _cartesianCoordinates;
  40811. /**
  40812. * Instantiates a new ArcFollowCamera
  40813. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40814. * @param name Define the name of the camera
  40815. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40816. * @param beta Define the rotation angle of the camera around the elevation axis
  40817. * @param radius Define the radius of the camera from its target point
  40818. * @param target Define the target of the camera
  40819. * @param scene Define the scene the camera belongs to
  40820. */
  40821. constructor(name: string,
  40822. /** The longitudinal angle of the camera */
  40823. alpha: number,
  40824. /** The latitudinal angle of the camera */
  40825. beta: number,
  40826. /** The radius of the camera from its target */
  40827. radius: number,
  40828. /** Define the camera target (the messh it should follow) */
  40829. target: Nullable<AbstractMesh>, scene: Scene);
  40830. private _follow;
  40831. /** @hidden */
  40832. _checkInputs(): void;
  40833. /**
  40834. * Returns the class name of the object.
  40835. * It is mostly used internally for serialization purposes.
  40836. */
  40837. getClassName(): string;
  40838. }
  40839. }
  40840. declare module BABYLON {
  40841. /**
  40842. * Manage the keyboard inputs to control the movement of a follow camera.
  40843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40844. */
  40845. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40846. /**
  40847. * Defines the camera the input is attached to.
  40848. */
  40849. camera: FollowCamera;
  40850. /**
  40851. * Defines the list of key codes associated with the up action (increase heightOffset)
  40852. */
  40853. keysHeightOffsetIncr: number[];
  40854. /**
  40855. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40856. */
  40857. keysHeightOffsetDecr: number[];
  40858. /**
  40859. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40860. */
  40861. keysHeightOffsetModifierAlt: boolean;
  40862. /**
  40863. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40864. */
  40865. keysHeightOffsetModifierCtrl: boolean;
  40866. /**
  40867. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40868. */
  40869. keysHeightOffsetModifierShift: boolean;
  40870. /**
  40871. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40872. */
  40873. keysRotationOffsetIncr: number[];
  40874. /**
  40875. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40876. */
  40877. keysRotationOffsetDecr: number[];
  40878. /**
  40879. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40880. */
  40881. keysRotationOffsetModifierAlt: boolean;
  40882. /**
  40883. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40884. */
  40885. keysRotationOffsetModifierCtrl: boolean;
  40886. /**
  40887. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40888. */
  40889. keysRotationOffsetModifierShift: boolean;
  40890. /**
  40891. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40892. */
  40893. keysRadiusIncr: number[];
  40894. /**
  40895. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40896. */
  40897. keysRadiusDecr: number[];
  40898. /**
  40899. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40900. */
  40901. keysRadiusModifierAlt: boolean;
  40902. /**
  40903. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40904. */
  40905. keysRadiusModifierCtrl: boolean;
  40906. /**
  40907. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40908. */
  40909. keysRadiusModifierShift: boolean;
  40910. /**
  40911. * Defines the rate of change of heightOffset.
  40912. */
  40913. heightSensibility: number;
  40914. /**
  40915. * Defines the rate of change of rotationOffset.
  40916. */
  40917. rotationSensibility: number;
  40918. /**
  40919. * Defines the rate of change of radius.
  40920. */
  40921. radiusSensibility: number;
  40922. private _keys;
  40923. private _ctrlPressed;
  40924. private _altPressed;
  40925. private _shiftPressed;
  40926. private _onCanvasBlurObserver;
  40927. private _onKeyboardObserver;
  40928. private _engine;
  40929. private _scene;
  40930. /**
  40931. * Attach the input controls to a specific dom element to get the input from.
  40932. * @param element Defines the element the controls should be listened from
  40933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40934. */
  40935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40936. /**
  40937. * Detach the current controls from the specified dom element.
  40938. * @param element Defines the element to stop listening the inputs from
  40939. */
  40940. detachControl(element: Nullable<HTMLElement>): void;
  40941. /**
  40942. * Update the current camera state depending on the inputs that have been used this frame.
  40943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40944. */
  40945. checkInputs(): void;
  40946. /**
  40947. * Gets the class name of the current input.
  40948. * @returns the class name
  40949. */
  40950. getClassName(): string;
  40951. /**
  40952. * Get the friendly name associated with the input class.
  40953. * @returns the input friendly name
  40954. */
  40955. getSimpleName(): string;
  40956. /**
  40957. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40958. * allow modification of the heightOffset value.
  40959. */
  40960. private _modifierHeightOffset;
  40961. /**
  40962. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40963. * allow modification of the rotationOffset value.
  40964. */
  40965. private _modifierRotationOffset;
  40966. /**
  40967. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40968. * allow modification of the radius value.
  40969. */
  40970. private _modifierRadius;
  40971. }
  40972. }
  40973. declare module BABYLON {
  40974. interface FreeCameraInputsManager {
  40975. /**
  40976. * @hidden
  40977. */
  40978. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40979. /**
  40980. * Add orientation input support to the input manager.
  40981. * @returns the current input manager
  40982. */
  40983. addDeviceOrientation(): FreeCameraInputsManager;
  40984. }
  40985. /**
  40986. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40987. * Screen rotation is taken into account.
  40988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40989. */
  40990. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40991. private _camera;
  40992. private _screenOrientationAngle;
  40993. private _constantTranform;
  40994. private _screenQuaternion;
  40995. private _alpha;
  40996. private _beta;
  40997. private _gamma;
  40998. /**
  40999. * Can be used to detect if a device orientation sensor is available on a device
  41000. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41001. * @returns a promise that will resolve on orientation change
  41002. */
  41003. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41004. /**
  41005. * @hidden
  41006. */
  41007. _onDeviceOrientationChangedObservable: Observable<void>;
  41008. /**
  41009. * Instantiates a new input
  41010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41011. */
  41012. constructor();
  41013. /**
  41014. * Define the camera controlled by the input.
  41015. */
  41016. get camera(): FreeCamera;
  41017. set camera(camera: FreeCamera);
  41018. /**
  41019. * Attach the input controls to a specific dom element to get the input from.
  41020. * @param element Defines the element the controls should be listened from
  41021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41022. */
  41023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41024. private _orientationChanged;
  41025. private _deviceOrientation;
  41026. /**
  41027. * Detach the current controls from the specified dom element.
  41028. * @param element Defines the element to stop listening the inputs from
  41029. */
  41030. detachControl(element: Nullable<HTMLElement>): void;
  41031. /**
  41032. * Update the current camera state depending on the inputs that have been used this frame.
  41033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41034. */
  41035. checkInputs(): void;
  41036. /**
  41037. * Gets the class name of the current intput.
  41038. * @returns the class name
  41039. */
  41040. getClassName(): string;
  41041. /**
  41042. * Get the friendly name associated with the input class.
  41043. * @returns the input friendly name
  41044. */
  41045. getSimpleName(): string;
  41046. }
  41047. }
  41048. declare module BABYLON {
  41049. /**
  41050. * Manage the gamepad inputs to control a free camera.
  41051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41052. */
  41053. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41054. /**
  41055. * Define the camera the input is attached to.
  41056. */
  41057. camera: FreeCamera;
  41058. /**
  41059. * Define the Gamepad controlling the input
  41060. */
  41061. gamepad: Nullable<Gamepad>;
  41062. /**
  41063. * Defines the gamepad rotation sensiblity.
  41064. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41065. */
  41066. gamepadAngularSensibility: number;
  41067. /**
  41068. * Defines the gamepad move sensiblity.
  41069. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41070. */
  41071. gamepadMoveSensibility: number;
  41072. private _yAxisScale;
  41073. /**
  41074. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41075. */
  41076. get invertYAxis(): boolean;
  41077. set invertYAxis(value: boolean);
  41078. private _onGamepadConnectedObserver;
  41079. private _onGamepadDisconnectedObserver;
  41080. private _cameraTransform;
  41081. private _deltaTransform;
  41082. private _vector3;
  41083. private _vector2;
  41084. /**
  41085. * Attach the input controls to a specific dom element to get the input from.
  41086. * @param element Defines the element the controls should be listened from
  41087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41088. */
  41089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41090. /**
  41091. * Detach the current controls from the specified dom element.
  41092. * @param element Defines the element to stop listening the inputs from
  41093. */
  41094. detachControl(element: Nullable<HTMLElement>): void;
  41095. /**
  41096. * Update the current camera state depending on the inputs that have been used this frame.
  41097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41098. */
  41099. checkInputs(): void;
  41100. /**
  41101. * Gets the class name of the current intput.
  41102. * @returns the class name
  41103. */
  41104. getClassName(): string;
  41105. /**
  41106. * Get the friendly name associated with the input class.
  41107. * @returns the input friendly name
  41108. */
  41109. getSimpleName(): string;
  41110. }
  41111. }
  41112. declare module BABYLON {
  41113. /**
  41114. * Defines the potential axis of a Joystick
  41115. */
  41116. export enum JoystickAxis {
  41117. /** X axis */
  41118. X = 0,
  41119. /** Y axis */
  41120. Y = 1,
  41121. /** Z axis */
  41122. Z = 2
  41123. }
  41124. /**
  41125. * Class used to define virtual joystick (used in touch mode)
  41126. */
  41127. export class VirtualJoystick {
  41128. /**
  41129. * Gets or sets a boolean indicating that left and right values must be inverted
  41130. */
  41131. reverseLeftRight: boolean;
  41132. /**
  41133. * Gets or sets a boolean indicating that up and down values must be inverted
  41134. */
  41135. reverseUpDown: boolean;
  41136. /**
  41137. * Gets the offset value for the position (ie. the change of the position value)
  41138. */
  41139. deltaPosition: Vector3;
  41140. /**
  41141. * Gets a boolean indicating if the virtual joystick was pressed
  41142. */
  41143. pressed: boolean;
  41144. /**
  41145. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41146. */
  41147. static Canvas: Nullable<HTMLCanvasElement>;
  41148. private static _globalJoystickIndex;
  41149. private static vjCanvasContext;
  41150. private static vjCanvasWidth;
  41151. private static vjCanvasHeight;
  41152. private static halfWidth;
  41153. private _action;
  41154. private _axisTargetedByLeftAndRight;
  41155. private _axisTargetedByUpAndDown;
  41156. private _joystickSensibility;
  41157. private _inversedSensibility;
  41158. private _joystickPointerID;
  41159. private _joystickColor;
  41160. private _joystickPointerPos;
  41161. private _joystickPreviousPointerPos;
  41162. private _joystickPointerStartPos;
  41163. private _deltaJoystickVector;
  41164. private _leftJoystick;
  41165. private _touches;
  41166. private _onPointerDownHandlerRef;
  41167. private _onPointerMoveHandlerRef;
  41168. private _onPointerUpHandlerRef;
  41169. private _onResize;
  41170. /**
  41171. * Creates a new virtual joystick
  41172. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41173. */
  41174. constructor(leftJoystick?: boolean);
  41175. /**
  41176. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41177. * @param newJoystickSensibility defines the new sensibility
  41178. */
  41179. setJoystickSensibility(newJoystickSensibility: number): void;
  41180. private _onPointerDown;
  41181. private _onPointerMove;
  41182. private _onPointerUp;
  41183. /**
  41184. * Change the color of the virtual joystick
  41185. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41186. */
  41187. setJoystickColor(newColor: string): void;
  41188. /**
  41189. * Defines a callback to call when the joystick is touched
  41190. * @param action defines the callback
  41191. */
  41192. setActionOnTouch(action: () => any): void;
  41193. /**
  41194. * Defines which axis you'd like to control for left & right
  41195. * @param axis defines the axis to use
  41196. */
  41197. setAxisForLeftRight(axis: JoystickAxis): void;
  41198. /**
  41199. * Defines which axis you'd like to control for up & down
  41200. * @param axis defines the axis to use
  41201. */
  41202. setAxisForUpDown(axis: JoystickAxis): void;
  41203. private _drawVirtualJoystick;
  41204. /**
  41205. * Release internal HTML canvas
  41206. */
  41207. releaseCanvas(): void;
  41208. }
  41209. }
  41210. declare module BABYLON {
  41211. interface FreeCameraInputsManager {
  41212. /**
  41213. * Add virtual joystick input support to the input manager.
  41214. * @returns the current input manager
  41215. */
  41216. addVirtualJoystick(): FreeCameraInputsManager;
  41217. }
  41218. /**
  41219. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41221. */
  41222. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41223. /**
  41224. * Defines the camera the input is attached to.
  41225. */
  41226. camera: FreeCamera;
  41227. private _leftjoystick;
  41228. private _rightjoystick;
  41229. /**
  41230. * Gets the left stick of the virtual joystick.
  41231. * @returns The virtual Joystick
  41232. */
  41233. getLeftJoystick(): VirtualJoystick;
  41234. /**
  41235. * Gets the right stick of the virtual joystick.
  41236. * @returns The virtual Joystick
  41237. */
  41238. getRightJoystick(): VirtualJoystick;
  41239. /**
  41240. * Update the current camera state depending on the inputs that have been used this frame.
  41241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41242. */
  41243. checkInputs(): void;
  41244. /**
  41245. * Attach the input controls to a specific dom element to get the input from.
  41246. * @param element Defines the element the controls should be listened from
  41247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41248. */
  41249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41250. /**
  41251. * Detach the current controls from the specified dom element.
  41252. * @param element Defines the element to stop listening the inputs from
  41253. */
  41254. detachControl(element: Nullable<HTMLElement>): void;
  41255. /**
  41256. * Gets the class name of the current intput.
  41257. * @returns the class name
  41258. */
  41259. getClassName(): string;
  41260. /**
  41261. * Get the friendly name associated with the input class.
  41262. * @returns the input friendly name
  41263. */
  41264. getSimpleName(): string;
  41265. }
  41266. }
  41267. declare module BABYLON {
  41268. /**
  41269. * This represents a FPS type of camera controlled by touch.
  41270. * This is like a universal camera minus the Gamepad controls.
  41271. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41272. */
  41273. export class TouchCamera extends FreeCamera {
  41274. /**
  41275. * Defines the touch sensibility for rotation.
  41276. * The higher the faster.
  41277. */
  41278. get touchAngularSensibility(): number;
  41279. set touchAngularSensibility(value: number);
  41280. /**
  41281. * Defines the touch sensibility for move.
  41282. * The higher the faster.
  41283. */
  41284. get touchMoveSensibility(): number;
  41285. set touchMoveSensibility(value: number);
  41286. /**
  41287. * Instantiates a new touch camera.
  41288. * This represents a FPS type of camera controlled by touch.
  41289. * This is like a universal camera minus the Gamepad controls.
  41290. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41291. * @param name Define the name of the camera in the scene
  41292. * @param position Define the start position of the camera in the scene
  41293. * @param scene Define the scene the camera belongs to
  41294. */
  41295. constructor(name: string, position: Vector3, scene: Scene);
  41296. /**
  41297. * Gets the current object class name.
  41298. * @return the class name
  41299. */
  41300. getClassName(): string;
  41301. /** @hidden */
  41302. _setupInputs(): void;
  41303. }
  41304. }
  41305. declare module BABYLON {
  41306. /**
  41307. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41308. * being tilted forward or back and left or right.
  41309. */
  41310. export class DeviceOrientationCamera extends FreeCamera {
  41311. private _initialQuaternion;
  41312. private _quaternionCache;
  41313. private _tmpDragQuaternion;
  41314. private _disablePointerInputWhenUsingDeviceOrientation;
  41315. /**
  41316. * Creates a new device orientation camera
  41317. * @param name The name of the camera
  41318. * @param position The start position camera
  41319. * @param scene The scene the camera belongs to
  41320. */
  41321. constructor(name: string, position: Vector3, scene: Scene);
  41322. /**
  41323. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41324. */
  41325. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41326. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41327. private _dragFactor;
  41328. /**
  41329. * Enabled turning on the y axis when the orientation sensor is active
  41330. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41331. */
  41332. enableHorizontalDragging(dragFactor?: number): void;
  41333. /**
  41334. * Gets the current instance class name ("DeviceOrientationCamera").
  41335. * This helps avoiding instanceof at run time.
  41336. * @returns the class name
  41337. */
  41338. getClassName(): string;
  41339. /**
  41340. * @hidden
  41341. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41342. */
  41343. _checkInputs(): void;
  41344. /**
  41345. * Reset the camera to its default orientation on the specified axis only.
  41346. * @param axis The axis to reset
  41347. */
  41348. resetToCurrentRotation(axis?: Axis): void;
  41349. }
  41350. }
  41351. declare module BABYLON {
  41352. /**
  41353. * Defines supported buttons for XBox360 compatible gamepads
  41354. */
  41355. export enum Xbox360Button {
  41356. /** A */
  41357. A = 0,
  41358. /** B */
  41359. B = 1,
  41360. /** X */
  41361. X = 2,
  41362. /** Y */
  41363. Y = 3,
  41364. /** Left button */
  41365. LB = 4,
  41366. /** Right button */
  41367. RB = 5,
  41368. /** Back */
  41369. Back = 8,
  41370. /** Start */
  41371. Start = 9,
  41372. /** Left stick */
  41373. LeftStick = 10,
  41374. /** Right stick */
  41375. RightStick = 11
  41376. }
  41377. /** Defines values for XBox360 DPad */
  41378. export enum Xbox360Dpad {
  41379. /** Up */
  41380. Up = 12,
  41381. /** Down */
  41382. Down = 13,
  41383. /** Left */
  41384. Left = 14,
  41385. /** Right */
  41386. Right = 15
  41387. }
  41388. /**
  41389. * Defines a XBox360 gamepad
  41390. */
  41391. export class Xbox360Pad extends Gamepad {
  41392. private _leftTrigger;
  41393. private _rightTrigger;
  41394. private _onlefttriggerchanged;
  41395. private _onrighttriggerchanged;
  41396. private _onbuttondown;
  41397. private _onbuttonup;
  41398. private _ondpaddown;
  41399. private _ondpadup;
  41400. /** Observable raised when a button is pressed */
  41401. onButtonDownObservable: Observable<Xbox360Button>;
  41402. /** Observable raised when a button is released */
  41403. onButtonUpObservable: Observable<Xbox360Button>;
  41404. /** Observable raised when a pad is pressed */
  41405. onPadDownObservable: Observable<Xbox360Dpad>;
  41406. /** Observable raised when a pad is released */
  41407. onPadUpObservable: Observable<Xbox360Dpad>;
  41408. private _buttonA;
  41409. private _buttonB;
  41410. private _buttonX;
  41411. private _buttonY;
  41412. private _buttonBack;
  41413. private _buttonStart;
  41414. private _buttonLB;
  41415. private _buttonRB;
  41416. private _buttonLeftStick;
  41417. private _buttonRightStick;
  41418. private _dPadUp;
  41419. private _dPadDown;
  41420. private _dPadLeft;
  41421. private _dPadRight;
  41422. private _isXboxOnePad;
  41423. /**
  41424. * Creates a new XBox360 gamepad object
  41425. * @param id defines the id of this gamepad
  41426. * @param index defines its index
  41427. * @param gamepad defines the internal HTML gamepad object
  41428. * @param xboxOne defines if it is a XBox One gamepad
  41429. */
  41430. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41431. /**
  41432. * Defines the callback to call when left trigger is pressed
  41433. * @param callback defines the callback to use
  41434. */
  41435. onlefttriggerchanged(callback: (value: number) => void): void;
  41436. /**
  41437. * Defines the callback to call when right trigger is pressed
  41438. * @param callback defines the callback to use
  41439. */
  41440. onrighttriggerchanged(callback: (value: number) => void): void;
  41441. /**
  41442. * Gets the left trigger value
  41443. */
  41444. get leftTrigger(): number;
  41445. /**
  41446. * Sets the left trigger value
  41447. */
  41448. set leftTrigger(newValue: number);
  41449. /**
  41450. * Gets the right trigger value
  41451. */
  41452. get rightTrigger(): number;
  41453. /**
  41454. * Sets the right trigger value
  41455. */
  41456. set rightTrigger(newValue: number);
  41457. /**
  41458. * Defines the callback to call when a button is pressed
  41459. * @param callback defines the callback to use
  41460. */
  41461. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41462. /**
  41463. * Defines the callback to call when a button is released
  41464. * @param callback defines the callback to use
  41465. */
  41466. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41467. /**
  41468. * Defines the callback to call when a pad is pressed
  41469. * @param callback defines the callback to use
  41470. */
  41471. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41472. /**
  41473. * Defines the callback to call when a pad is released
  41474. * @param callback defines the callback to use
  41475. */
  41476. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41477. private _setButtonValue;
  41478. private _setDPadValue;
  41479. /**
  41480. * Gets the value of the `A` button
  41481. */
  41482. get buttonA(): number;
  41483. /**
  41484. * Sets the value of the `A` button
  41485. */
  41486. set buttonA(value: number);
  41487. /**
  41488. * Gets the value of the `B` button
  41489. */
  41490. get buttonB(): number;
  41491. /**
  41492. * Sets the value of the `B` button
  41493. */
  41494. set buttonB(value: number);
  41495. /**
  41496. * Gets the value of the `X` button
  41497. */
  41498. get buttonX(): number;
  41499. /**
  41500. * Sets the value of the `X` button
  41501. */
  41502. set buttonX(value: number);
  41503. /**
  41504. * Gets the value of the `Y` button
  41505. */
  41506. get buttonY(): number;
  41507. /**
  41508. * Sets the value of the `Y` button
  41509. */
  41510. set buttonY(value: number);
  41511. /**
  41512. * Gets the value of the `Start` button
  41513. */
  41514. get buttonStart(): number;
  41515. /**
  41516. * Sets the value of the `Start` button
  41517. */
  41518. set buttonStart(value: number);
  41519. /**
  41520. * Gets the value of the `Back` button
  41521. */
  41522. get buttonBack(): number;
  41523. /**
  41524. * Sets the value of the `Back` button
  41525. */
  41526. set buttonBack(value: number);
  41527. /**
  41528. * Gets the value of the `Left` button
  41529. */
  41530. get buttonLB(): number;
  41531. /**
  41532. * Sets the value of the `Left` button
  41533. */
  41534. set buttonLB(value: number);
  41535. /**
  41536. * Gets the value of the `Right` button
  41537. */
  41538. get buttonRB(): number;
  41539. /**
  41540. * Sets the value of the `Right` button
  41541. */
  41542. set buttonRB(value: number);
  41543. /**
  41544. * Gets the value of the Left joystick
  41545. */
  41546. get buttonLeftStick(): number;
  41547. /**
  41548. * Sets the value of the Left joystick
  41549. */
  41550. set buttonLeftStick(value: number);
  41551. /**
  41552. * Gets the value of the Right joystick
  41553. */
  41554. get buttonRightStick(): number;
  41555. /**
  41556. * Sets the value of the Right joystick
  41557. */
  41558. set buttonRightStick(value: number);
  41559. /**
  41560. * Gets the value of D-pad up
  41561. */
  41562. get dPadUp(): number;
  41563. /**
  41564. * Sets the value of D-pad up
  41565. */
  41566. set dPadUp(value: number);
  41567. /**
  41568. * Gets the value of D-pad down
  41569. */
  41570. get dPadDown(): number;
  41571. /**
  41572. * Sets the value of D-pad down
  41573. */
  41574. set dPadDown(value: number);
  41575. /**
  41576. * Gets the value of D-pad left
  41577. */
  41578. get dPadLeft(): number;
  41579. /**
  41580. * Sets the value of D-pad left
  41581. */
  41582. set dPadLeft(value: number);
  41583. /**
  41584. * Gets the value of D-pad right
  41585. */
  41586. get dPadRight(): number;
  41587. /**
  41588. * Sets the value of D-pad right
  41589. */
  41590. set dPadRight(value: number);
  41591. /**
  41592. * Force the gamepad to synchronize with device values
  41593. */
  41594. update(): void;
  41595. /**
  41596. * Disposes the gamepad
  41597. */
  41598. dispose(): void;
  41599. }
  41600. }
  41601. declare module BABYLON {
  41602. /**
  41603. * Defines supported buttons for DualShock compatible gamepads
  41604. */
  41605. export enum DualShockButton {
  41606. /** Cross */
  41607. Cross = 0,
  41608. /** Circle */
  41609. Circle = 1,
  41610. /** Square */
  41611. Square = 2,
  41612. /** Triangle */
  41613. Triangle = 3,
  41614. /** L1 */
  41615. L1 = 4,
  41616. /** R1 */
  41617. R1 = 5,
  41618. /** Share */
  41619. Share = 8,
  41620. /** Options */
  41621. Options = 9,
  41622. /** Left stick */
  41623. LeftStick = 10,
  41624. /** Right stick */
  41625. RightStick = 11
  41626. }
  41627. /** Defines values for DualShock DPad */
  41628. export enum DualShockDpad {
  41629. /** Up */
  41630. Up = 12,
  41631. /** Down */
  41632. Down = 13,
  41633. /** Left */
  41634. Left = 14,
  41635. /** Right */
  41636. Right = 15
  41637. }
  41638. /**
  41639. * Defines a DualShock gamepad
  41640. */
  41641. export class DualShockPad extends Gamepad {
  41642. private _leftTrigger;
  41643. private _rightTrigger;
  41644. private _onlefttriggerchanged;
  41645. private _onrighttriggerchanged;
  41646. private _onbuttondown;
  41647. private _onbuttonup;
  41648. private _ondpaddown;
  41649. private _ondpadup;
  41650. /** Observable raised when a button is pressed */
  41651. onButtonDownObservable: Observable<DualShockButton>;
  41652. /** Observable raised when a button is released */
  41653. onButtonUpObservable: Observable<DualShockButton>;
  41654. /** Observable raised when a pad is pressed */
  41655. onPadDownObservable: Observable<DualShockDpad>;
  41656. /** Observable raised when a pad is released */
  41657. onPadUpObservable: Observable<DualShockDpad>;
  41658. private _buttonCross;
  41659. private _buttonCircle;
  41660. private _buttonSquare;
  41661. private _buttonTriangle;
  41662. private _buttonShare;
  41663. private _buttonOptions;
  41664. private _buttonL1;
  41665. private _buttonR1;
  41666. private _buttonLeftStick;
  41667. private _buttonRightStick;
  41668. private _dPadUp;
  41669. private _dPadDown;
  41670. private _dPadLeft;
  41671. private _dPadRight;
  41672. /**
  41673. * Creates a new DualShock gamepad object
  41674. * @param id defines the id of this gamepad
  41675. * @param index defines its index
  41676. * @param gamepad defines the internal HTML gamepad object
  41677. */
  41678. constructor(id: string, index: number, gamepad: any);
  41679. /**
  41680. * Defines the callback to call when left trigger is pressed
  41681. * @param callback defines the callback to use
  41682. */
  41683. onlefttriggerchanged(callback: (value: number) => void): void;
  41684. /**
  41685. * Defines the callback to call when right trigger is pressed
  41686. * @param callback defines the callback to use
  41687. */
  41688. onrighttriggerchanged(callback: (value: number) => void): void;
  41689. /**
  41690. * Gets the left trigger value
  41691. */
  41692. get leftTrigger(): number;
  41693. /**
  41694. * Sets the left trigger value
  41695. */
  41696. set leftTrigger(newValue: number);
  41697. /**
  41698. * Gets the right trigger value
  41699. */
  41700. get rightTrigger(): number;
  41701. /**
  41702. * Sets the right trigger value
  41703. */
  41704. set rightTrigger(newValue: number);
  41705. /**
  41706. * Defines the callback to call when a button is pressed
  41707. * @param callback defines the callback to use
  41708. */
  41709. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41710. /**
  41711. * Defines the callback to call when a button is released
  41712. * @param callback defines the callback to use
  41713. */
  41714. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41715. /**
  41716. * Defines the callback to call when a pad is pressed
  41717. * @param callback defines the callback to use
  41718. */
  41719. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41720. /**
  41721. * Defines the callback to call when a pad is released
  41722. * @param callback defines the callback to use
  41723. */
  41724. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41725. private _setButtonValue;
  41726. private _setDPadValue;
  41727. /**
  41728. * Gets the value of the `Cross` button
  41729. */
  41730. get buttonCross(): number;
  41731. /**
  41732. * Sets the value of the `Cross` button
  41733. */
  41734. set buttonCross(value: number);
  41735. /**
  41736. * Gets the value of the `Circle` button
  41737. */
  41738. get buttonCircle(): number;
  41739. /**
  41740. * Sets the value of the `Circle` button
  41741. */
  41742. set buttonCircle(value: number);
  41743. /**
  41744. * Gets the value of the `Square` button
  41745. */
  41746. get buttonSquare(): number;
  41747. /**
  41748. * Sets the value of the `Square` button
  41749. */
  41750. set buttonSquare(value: number);
  41751. /**
  41752. * Gets the value of the `Triangle` button
  41753. */
  41754. get buttonTriangle(): number;
  41755. /**
  41756. * Sets the value of the `Triangle` button
  41757. */
  41758. set buttonTriangle(value: number);
  41759. /**
  41760. * Gets the value of the `Options` button
  41761. */
  41762. get buttonOptions(): number;
  41763. /**
  41764. * Sets the value of the `Options` button
  41765. */
  41766. set buttonOptions(value: number);
  41767. /**
  41768. * Gets the value of the `Share` button
  41769. */
  41770. get buttonShare(): number;
  41771. /**
  41772. * Sets the value of the `Share` button
  41773. */
  41774. set buttonShare(value: number);
  41775. /**
  41776. * Gets the value of the `L1` button
  41777. */
  41778. get buttonL1(): number;
  41779. /**
  41780. * Sets the value of the `L1` button
  41781. */
  41782. set buttonL1(value: number);
  41783. /**
  41784. * Gets the value of the `R1` button
  41785. */
  41786. get buttonR1(): number;
  41787. /**
  41788. * Sets the value of the `R1` button
  41789. */
  41790. set buttonR1(value: number);
  41791. /**
  41792. * Gets the value of the Left joystick
  41793. */
  41794. get buttonLeftStick(): number;
  41795. /**
  41796. * Sets the value of the Left joystick
  41797. */
  41798. set buttonLeftStick(value: number);
  41799. /**
  41800. * Gets the value of the Right joystick
  41801. */
  41802. get buttonRightStick(): number;
  41803. /**
  41804. * Sets the value of the Right joystick
  41805. */
  41806. set buttonRightStick(value: number);
  41807. /**
  41808. * Gets the value of D-pad up
  41809. */
  41810. get dPadUp(): number;
  41811. /**
  41812. * Sets the value of D-pad up
  41813. */
  41814. set dPadUp(value: number);
  41815. /**
  41816. * Gets the value of D-pad down
  41817. */
  41818. get dPadDown(): number;
  41819. /**
  41820. * Sets the value of D-pad down
  41821. */
  41822. set dPadDown(value: number);
  41823. /**
  41824. * Gets the value of D-pad left
  41825. */
  41826. get dPadLeft(): number;
  41827. /**
  41828. * Sets the value of D-pad left
  41829. */
  41830. set dPadLeft(value: number);
  41831. /**
  41832. * Gets the value of D-pad right
  41833. */
  41834. get dPadRight(): number;
  41835. /**
  41836. * Sets the value of D-pad right
  41837. */
  41838. set dPadRight(value: number);
  41839. /**
  41840. * Force the gamepad to synchronize with device values
  41841. */
  41842. update(): void;
  41843. /**
  41844. * Disposes the gamepad
  41845. */
  41846. dispose(): void;
  41847. }
  41848. }
  41849. declare module BABYLON {
  41850. /**
  41851. * Manager for handling gamepads
  41852. */
  41853. export class GamepadManager {
  41854. private _scene?;
  41855. private _babylonGamepads;
  41856. private _oneGamepadConnected;
  41857. /** @hidden */
  41858. _isMonitoring: boolean;
  41859. private _gamepadEventSupported;
  41860. private _gamepadSupport?;
  41861. /**
  41862. * observable to be triggered when the gamepad controller has been connected
  41863. */
  41864. onGamepadConnectedObservable: Observable<Gamepad>;
  41865. /**
  41866. * observable to be triggered when the gamepad controller has been disconnected
  41867. */
  41868. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41869. private _onGamepadConnectedEvent;
  41870. private _onGamepadDisconnectedEvent;
  41871. /**
  41872. * Initializes the gamepad manager
  41873. * @param _scene BabylonJS scene
  41874. */
  41875. constructor(_scene?: Scene | undefined);
  41876. /**
  41877. * The gamepads in the game pad manager
  41878. */
  41879. get gamepads(): Gamepad[];
  41880. /**
  41881. * Get the gamepad controllers based on type
  41882. * @param type The type of gamepad controller
  41883. * @returns Nullable gamepad
  41884. */
  41885. getGamepadByType(type?: number): Nullable<Gamepad>;
  41886. /**
  41887. * Disposes the gamepad manager
  41888. */
  41889. dispose(): void;
  41890. private _addNewGamepad;
  41891. private _startMonitoringGamepads;
  41892. private _stopMonitoringGamepads;
  41893. /** @hidden */
  41894. _checkGamepadsStatus(): void;
  41895. private _updateGamepadObjects;
  41896. }
  41897. }
  41898. declare module BABYLON {
  41899. interface Scene {
  41900. /** @hidden */
  41901. _gamepadManager: Nullable<GamepadManager>;
  41902. /**
  41903. * Gets the gamepad manager associated with the scene
  41904. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41905. */
  41906. gamepadManager: GamepadManager;
  41907. }
  41908. /**
  41909. * Interface representing a free camera inputs manager
  41910. */
  41911. interface FreeCameraInputsManager {
  41912. /**
  41913. * Adds gamepad input support to the FreeCameraInputsManager.
  41914. * @returns the FreeCameraInputsManager
  41915. */
  41916. addGamepad(): FreeCameraInputsManager;
  41917. }
  41918. /**
  41919. * Interface representing an arc rotate camera inputs manager
  41920. */
  41921. interface ArcRotateCameraInputsManager {
  41922. /**
  41923. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41924. * @returns the camera inputs manager
  41925. */
  41926. addGamepad(): ArcRotateCameraInputsManager;
  41927. }
  41928. /**
  41929. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41930. */
  41931. export class GamepadSystemSceneComponent implements ISceneComponent {
  41932. /**
  41933. * The component name helpfull to identify the component in the list of scene components.
  41934. */
  41935. readonly name: string;
  41936. /**
  41937. * The scene the component belongs to.
  41938. */
  41939. scene: Scene;
  41940. /**
  41941. * Creates a new instance of the component for the given scene
  41942. * @param scene Defines the scene to register the component in
  41943. */
  41944. constructor(scene: Scene);
  41945. /**
  41946. * Registers the component in a given scene
  41947. */
  41948. register(): void;
  41949. /**
  41950. * Rebuilds the elements related to this component in case of
  41951. * context lost for instance.
  41952. */
  41953. rebuild(): void;
  41954. /**
  41955. * Disposes the component and the associated ressources
  41956. */
  41957. dispose(): void;
  41958. private _beforeCameraUpdate;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * 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,
  41964. * which still works and will still be found in many Playgrounds.
  41965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41966. */
  41967. export class UniversalCamera extends TouchCamera {
  41968. /**
  41969. * Defines the gamepad rotation sensiblity.
  41970. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41971. */
  41972. get gamepadAngularSensibility(): number;
  41973. set gamepadAngularSensibility(value: number);
  41974. /**
  41975. * Defines the gamepad move sensiblity.
  41976. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41977. */
  41978. get gamepadMoveSensibility(): number;
  41979. set gamepadMoveSensibility(value: number);
  41980. /**
  41981. * 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,
  41982. * which still works and will still be found in many Playgrounds.
  41983. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41984. * @param name Define the name of the camera in the scene
  41985. * @param position Define the start position of the camera in the scene
  41986. * @param scene Define the scene the camera belongs to
  41987. */
  41988. constructor(name: string, position: Vector3, scene: Scene);
  41989. /**
  41990. * Gets the current object class name.
  41991. * @return the class name
  41992. */
  41993. getClassName(): string;
  41994. }
  41995. }
  41996. declare module BABYLON {
  41997. /**
  41998. * This represents a FPS type of camera. This is only here for back compat purpose.
  41999. * Please use the UniversalCamera instead as both are identical.
  42000. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42001. */
  42002. export class GamepadCamera extends UniversalCamera {
  42003. /**
  42004. * Instantiates a new Gamepad Camera
  42005. * This represents a FPS type of camera. This is only here for back compat purpose.
  42006. * Please use the UniversalCamera instead as both are identical.
  42007. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42008. * @param name Define the name of the camera in the scene
  42009. * @param position Define the start position of the camera in the scene
  42010. * @param scene Define the scene the camera belongs to
  42011. */
  42012. constructor(name: string, position: Vector3, scene: Scene);
  42013. /**
  42014. * Gets the current object class name.
  42015. * @return the class name
  42016. */
  42017. getClassName(): string;
  42018. }
  42019. }
  42020. declare module BABYLON {
  42021. /** @hidden */
  42022. export var passPixelShader: {
  42023. name: string;
  42024. shader: string;
  42025. };
  42026. }
  42027. declare module BABYLON {
  42028. /** @hidden */
  42029. export var passCubePixelShader: {
  42030. name: string;
  42031. shader: string;
  42032. };
  42033. }
  42034. declare module BABYLON {
  42035. /**
  42036. * PassPostProcess which produces an output the same as it's input
  42037. */
  42038. export class PassPostProcess extends PostProcess {
  42039. /**
  42040. * Creates the PassPostProcess
  42041. * @param name The name of the effect.
  42042. * @param options The required width/height ratio to downsize to before computing the render pass.
  42043. * @param camera The camera to apply the render pass to.
  42044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42045. * @param engine The engine which the post process will be applied. (default: current engine)
  42046. * @param reusable If the post process can be reused on the same frame. (default: false)
  42047. * @param textureType The type of texture to be used when performing the post processing.
  42048. * @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)
  42049. */
  42050. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42051. }
  42052. /**
  42053. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42054. */
  42055. export class PassCubePostProcess extends PostProcess {
  42056. private _face;
  42057. /**
  42058. * Gets or sets the cube face to display.
  42059. * * 0 is +X
  42060. * * 1 is -X
  42061. * * 2 is +Y
  42062. * * 3 is -Y
  42063. * * 4 is +Z
  42064. * * 5 is -Z
  42065. */
  42066. get face(): number;
  42067. set face(value: number);
  42068. /**
  42069. * Creates the PassCubePostProcess
  42070. * @param name The name of the effect.
  42071. * @param options The required width/height ratio to downsize to before computing the render pass.
  42072. * @param camera The camera to apply the render pass to.
  42073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42074. * @param engine The engine which the post process will be applied. (default: current engine)
  42075. * @param reusable If the post process can be reused on the same frame. (default: false)
  42076. * @param textureType The type of texture to be used when performing the post processing.
  42077. * @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)
  42078. */
  42079. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42080. }
  42081. }
  42082. declare module BABYLON {
  42083. /** @hidden */
  42084. export var anaglyphPixelShader: {
  42085. name: string;
  42086. shader: string;
  42087. };
  42088. }
  42089. declare module BABYLON {
  42090. /**
  42091. * Postprocess used to generate anaglyphic rendering
  42092. */
  42093. export class AnaglyphPostProcess extends PostProcess {
  42094. private _passedProcess;
  42095. /**
  42096. * Creates a new AnaglyphPostProcess
  42097. * @param name defines postprocess name
  42098. * @param options defines creation options or target ratio scale
  42099. * @param rigCameras defines cameras using this postprocess
  42100. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42101. * @param engine defines hosting engine
  42102. * @param reusable defines if the postprocess will be reused multiple times per frame
  42103. */
  42104. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42105. }
  42106. }
  42107. declare module BABYLON {
  42108. /**
  42109. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42110. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42111. */
  42112. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42113. /**
  42114. * Creates a new AnaglyphArcRotateCamera
  42115. * @param name defines camera name
  42116. * @param alpha defines alpha angle (in radians)
  42117. * @param beta defines beta angle (in radians)
  42118. * @param radius defines radius
  42119. * @param target defines camera target
  42120. * @param interaxialDistance defines distance between each color axis
  42121. * @param scene defines the hosting scene
  42122. */
  42123. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42124. /**
  42125. * Gets camera class name
  42126. * @returns AnaglyphArcRotateCamera
  42127. */
  42128. getClassName(): string;
  42129. }
  42130. }
  42131. declare module BABYLON {
  42132. /**
  42133. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42134. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42135. */
  42136. export class AnaglyphFreeCamera extends FreeCamera {
  42137. /**
  42138. * Creates a new AnaglyphFreeCamera
  42139. * @param name defines camera name
  42140. * @param position defines initial position
  42141. * @param interaxialDistance defines distance between each color axis
  42142. * @param scene defines the hosting scene
  42143. */
  42144. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42145. /**
  42146. * Gets camera class name
  42147. * @returns AnaglyphFreeCamera
  42148. */
  42149. getClassName(): string;
  42150. }
  42151. }
  42152. declare module BABYLON {
  42153. /**
  42154. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42155. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42156. */
  42157. export class AnaglyphGamepadCamera extends GamepadCamera {
  42158. /**
  42159. * Creates a new AnaglyphGamepadCamera
  42160. * @param name defines camera name
  42161. * @param position defines initial position
  42162. * @param interaxialDistance defines distance between each color axis
  42163. * @param scene defines the hosting scene
  42164. */
  42165. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42166. /**
  42167. * Gets camera class name
  42168. * @returns AnaglyphGamepadCamera
  42169. */
  42170. getClassName(): string;
  42171. }
  42172. }
  42173. declare module BABYLON {
  42174. /**
  42175. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42176. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42177. */
  42178. export class AnaglyphUniversalCamera extends UniversalCamera {
  42179. /**
  42180. * Creates a new AnaglyphUniversalCamera
  42181. * @param name defines camera name
  42182. * @param position defines initial position
  42183. * @param interaxialDistance defines distance between each color axis
  42184. * @param scene defines the hosting scene
  42185. */
  42186. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42187. /**
  42188. * Gets camera class name
  42189. * @returns AnaglyphUniversalCamera
  42190. */
  42191. getClassName(): string;
  42192. }
  42193. }
  42194. declare module BABYLON {
  42195. /** @hidden */
  42196. export var stereoscopicInterlacePixelShader: {
  42197. name: string;
  42198. shader: string;
  42199. };
  42200. }
  42201. declare module BABYLON {
  42202. /**
  42203. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42204. */
  42205. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42206. private _stepSize;
  42207. private _passedProcess;
  42208. /**
  42209. * Initializes a StereoscopicInterlacePostProcessI
  42210. * @param name The name of the effect.
  42211. * @param rigCameras The rig cameras to be appled to the post process
  42212. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42213. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42215. * @param engine The engine which the post process will be applied. (default: current engine)
  42216. * @param reusable If the post process can be reused on the same frame. (default: false)
  42217. */
  42218. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42219. }
  42220. /**
  42221. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42222. */
  42223. export class StereoscopicInterlacePostProcess extends PostProcess {
  42224. private _stepSize;
  42225. private _passedProcess;
  42226. /**
  42227. * Initializes a StereoscopicInterlacePostProcess
  42228. * @param name The name of the effect.
  42229. * @param rigCameras The rig cameras to be appled to the post process
  42230. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42232. * @param engine The engine which the post process will be applied. (default: current engine)
  42233. * @param reusable If the post process can be reused on the same frame. (default: false)
  42234. */
  42235. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42236. }
  42237. }
  42238. declare module BABYLON {
  42239. /**
  42240. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42241. * @see http://doc.babylonjs.com/features/cameras
  42242. */
  42243. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42244. /**
  42245. * Creates a new StereoscopicArcRotateCamera
  42246. * @param name defines camera name
  42247. * @param alpha defines alpha angle (in radians)
  42248. * @param beta defines beta angle (in radians)
  42249. * @param radius defines radius
  42250. * @param target defines camera target
  42251. * @param interaxialDistance defines distance between each color axis
  42252. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42253. * @param scene defines the hosting scene
  42254. */
  42255. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42256. /**
  42257. * Gets camera class name
  42258. * @returns StereoscopicArcRotateCamera
  42259. */
  42260. getClassName(): string;
  42261. }
  42262. }
  42263. declare module BABYLON {
  42264. /**
  42265. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42266. * @see http://doc.babylonjs.com/features/cameras
  42267. */
  42268. export class StereoscopicFreeCamera extends FreeCamera {
  42269. /**
  42270. * Creates a new StereoscopicFreeCamera
  42271. * @param name defines camera name
  42272. * @param position defines initial position
  42273. * @param interaxialDistance defines distance between each color axis
  42274. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42275. * @param scene defines the hosting scene
  42276. */
  42277. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42278. /**
  42279. * Gets camera class name
  42280. * @returns StereoscopicFreeCamera
  42281. */
  42282. getClassName(): string;
  42283. }
  42284. }
  42285. declare module BABYLON {
  42286. /**
  42287. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42288. * @see http://doc.babylonjs.com/features/cameras
  42289. */
  42290. export class StereoscopicGamepadCamera extends GamepadCamera {
  42291. /**
  42292. * Creates a new StereoscopicGamepadCamera
  42293. * @param name defines camera name
  42294. * @param position defines initial position
  42295. * @param interaxialDistance defines distance between each color axis
  42296. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42297. * @param scene defines the hosting scene
  42298. */
  42299. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42300. /**
  42301. * Gets camera class name
  42302. * @returns StereoscopicGamepadCamera
  42303. */
  42304. getClassName(): string;
  42305. }
  42306. }
  42307. declare module BABYLON {
  42308. /**
  42309. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42310. * @see http://doc.babylonjs.com/features/cameras
  42311. */
  42312. export class StereoscopicUniversalCamera extends UniversalCamera {
  42313. /**
  42314. * Creates a new StereoscopicUniversalCamera
  42315. * @param name defines camera name
  42316. * @param position defines initial position
  42317. * @param interaxialDistance defines distance between each color axis
  42318. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42319. * @param scene defines the hosting scene
  42320. */
  42321. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42322. /**
  42323. * Gets camera class name
  42324. * @returns StereoscopicUniversalCamera
  42325. */
  42326. getClassName(): string;
  42327. }
  42328. }
  42329. declare module BABYLON {
  42330. /**
  42331. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42332. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42333. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42334. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42335. */
  42336. export class VirtualJoysticksCamera extends FreeCamera {
  42337. /**
  42338. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42339. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42340. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42341. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42342. * @param name Define the name of the camera in the scene
  42343. * @param position Define the start position of the camera in the scene
  42344. * @param scene Define the scene the camera belongs to
  42345. */
  42346. constructor(name: string, position: Vector3, scene: Scene);
  42347. /**
  42348. * Gets the current object class name.
  42349. * @return the class name
  42350. */
  42351. getClassName(): string;
  42352. }
  42353. }
  42354. declare module BABYLON {
  42355. /**
  42356. * This represents all the required metrics to create a VR camera.
  42357. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42358. */
  42359. export class VRCameraMetrics {
  42360. /**
  42361. * Define the horizontal resolution off the screen.
  42362. */
  42363. hResolution: number;
  42364. /**
  42365. * Define the vertical resolution off the screen.
  42366. */
  42367. vResolution: number;
  42368. /**
  42369. * Define the horizontal screen size.
  42370. */
  42371. hScreenSize: number;
  42372. /**
  42373. * Define the vertical screen size.
  42374. */
  42375. vScreenSize: number;
  42376. /**
  42377. * Define the vertical screen center position.
  42378. */
  42379. vScreenCenter: number;
  42380. /**
  42381. * Define the distance of the eyes to the screen.
  42382. */
  42383. eyeToScreenDistance: number;
  42384. /**
  42385. * Define the distance between both lenses
  42386. */
  42387. lensSeparationDistance: number;
  42388. /**
  42389. * Define the distance between both viewer's eyes.
  42390. */
  42391. interpupillaryDistance: number;
  42392. /**
  42393. * Define the distortion factor of the VR postprocess.
  42394. * Please, touch with care.
  42395. */
  42396. distortionK: number[];
  42397. /**
  42398. * Define the chromatic aberration correction factors for the VR post process.
  42399. */
  42400. chromaAbCorrection: number[];
  42401. /**
  42402. * Define the scale factor of the post process.
  42403. * The smaller the better but the slower.
  42404. */
  42405. postProcessScaleFactor: number;
  42406. /**
  42407. * Define an offset for the lens center.
  42408. */
  42409. lensCenterOffset: number;
  42410. /**
  42411. * Define if the current vr camera should compensate the distortion of the lense or not.
  42412. */
  42413. compensateDistortion: boolean;
  42414. /**
  42415. * Defines if multiview should be enabled when rendering (Default: false)
  42416. */
  42417. multiviewEnabled: boolean;
  42418. /**
  42419. * Gets the rendering aspect ratio based on the provided resolutions.
  42420. */
  42421. get aspectRatio(): number;
  42422. /**
  42423. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42424. */
  42425. get aspectRatioFov(): number;
  42426. /**
  42427. * @hidden
  42428. */
  42429. get leftHMatrix(): Matrix;
  42430. /**
  42431. * @hidden
  42432. */
  42433. get rightHMatrix(): Matrix;
  42434. /**
  42435. * @hidden
  42436. */
  42437. get leftPreViewMatrix(): Matrix;
  42438. /**
  42439. * @hidden
  42440. */
  42441. get rightPreViewMatrix(): Matrix;
  42442. /**
  42443. * Get the default VRMetrics based on the most generic setup.
  42444. * @returns the default vr metrics
  42445. */
  42446. static GetDefault(): VRCameraMetrics;
  42447. }
  42448. }
  42449. declare module BABYLON {
  42450. /** @hidden */
  42451. export var vrDistortionCorrectionPixelShader: {
  42452. name: string;
  42453. shader: string;
  42454. };
  42455. }
  42456. declare module BABYLON {
  42457. /**
  42458. * VRDistortionCorrectionPostProcess used for mobile VR
  42459. */
  42460. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42461. private _isRightEye;
  42462. private _distortionFactors;
  42463. private _postProcessScaleFactor;
  42464. private _lensCenterOffset;
  42465. private _scaleIn;
  42466. private _scaleFactor;
  42467. private _lensCenter;
  42468. /**
  42469. * Initializes the VRDistortionCorrectionPostProcess
  42470. * @param name The name of the effect.
  42471. * @param camera The camera to apply the render pass to.
  42472. * @param isRightEye If this is for the right eye distortion
  42473. * @param vrMetrics All the required metrics for the VR camera
  42474. */
  42475. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42476. }
  42477. }
  42478. declare module BABYLON {
  42479. /**
  42480. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42481. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42482. */
  42483. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42484. /**
  42485. * Creates a new VRDeviceOrientationArcRotateCamera
  42486. * @param name defines camera name
  42487. * @param alpha defines the camera rotation along the logitudinal axis
  42488. * @param beta defines the camera rotation along the latitudinal axis
  42489. * @param radius defines the camera distance from its target
  42490. * @param target defines the camera target
  42491. * @param scene defines the scene the camera belongs to
  42492. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42493. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42494. */
  42495. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42496. /**
  42497. * Gets camera class name
  42498. * @returns VRDeviceOrientationArcRotateCamera
  42499. */
  42500. getClassName(): string;
  42501. }
  42502. }
  42503. declare module BABYLON {
  42504. /**
  42505. * Camera used to simulate VR rendering (based on FreeCamera)
  42506. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42507. */
  42508. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42509. /**
  42510. * Creates a new VRDeviceOrientationFreeCamera
  42511. * @param name defines camera name
  42512. * @param position defines the start position of the camera
  42513. * @param scene defines the scene the camera belongs to
  42514. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42515. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42516. */
  42517. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42518. /**
  42519. * Gets camera class name
  42520. * @returns VRDeviceOrientationFreeCamera
  42521. */
  42522. getClassName(): string;
  42523. }
  42524. }
  42525. declare module BABYLON {
  42526. /**
  42527. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42528. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42529. */
  42530. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42531. /**
  42532. * Creates a new VRDeviceOrientationGamepadCamera
  42533. * @param name defines camera name
  42534. * @param position defines the start position of the camera
  42535. * @param scene defines the scene the camera belongs to
  42536. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42537. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42538. */
  42539. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42540. /**
  42541. * Gets camera class name
  42542. * @returns VRDeviceOrientationGamepadCamera
  42543. */
  42544. getClassName(): string;
  42545. }
  42546. }
  42547. declare module BABYLON {
  42548. /** @hidden */
  42549. export var imageProcessingPixelShader: {
  42550. name: string;
  42551. shader: string;
  42552. };
  42553. }
  42554. declare module BABYLON {
  42555. /**
  42556. * ImageProcessingPostProcess
  42557. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42558. */
  42559. export class ImageProcessingPostProcess extends PostProcess {
  42560. /**
  42561. * Default configuration related to image processing available in the PBR Material.
  42562. */
  42563. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42564. /**
  42565. * Gets the image processing configuration used either in this material.
  42566. */
  42567. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42568. /**
  42569. * Sets the Default image processing configuration used either in the this material.
  42570. *
  42571. * If sets to null, the scene one is in use.
  42572. */
  42573. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42574. /**
  42575. * Keep track of the image processing observer to allow dispose and replace.
  42576. */
  42577. private _imageProcessingObserver;
  42578. /**
  42579. * Attaches a new image processing configuration to the PBR Material.
  42580. * @param configuration
  42581. */
  42582. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42583. /**
  42584. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42585. */
  42586. get colorCurves(): Nullable<ColorCurves>;
  42587. /**
  42588. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42589. */
  42590. set colorCurves(value: Nullable<ColorCurves>);
  42591. /**
  42592. * Gets wether the color curves effect is enabled.
  42593. */
  42594. get colorCurvesEnabled(): boolean;
  42595. /**
  42596. * Sets wether the color curves effect is enabled.
  42597. */
  42598. set colorCurvesEnabled(value: boolean);
  42599. /**
  42600. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42601. */
  42602. get colorGradingTexture(): Nullable<BaseTexture>;
  42603. /**
  42604. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42605. */
  42606. set colorGradingTexture(value: Nullable<BaseTexture>);
  42607. /**
  42608. * Gets wether the color grading effect is enabled.
  42609. */
  42610. get colorGradingEnabled(): boolean;
  42611. /**
  42612. * Gets wether the color grading effect is enabled.
  42613. */
  42614. set colorGradingEnabled(value: boolean);
  42615. /**
  42616. * Gets exposure used in the effect.
  42617. */
  42618. get exposure(): number;
  42619. /**
  42620. * Sets exposure used in the effect.
  42621. */
  42622. set exposure(value: number);
  42623. /**
  42624. * Gets wether tonemapping is enabled or not.
  42625. */
  42626. get toneMappingEnabled(): boolean;
  42627. /**
  42628. * Sets wether tonemapping is enabled or not
  42629. */
  42630. set toneMappingEnabled(value: boolean);
  42631. /**
  42632. * Gets the type of tone mapping effect.
  42633. */
  42634. get toneMappingType(): number;
  42635. /**
  42636. * Sets the type of tone mapping effect.
  42637. */
  42638. set toneMappingType(value: number);
  42639. /**
  42640. * Gets contrast used in the effect.
  42641. */
  42642. get contrast(): number;
  42643. /**
  42644. * Sets contrast used in the effect.
  42645. */
  42646. set contrast(value: number);
  42647. /**
  42648. * Gets Vignette stretch size.
  42649. */
  42650. get vignetteStretch(): number;
  42651. /**
  42652. * Sets Vignette stretch size.
  42653. */
  42654. set vignetteStretch(value: number);
  42655. /**
  42656. * Gets Vignette centre X Offset.
  42657. */
  42658. get vignetteCentreX(): number;
  42659. /**
  42660. * Sets Vignette centre X Offset.
  42661. */
  42662. set vignetteCentreX(value: number);
  42663. /**
  42664. * Gets Vignette centre Y Offset.
  42665. */
  42666. get vignetteCentreY(): number;
  42667. /**
  42668. * Sets Vignette centre Y Offset.
  42669. */
  42670. set vignetteCentreY(value: number);
  42671. /**
  42672. * Gets Vignette weight or intensity of the vignette effect.
  42673. */
  42674. get vignetteWeight(): number;
  42675. /**
  42676. * Sets Vignette weight or intensity of the vignette effect.
  42677. */
  42678. set vignetteWeight(value: number);
  42679. /**
  42680. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42681. * if vignetteEnabled is set to true.
  42682. */
  42683. get vignetteColor(): Color4;
  42684. /**
  42685. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42686. * if vignetteEnabled is set to true.
  42687. */
  42688. set vignetteColor(value: Color4);
  42689. /**
  42690. * Gets Camera field of view used by the Vignette effect.
  42691. */
  42692. get vignetteCameraFov(): number;
  42693. /**
  42694. * Sets Camera field of view used by the Vignette effect.
  42695. */
  42696. set vignetteCameraFov(value: number);
  42697. /**
  42698. * Gets the vignette blend mode allowing different kind of effect.
  42699. */
  42700. get vignetteBlendMode(): number;
  42701. /**
  42702. * Sets the vignette blend mode allowing different kind of effect.
  42703. */
  42704. set vignetteBlendMode(value: number);
  42705. /**
  42706. * Gets wether the vignette effect is enabled.
  42707. */
  42708. get vignetteEnabled(): boolean;
  42709. /**
  42710. * Sets wether the vignette effect is enabled.
  42711. */
  42712. set vignetteEnabled(value: boolean);
  42713. private _fromLinearSpace;
  42714. /**
  42715. * Gets wether the input of the processing is in Gamma or Linear Space.
  42716. */
  42717. get fromLinearSpace(): boolean;
  42718. /**
  42719. * Sets wether the input of the processing is in Gamma or Linear Space.
  42720. */
  42721. set fromLinearSpace(value: boolean);
  42722. /**
  42723. * Defines cache preventing GC.
  42724. */
  42725. private _defines;
  42726. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42727. /**
  42728. * "ImageProcessingPostProcess"
  42729. * @returns "ImageProcessingPostProcess"
  42730. */
  42731. getClassName(): string;
  42732. protected _updateParameters(): void;
  42733. dispose(camera?: Camera): void;
  42734. }
  42735. }
  42736. declare module BABYLON {
  42737. /**
  42738. * Class containing static functions to help procedurally build meshes
  42739. */
  42740. export class GroundBuilder {
  42741. /**
  42742. * Creates a ground mesh
  42743. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42744. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42746. * @param name defines the name of the mesh
  42747. * @param options defines the options used to create the mesh
  42748. * @param scene defines the hosting scene
  42749. * @returns the ground mesh
  42750. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42751. */
  42752. static CreateGround(name: string, options: {
  42753. width?: number;
  42754. height?: number;
  42755. subdivisions?: number;
  42756. subdivisionsX?: number;
  42757. subdivisionsY?: number;
  42758. updatable?: boolean;
  42759. }, scene: any): Mesh;
  42760. /**
  42761. * Creates a tiled ground mesh
  42762. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42763. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42764. * * 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
  42765. * * 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
  42766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42767. * @param name defines the name of the mesh
  42768. * @param options defines the options used to create the mesh
  42769. * @param scene defines the hosting scene
  42770. * @returns the tiled ground mesh
  42771. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42772. */
  42773. static CreateTiledGround(name: string, options: {
  42774. xmin: number;
  42775. zmin: number;
  42776. xmax: number;
  42777. zmax: number;
  42778. subdivisions?: {
  42779. w: number;
  42780. h: number;
  42781. };
  42782. precision?: {
  42783. w: number;
  42784. h: number;
  42785. };
  42786. updatable?: boolean;
  42787. }, scene?: Nullable<Scene>): Mesh;
  42788. /**
  42789. * Creates a ground mesh from a height map
  42790. * * The parameter `url` sets the URL of the height map image resource.
  42791. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42792. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42793. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42794. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42795. * * 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.
  42796. * * 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).
  42797. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42799. * @param name defines the name of the mesh
  42800. * @param url defines the url to the height map
  42801. * @param options defines the options used to create the mesh
  42802. * @param scene defines the hosting scene
  42803. * @returns the ground mesh
  42804. * @see https://doc.babylonjs.com/babylon101/height_map
  42805. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42806. */
  42807. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42808. width?: number;
  42809. height?: number;
  42810. subdivisions?: number;
  42811. minHeight?: number;
  42812. maxHeight?: number;
  42813. colorFilter?: Color3;
  42814. alphaFilter?: number;
  42815. updatable?: boolean;
  42816. onReady?: (mesh: GroundMesh) => void;
  42817. }, scene?: Nullable<Scene>): GroundMesh;
  42818. }
  42819. }
  42820. declare module BABYLON {
  42821. /**
  42822. * Class containing static functions to help procedurally build meshes
  42823. */
  42824. export class TorusBuilder {
  42825. /**
  42826. * Creates a torus mesh
  42827. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42828. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42829. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42831. * * 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
  42832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42833. * @param name defines the name of the mesh
  42834. * @param options defines the options used to create the mesh
  42835. * @param scene defines the hosting scene
  42836. * @returns the torus mesh
  42837. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42838. */
  42839. static CreateTorus(name: string, options: {
  42840. diameter?: number;
  42841. thickness?: number;
  42842. tessellation?: number;
  42843. updatable?: boolean;
  42844. sideOrientation?: number;
  42845. frontUVs?: Vector4;
  42846. backUVs?: Vector4;
  42847. }, scene: any): Mesh;
  42848. }
  42849. }
  42850. declare module BABYLON {
  42851. /**
  42852. * Class containing static functions to help procedurally build meshes
  42853. */
  42854. export class CylinderBuilder {
  42855. /**
  42856. * Creates a cylinder or a cone mesh
  42857. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42858. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42859. * * 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.
  42860. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42861. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42862. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42863. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42864. * * 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).
  42865. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42866. * * 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).
  42867. * * 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
  42868. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42869. * * 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
  42870. * * 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.
  42871. * * If `enclose` is false, a ring surface is one element.
  42872. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42873. * * 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
  42874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42875. * * 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
  42876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42877. * @param name defines the name of the mesh
  42878. * @param options defines the options used to create the mesh
  42879. * @param scene defines the hosting scene
  42880. * @returns the cylinder mesh
  42881. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42882. */
  42883. static CreateCylinder(name: string, options: {
  42884. height?: number;
  42885. diameterTop?: number;
  42886. diameterBottom?: number;
  42887. diameter?: number;
  42888. tessellation?: number;
  42889. subdivisions?: number;
  42890. arc?: number;
  42891. faceColors?: Color4[];
  42892. faceUV?: Vector4[];
  42893. updatable?: boolean;
  42894. hasRings?: boolean;
  42895. enclose?: boolean;
  42896. cap?: number;
  42897. sideOrientation?: number;
  42898. frontUVs?: Vector4;
  42899. backUVs?: Vector4;
  42900. }, scene: any): Mesh;
  42901. }
  42902. }
  42903. declare module BABYLON {
  42904. /**
  42905. * States of the webXR experience
  42906. */
  42907. export enum WebXRState {
  42908. /**
  42909. * Transitioning to being in XR mode
  42910. */
  42911. ENTERING_XR = 0,
  42912. /**
  42913. * Transitioning to non XR mode
  42914. */
  42915. EXITING_XR = 1,
  42916. /**
  42917. * In XR mode and presenting
  42918. */
  42919. IN_XR = 2,
  42920. /**
  42921. * Not entered XR mode
  42922. */
  42923. NOT_IN_XR = 3
  42924. }
  42925. /**
  42926. * Abstraction of the XR render target
  42927. */
  42928. export interface WebXRRenderTarget extends IDisposable {
  42929. /**
  42930. * xrpresent context of the canvas which can be used to display/mirror xr content
  42931. */
  42932. canvasContext: WebGLRenderingContext;
  42933. /**
  42934. * xr layer for the canvas
  42935. */
  42936. xrLayer: Nullable<XRWebGLLayer>;
  42937. /**
  42938. * Initializes the xr layer for the session
  42939. * @param xrSession xr session
  42940. * @returns a promise that will resolve once the XR Layer has been created
  42941. */
  42942. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42943. }
  42944. }
  42945. declare module BABYLON {
  42946. /**
  42947. * COnfiguration object for WebXR output canvas
  42948. */
  42949. export class WebXRManagedOutputCanvasOptions {
  42950. /**
  42951. * An optional canvas in case you wish to create it yourself and provide it here.
  42952. * If not provided, a new canvas will be created
  42953. */
  42954. canvasElement?: HTMLCanvasElement;
  42955. /**
  42956. * Options for this XR Layer output
  42957. */
  42958. canvasOptions?: XRWebGLLayerOptions;
  42959. /**
  42960. * CSS styling for a newly created canvas (if not provided)
  42961. */
  42962. newCanvasCssStyle?: string;
  42963. /**
  42964. * Get the default values of the configuration object
  42965. * @returns default values of this configuration object
  42966. */
  42967. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42968. }
  42969. /**
  42970. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42971. */
  42972. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42973. private _options;
  42974. private _canvas;
  42975. private _engine;
  42976. /**
  42977. * Rendering context of the canvas which can be used to display/mirror xr content
  42978. */
  42979. canvasContext: WebGLRenderingContext;
  42980. /**
  42981. * xr layer for the canvas
  42982. */
  42983. xrLayer: Nullable<XRWebGLLayer>;
  42984. /**
  42985. * Initializes the canvas to be added/removed upon entering/exiting xr
  42986. * @param _xrSessionManager The XR Session manager
  42987. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42988. */
  42989. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42990. /**
  42991. * Disposes of the object
  42992. */
  42993. dispose(): void;
  42994. /**
  42995. * Initializes the xr layer for the session
  42996. * @param xrSession xr session
  42997. * @returns a promise that will resolve once the XR Layer has been created
  42998. */
  42999. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43000. private _addCanvas;
  43001. private _removeCanvas;
  43002. private _setManagedOutputCanvas;
  43003. }
  43004. }
  43005. declare module BABYLON {
  43006. /**
  43007. * Manages an XRSession to work with Babylon's engine
  43008. * @see https://doc.babylonjs.com/how_to/webxr
  43009. */
  43010. export class WebXRSessionManager implements IDisposable {
  43011. /** The scene which the session should be created for */
  43012. scene: Scene;
  43013. private _referenceSpace;
  43014. private _rttProvider;
  43015. private _sessionEnded;
  43016. private _xrNavigator;
  43017. private baseLayer;
  43018. /**
  43019. * The base reference space from which the session started. good if you want to reset your
  43020. * reference space
  43021. */
  43022. baseReferenceSpace: XRReferenceSpace;
  43023. /**
  43024. * Current XR frame
  43025. */
  43026. currentFrame: Nullable<XRFrame>;
  43027. /** WebXR timestamp updated every frame */
  43028. currentTimestamp: number;
  43029. /**
  43030. * Used just in case of a failure to initialize an immersive session.
  43031. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43032. */
  43033. defaultHeightCompensation: number;
  43034. /**
  43035. * Fires every time a new xrFrame arrives which can be used to update the camera
  43036. */
  43037. onXRFrameObservable: Observable<XRFrame>;
  43038. /**
  43039. * Fires when the reference space changed
  43040. */
  43041. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43042. /**
  43043. * Fires when the xr session is ended either by the device or manually done
  43044. */
  43045. onXRSessionEnded: Observable<any>;
  43046. /**
  43047. * Fires when the xr session is ended either by the device or manually done
  43048. */
  43049. onXRSessionInit: Observable<XRSession>;
  43050. /**
  43051. * Underlying xr session
  43052. */
  43053. session: XRSession;
  43054. /**
  43055. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43056. * or get the offset the player is currently at.
  43057. */
  43058. viewerReferenceSpace: XRReferenceSpace;
  43059. /**
  43060. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43061. * @param scene The scene which the session should be created for
  43062. */
  43063. constructor(
  43064. /** The scene which the session should be created for */
  43065. scene: Scene);
  43066. /**
  43067. * The current reference space used in this session. This reference space can constantly change!
  43068. * It is mainly used to offset the camera's position.
  43069. */
  43070. get referenceSpace(): XRReferenceSpace;
  43071. /**
  43072. * Set a new reference space and triggers the observable
  43073. */
  43074. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43075. /**
  43076. * Disposes of the session manager
  43077. */
  43078. dispose(): void;
  43079. /**
  43080. * Stops the xrSession and restores the render loop
  43081. * @returns Promise which resolves after it exits XR
  43082. */
  43083. exitXRAsync(): Promise<void>;
  43084. /**
  43085. * Gets the correct render target texture to be rendered this frame for this eye
  43086. * @param eye the eye for which to get the render target
  43087. * @returns the render target for the specified eye
  43088. */
  43089. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43090. /**
  43091. * Creates a WebXRRenderTarget object for the XR session
  43092. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43093. * @param options optional options to provide when creating a new render target
  43094. * @returns a WebXR render target to which the session can render
  43095. */
  43096. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43097. /**
  43098. * Initializes the manager
  43099. * After initialization enterXR can be called to start an XR session
  43100. * @returns Promise which resolves after it is initialized
  43101. */
  43102. initializeAsync(): Promise<void>;
  43103. /**
  43104. * Initializes an xr session
  43105. * @param xrSessionMode mode to initialize
  43106. * @param xrSessionInit defines optional and required values to pass to the session builder
  43107. * @returns a promise which will resolve once the session has been initialized
  43108. */
  43109. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43110. /**
  43111. * Checks if a session would be supported for the creation options specified
  43112. * @param sessionMode session mode to check if supported eg. immersive-vr
  43113. * @returns A Promise that resolves to true if supported and false if not
  43114. */
  43115. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43116. /**
  43117. * Resets the reference space to the one started the session
  43118. */
  43119. resetReferenceSpace(): void;
  43120. /**
  43121. * Starts rendering to the xr layer
  43122. */
  43123. runXRRenderLoop(): void;
  43124. /**
  43125. * Sets the reference space on the xr session
  43126. * @param referenceSpaceType space to set
  43127. * @returns a promise that will resolve once the reference space has been set
  43128. */
  43129. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43130. /**
  43131. * Updates the render state of the session
  43132. * @param state state to set
  43133. * @returns a promise that resolves once the render state has been updated
  43134. */
  43135. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43136. /**
  43137. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43138. * @param sessionMode defines the session to test
  43139. * @returns a promise with boolean as final value
  43140. */
  43141. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43142. private _createRenderTargetTexture;
  43143. }
  43144. }
  43145. declare module BABYLON {
  43146. /**
  43147. * WebXR Camera which holds the views for the xrSession
  43148. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43149. */
  43150. export class WebXRCamera extends FreeCamera {
  43151. private _xrSessionManager;
  43152. private _firstFrame;
  43153. private _referenceQuaternion;
  43154. private _referencedPosition;
  43155. private _xrInvPositionCache;
  43156. private _xrInvQuaternionCache;
  43157. /**
  43158. * Should position compensation execute on first frame.
  43159. * This is used when copying the position from a native (non XR) camera
  43160. */
  43161. compensateOnFirstFrame: boolean;
  43162. /**
  43163. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43164. * @param name the name of the camera
  43165. * @param scene the scene to add the camera to
  43166. * @param _xrSessionManager a constructed xr session manager
  43167. */
  43168. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43169. /**
  43170. * Return the user's height, unrelated to the current ground.
  43171. * This will be the y position of this camera, when ground level is 0.
  43172. */
  43173. get realWorldHeight(): number;
  43174. /** @hidden */
  43175. _updateForDualEyeDebugging(): void;
  43176. /**
  43177. * Sets this camera's transformation based on a non-vr camera
  43178. * @param otherCamera the non-vr camera to copy the transformation from
  43179. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43180. */
  43181. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43182. /**
  43183. * Gets the current instance class name ("WebXRCamera").
  43184. * @returns the class name
  43185. */
  43186. getClassName(): string;
  43187. private _updateFromXRSession;
  43188. private _updateNumberOfRigCameras;
  43189. private _updateReferenceSpace;
  43190. private _updateReferenceSpaceOffset;
  43191. }
  43192. }
  43193. declare module BABYLON {
  43194. /**
  43195. * Defining the interface required for a (webxr) feature
  43196. */
  43197. export interface IWebXRFeature extends IDisposable {
  43198. /**
  43199. * Is this feature attached
  43200. */
  43201. attached: boolean;
  43202. /**
  43203. * Should auto-attach be disabled?
  43204. */
  43205. disableAutoAttach: boolean;
  43206. /**
  43207. * Attach the feature to the session
  43208. * Will usually be called by the features manager
  43209. *
  43210. * @param force should attachment be forced (even when already attached)
  43211. * @returns true if successful.
  43212. */
  43213. attach(force?: boolean): boolean;
  43214. /**
  43215. * Detach the feature from the session
  43216. * Will usually be called by the features manager
  43217. *
  43218. * @returns true if successful.
  43219. */
  43220. detach(): boolean;
  43221. }
  43222. /**
  43223. * A list of the currently available features without referencing them
  43224. */
  43225. export class WebXRFeatureName {
  43226. /**
  43227. * The name of the anchor system feature
  43228. */
  43229. static ANCHOR_SYSTEM: string;
  43230. /**
  43231. * The name of the background remover feature
  43232. */
  43233. static BACKGROUND_REMOVER: string;
  43234. /**
  43235. * The name of the hit test feature
  43236. */
  43237. static HIT_TEST: string;
  43238. /**
  43239. * physics impostors for xr controllers feature
  43240. */
  43241. static PHYSICS_CONTROLLERS: string;
  43242. /**
  43243. * The name of the plane detection feature
  43244. */
  43245. static PLANE_DETECTION: string;
  43246. /**
  43247. * The name of the pointer selection feature
  43248. */
  43249. static POINTER_SELECTION: string;
  43250. /**
  43251. * The name of the teleportation feature
  43252. */
  43253. static TELEPORTATION: string;
  43254. }
  43255. /**
  43256. * Defining the constructor of a feature. Used to register the modules.
  43257. */
  43258. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43259. /**
  43260. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43261. * It is mainly used in AR sessions.
  43262. *
  43263. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43264. */
  43265. export class WebXRFeaturesManager implements IDisposable {
  43266. private _xrSessionManager;
  43267. private static readonly _AvailableFeatures;
  43268. private _features;
  43269. /**
  43270. * constructs a new features manages.
  43271. *
  43272. * @param _xrSessionManager an instance of WebXRSessionManager
  43273. */
  43274. constructor(_xrSessionManager: WebXRSessionManager);
  43275. /**
  43276. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43277. * Mainly used internally.
  43278. *
  43279. * @param featureName the name of the feature to register
  43280. * @param constructorFunction the function used to construct the module
  43281. * @param version the (babylon) version of the module
  43282. * @param stable is that a stable version of this module
  43283. */
  43284. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43285. /**
  43286. * Returns a constructor of a specific feature.
  43287. *
  43288. * @param featureName the name of the feature to construct
  43289. * @param version the version of the feature to load
  43290. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43291. * @param options optional options provided to the module.
  43292. * @returns a function that, when called, will return a new instance of this feature
  43293. */
  43294. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43295. /**
  43296. * Can be used to return the list of features currently registered
  43297. *
  43298. * @returns an Array of available features
  43299. */
  43300. static GetAvailableFeatures(): string[];
  43301. /**
  43302. * Gets the versions available for a specific feature
  43303. * @param featureName the name of the feature
  43304. * @returns an array with the available versions
  43305. */
  43306. static GetAvailableVersions(featureName: string): string[];
  43307. /**
  43308. * Return the latest unstable version of this feature
  43309. * @param featureName the name of the feature to search
  43310. * @returns the version number. if not found will return -1
  43311. */
  43312. static GetLatestVersionOfFeature(featureName: string): number;
  43313. /**
  43314. * Return the latest stable version of this feature
  43315. * @param featureName the name of the feature to search
  43316. * @returns the version number. if not found will return -1
  43317. */
  43318. static GetStableVersionOfFeature(featureName: string): number;
  43319. /**
  43320. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43321. * Can be used during a session to start a feature
  43322. * @param featureName the name of feature to attach
  43323. */
  43324. attachFeature(featureName: string): void;
  43325. /**
  43326. * Can be used inside a session or when the session ends to detach a specific feature
  43327. * @param featureName the name of the feature to detach
  43328. */
  43329. detachFeature(featureName: string): void;
  43330. /**
  43331. * Used to disable an already-enabled feature
  43332. * The feature will be disposed and will be recreated once enabled.
  43333. * @param featureName the feature to disable
  43334. * @returns true if disable was successful
  43335. */
  43336. disableFeature(featureName: string | {
  43337. Name: string;
  43338. }): boolean;
  43339. /**
  43340. * dispose this features manager
  43341. */
  43342. dispose(): void;
  43343. /**
  43344. * 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.
  43345. * 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.
  43346. *
  43347. * @param featureName the name of the feature to load or the class of the feature
  43348. * @param version optional version to load. if not provided the latest version will be enabled
  43349. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43350. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43351. * @returns a new constructed feature or throws an error if feature not found.
  43352. */
  43353. enableFeature(featureName: string | {
  43354. Name: string;
  43355. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43356. /**
  43357. * get the implementation of an enabled feature.
  43358. * @param featureName the name of the feature to load
  43359. * @returns the feature class, if found
  43360. */
  43361. getEnabledFeature(featureName: string): IWebXRFeature;
  43362. /**
  43363. * Get the list of enabled features
  43364. * @returns an array of enabled features
  43365. */
  43366. getEnabledFeatures(): string[];
  43367. }
  43368. }
  43369. declare module BABYLON {
  43370. /**
  43371. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43372. * @see https://doc.babylonjs.com/how_to/webxr
  43373. */
  43374. export class WebXRExperienceHelper implements IDisposable {
  43375. private scene;
  43376. private _nonVRCamera;
  43377. private _originalSceneAutoClear;
  43378. private _supported;
  43379. /**
  43380. * Camera used to render xr content
  43381. */
  43382. camera: WebXRCamera;
  43383. /** A features manager for this xr session */
  43384. featuresManager: WebXRFeaturesManager;
  43385. /**
  43386. * Observers registered here will be triggered after the camera's initial transformation is set
  43387. * This can be used to set a different ground level or an extra rotation.
  43388. *
  43389. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43390. * to the position set after this observable is done executing.
  43391. */
  43392. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43393. /**
  43394. * Fires when the state of the experience helper has changed
  43395. */
  43396. onStateChangedObservable: Observable<WebXRState>;
  43397. /** Session manager used to keep track of xr session */
  43398. sessionManager: WebXRSessionManager;
  43399. /**
  43400. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43401. */
  43402. state: WebXRState;
  43403. /**
  43404. * Creates a WebXRExperienceHelper
  43405. * @param scene The scene the helper should be created in
  43406. */
  43407. private constructor();
  43408. /**
  43409. * Creates the experience helper
  43410. * @param scene the scene to attach the experience helper to
  43411. * @returns a promise for the experience helper
  43412. */
  43413. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43414. /**
  43415. * Disposes of the experience helper
  43416. */
  43417. dispose(): void;
  43418. /**
  43419. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43420. * @param sessionMode options for the XR session
  43421. * @param referenceSpaceType frame of reference of the XR session
  43422. * @param renderTarget the output canvas that will be used to enter XR mode
  43423. * @returns promise that resolves after xr mode has entered
  43424. */
  43425. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43426. /**
  43427. * Exits XR mode and returns the scene to its original state
  43428. * @returns promise that resolves after xr mode has exited
  43429. */
  43430. exitXRAsync(): Promise<void>;
  43431. private _nonXRToXRCamera;
  43432. private _setState;
  43433. }
  43434. }
  43435. declare module BABYLON {
  43436. /**
  43437. * X-Y values for axes in WebXR
  43438. */
  43439. export interface IWebXRMotionControllerAxesValue {
  43440. /**
  43441. * The value of the x axis
  43442. */
  43443. x: number;
  43444. /**
  43445. * The value of the y-axis
  43446. */
  43447. y: number;
  43448. }
  43449. /**
  43450. * changed / previous values for the values of this component
  43451. */
  43452. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43453. /**
  43454. * current (this frame) value
  43455. */
  43456. current: T;
  43457. /**
  43458. * previous (last change) value
  43459. */
  43460. previous: T;
  43461. }
  43462. /**
  43463. * Represents changes in the component between current frame and last values recorded
  43464. */
  43465. export interface IWebXRMotionControllerComponentChanges {
  43466. /**
  43467. * will be populated with previous and current values if axes changed
  43468. */
  43469. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43470. /**
  43471. * will be populated with previous and current values if pressed changed
  43472. */
  43473. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43474. /**
  43475. * will be populated with previous and current values if touched changed
  43476. */
  43477. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43478. /**
  43479. * will be populated with previous and current values if value changed
  43480. */
  43481. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43482. }
  43483. /**
  43484. * This class represents a single component (for example button or thumbstick) of a motion controller
  43485. */
  43486. export class WebXRControllerComponent implements IDisposable {
  43487. /**
  43488. * the id of this component
  43489. */
  43490. id: string;
  43491. /**
  43492. * the type of the component
  43493. */
  43494. type: MotionControllerComponentType;
  43495. private _buttonIndex;
  43496. private _axesIndices;
  43497. private _axes;
  43498. private _changes;
  43499. private _currentValue;
  43500. private _hasChanges;
  43501. private _pressed;
  43502. private _touched;
  43503. /**
  43504. * button component type
  43505. */
  43506. static BUTTON_TYPE: MotionControllerComponentType;
  43507. /**
  43508. * squeeze component type
  43509. */
  43510. static SQUEEZE_TYPE: MotionControllerComponentType;
  43511. /**
  43512. * Thumbstick component type
  43513. */
  43514. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43515. /**
  43516. * Touchpad component type
  43517. */
  43518. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43519. /**
  43520. * trigger component type
  43521. */
  43522. static TRIGGER_TYPE: MotionControllerComponentType;
  43523. /**
  43524. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43525. * the axes data changes
  43526. */
  43527. onAxisValueChangedObservable: Observable<{
  43528. x: number;
  43529. y: number;
  43530. }>;
  43531. /**
  43532. * Observers registered here will be triggered when the state of a button changes
  43533. * State change is either pressed / touched / value
  43534. */
  43535. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43536. /**
  43537. * Creates a new component for a motion controller.
  43538. * It is created by the motion controller itself
  43539. *
  43540. * @param id the id of this component
  43541. * @param type the type of the component
  43542. * @param _buttonIndex index in the buttons array of the gamepad
  43543. * @param _axesIndices indices of the values in the axes array of the gamepad
  43544. */
  43545. constructor(
  43546. /**
  43547. * the id of this component
  43548. */
  43549. id: string,
  43550. /**
  43551. * the type of the component
  43552. */
  43553. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43554. /**
  43555. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43556. */
  43557. get axes(): IWebXRMotionControllerAxesValue;
  43558. /**
  43559. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43560. */
  43561. get changes(): IWebXRMotionControllerComponentChanges;
  43562. /**
  43563. * Return whether or not the component changed the last frame
  43564. */
  43565. get hasChanges(): boolean;
  43566. /**
  43567. * is the button currently pressed
  43568. */
  43569. get pressed(): boolean;
  43570. /**
  43571. * is the button currently touched
  43572. */
  43573. get touched(): boolean;
  43574. /**
  43575. * Get the current value of this component
  43576. */
  43577. get value(): number;
  43578. /**
  43579. * Dispose this component
  43580. */
  43581. dispose(): void;
  43582. /**
  43583. * Are there axes correlating to this component
  43584. * @return true is axes data is available
  43585. */
  43586. isAxes(): boolean;
  43587. /**
  43588. * Is this component a button (hence - pressable)
  43589. * @returns true if can be pressed
  43590. */
  43591. isButton(): boolean;
  43592. /**
  43593. * update this component using the gamepad object it is in. Called on every frame
  43594. * @param nativeController the native gamepad controller object
  43595. */
  43596. update(nativeController: IMinimalMotionControllerObject): void;
  43597. }
  43598. }
  43599. declare module BABYLON {
  43600. /**
  43601. * Class used to represent data loading progression
  43602. */
  43603. export class SceneLoaderProgressEvent {
  43604. /** defines if data length to load can be evaluated */
  43605. readonly lengthComputable: boolean;
  43606. /** defines the loaded data length */
  43607. readonly loaded: number;
  43608. /** defines the data length to load */
  43609. readonly total: number;
  43610. /**
  43611. * Create a new progress event
  43612. * @param lengthComputable defines if data length to load can be evaluated
  43613. * @param loaded defines the loaded data length
  43614. * @param total defines the data length to load
  43615. */
  43616. constructor(
  43617. /** defines if data length to load can be evaluated */
  43618. lengthComputable: boolean,
  43619. /** defines the loaded data length */
  43620. loaded: number,
  43621. /** defines the data length to load */
  43622. total: number);
  43623. /**
  43624. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43625. * @param event defines the source event
  43626. * @returns a new SceneLoaderProgressEvent
  43627. */
  43628. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43629. }
  43630. /**
  43631. * Interface used by SceneLoader plugins to define supported file extensions
  43632. */
  43633. export interface ISceneLoaderPluginExtensions {
  43634. /**
  43635. * Defines the list of supported extensions
  43636. */
  43637. [extension: string]: {
  43638. isBinary: boolean;
  43639. };
  43640. }
  43641. /**
  43642. * Interface used by SceneLoader plugin factory
  43643. */
  43644. export interface ISceneLoaderPluginFactory {
  43645. /**
  43646. * Defines the name of the factory
  43647. */
  43648. name: string;
  43649. /**
  43650. * Function called to create a new plugin
  43651. * @return the new plugin
  43652. */
  43653. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43654. /**
  43655. * The callback that returns true if the data can be directly loaded.
  43656. * @param data string containing the file data
  43657. * @returns if the data can be loaded directly
  43658. */
  43659. canDirectLoad?(data: string): boolean;
  43660. }
  43661. /**
  43662. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43663. */
  43664. export interface ISceneLoaderPluginBase {
  43665. /**
  43666. * The friendly name of this plugin.
  43667. */
  43668. name: string;
  43669. /**
  43670. * The file extensions supported by this plugin.
  43671. */
  43672. extensions: string | ISceneLoaderPluginExtensions;
  43673. /**
  43674. * The callback called when loading from a url.
  43675. * @param scene scene loading this url
  43676. * @param url url to load
  43677. * @param onSuccess callback called when the file successfully loads
  43678. * @param onProgress callback called while file is loading (if the server supports this mode)
  43679. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43680. * @param onError callback called when the file fails to load
  43681. * @returns a file request object
  43682. */
  43683. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43684. /**
  43685. * The callback called when loading from a file object.
  43686. * @param scene scene loading this file
  43687. * @param file defines the file to load
  43688. * @param onSuccess defines the callback to call when data is loaded
  43689. * @param onProgress defines the callback to call during loading process
  43690. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43691. * @param onError defines the callback to call when an error occurs
  43692. * @returns a file request object
  43693. */
  43694. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43695. /**
  43696. * The callback that returns true if the data can be directly loaded.
  43697. * @param data string containing the file data
  43698. * @returns if the data can be loaded directly
  43699. */
  43700. canDirectLoad?(data: string): boolean;
  43701. /**
  43702. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43703. * @param scene scene loading this data
  43704. * @param data string containing the data
  43705. * @returns data to pass to the plugin
  43706. */
  43707. directLoad?(scene: Scene, data: string): any;
  43708. /**
  43709. * The callback that allows custom handling of the root url based on the response url.
  43710. * @param rootUrl the original root url
  43711. * @param responseURL the response url if available
  43712. * @returns the new root url
  43713. */
  43714. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43715. }
  43716. /**
  43717. * Interface used to define a SceneLoader plugin
  43718. */
  43719. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43720. /**
  43721. * Import meshes into a scene.
  43722. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43723. * @param scene The scene to import into
  43724. * @param data The data to import
  43725. * @param rootUrl The root url for scene and resources
  43726. * @param meshes The meshes array to import into
  43727. * @param particleSystems The particle systems array to import into
  43728. * @param skeletons The skeletons array to import into
  43729. * @param onError The callback when import fails
  43730. * @returns True if successful or false otherwise
  43731. */
  43732. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43733. /**
  43734. * Load into a scene.
  43735. * @param scene The scene to load into
  43736. * @param data The data to import
  43737. * @param rootUrl The root url for scene and resources
  43738. * @param onError The callback when import fails
  43739. * @returns True if successful or false otherwise
  43740. */
  43741. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43742. /**
  43743. * Load into an asset container.
  43744. * @param scene The scene to load into
  43745. * @param data The data to import
  43746. * @param rootUrl The root url for scene and resources
  43747. * @param onError The callback when import fails
  43748. * @returns The loaded asset container
  43749. */
  43750. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43751. }
  43752. /**
  43753. * Interface used to define an async SceneLoader plugin
  43754. */
  43755. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43756. /**
  43757. * Import meshes into a scene.
  43758. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43759. * @param scene The scene to import into
  43760. * @param data The data to import
  43761. * @param rootUrl The root url for scene and resources
  43762. * @param onProgress The callback when the load progresses
  43763. * @param fileName Defines the name of the file to load
  43764. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43765. */
  43766. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43767. meshes: AbstractMesh[];
  43768. particleSystems: IParticleSystem[];
  43769. skeletons: Skeleton[];
  43770. animationGroups: AnimationGroup[];
  43771. }>;
  43772. /**
  43773. * Load into a scene.
  43774. * @param scene The scene to load into
  43775. * @param data The data to import
  43776. * @param rootUrl The root url for scene and resources
  43777. * @param onProgress The callback when the load progresses
  43778. * @param fileName Defines the name of the file to load
  43779. * @returns Nothing
  43780. */
  43781. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43782. /**
  43783. * Load into an asset container.
  43784. * @param scene The scene to load into
  43785. * @param data The data to import
  43786. * @param rootUrl The root url for scene and resources
  43787. * @param onProgress The callback when the load progresses
  43788. * @param fileName Defines the name of the file to load
  43789. * @returns The loaded asset container
  43790. */
  43791. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43792. }
  43793. /**
  43794. * Mode that determines how to handle old animation groups before loading new ones.
  43795. */
  43796. export enum SceneLoaderAnimationGroupLoadingMode {
  43797. /**
  43798. * Reset all old animations to initial state then dispose them.
  43799. */
  43800. Clean = 0,
  43801. /**
  43802. * Stop all old animations.
  43803. */
  43804. Stop = 1,
  43805. /**
  43806. * Restart old animations from first frame.
  43807. */
  43808. Sync = 2,
  43809. /**
  43810. * Old animations remains untouched.
  43811. */
  43812. NoSync = 3
  43813. }
  43814. /**
  43815. * Class used to load scene from various file formats using registered plugins
  43816. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43817. */
  43818. export class SceneLoader {
  43819. /**
  43820. * No logging while loading
  43821. */
  43822. static readonly NO_LOGGING: number;
  43823. /**
  43824. * Minimal logging while loading
  43825. */
  43826. static readonly MINIMAL_LOGGING: number;
  43827. /**
  43828. * Summary logging while loading
  43829. */
  43830. static readonly SUMMARY_LOGGING: number;
  43831. /**
  43832. * Detailled logging while loading
  43833. */
  43834. static readonly DETAILED_LOGGING: number;
  43835. /**
  43836. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43837. */
  43838. static get ForceFullSceneLoadingForIncremental(): boolean;
  43839. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43840. /**
  43841. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43842. */
  43843. static get ShowLoadingScreen(): boolean;
  43844. static set ShowLoadingScreen(value: boolean);
  43845. /**
  43846. * Defines the current logging level (while loading the scene)
  43847. * @ignorenaming
  43848. */
  43849. static get loggingLevel(): number;
  43850. static set loggingLevel(value: number);
  43851. /**
  43852. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43853. */
  43854. static get CleanBoneMatrixWeights(): boolean;
  43855. static set CleanBoneMatrixWeights(value: boolean);
  43856. /**
  43857. * Event raised when a plugin is used to load a scene
  43858. */
  43859. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43860. private static _registeredPlugins;
  43861. private static _getDefaultPlugin;
  43862. private static _getPluginForExtension;
  43863. private static _getPluginForDirectLoad;
  43864. private static _getPluginForFilename;
  43865. private static _getDirectLoad;
  43866. private static _loadData;
  43867. private static _getFileInfo;
  43868. /**
  43869. * Gets a plugin that can load the given extension
  43870. * @param extension defines the extension to load
  43871. * @returns a plugin or null if none works
  43872. */
  43873. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43874. /**
  43875. * Gets a boolean indicating that the given extension can be loaded
  43876. * @param extension defines the extension to load
  43877. * @returns true if the extension is supported
  43878. */
  43879. static IsPluginForExtensionAvailable(extension: string): boolean;
  43880. /**
  43881. * Adds a new plugin to the list of registered plugins
  43882. * @param plugin defines the plugin to add
  43883. */
  43884. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43885. /**
  43886. * Import meshes into a scene
  43887. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43888. * @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)
  43889. * @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)
  43890. * @param scene the instance of BABYLON.Scene to append to
  43891. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43892. * @param onProgress a callback with a progress event for each file being loaded
  43893. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43894. * @param pluginExtension the extension used to determine the plugin
  43895. * @returns The loaded plugin
  43896. */
  43897. 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>;
  43898. /**
  43899. * Import meshes into a scene
  43900. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 scene the instance of BABYLON.Scene to append to
  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 list of imported meshes, particle systems, skeletons, and animation groups
  43907. */
  43908. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43909. meshes: AbstractMesh[];
  43910. particleSystems: IParticleSystem[];
  43911. skeletons: Skeleton[];
  43912. animationGroups: AnimationGroup[];
  43913. }>;
  43914. /**
  43915. * Load a scene
  43916. * @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)
  43917. * @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)
  43918. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43919. * @param onSuccess a callback with the scene when import succeeds
  43920. * @param onProgress a callback with a progress event for each file being loaded
  43921. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43922. * @param pluginExtension the extension used to determine the plugin
  43923. * @returns The loaded plugin
  43924. */
  43925. 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>;
  43926. /**
  43927. * Load a scene
  43928. * @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)
  43929. * @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)
  43930. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43931. * @param onProgress a callback with a progress event for each file being loaded
  43932. * @param pluginExtension the extension used to determine the plugin
  43933. * @returns The loaded scene
  43934. */
  43935. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43936. /**
  43937. * Append a scene
  43938. * @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)
  43939. * @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)
  43940. * @param scene is the instance of BABYLON.Scene to append to
  43941. * @param onSuccess a callback with the scene when import succeeds
  43942. * @param onProgress a callback with a progress event for each file being loaded
  43943. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43944. * @param pluginExtension the extension used to determine the plugin
  43945. * @returns The loaded plugin
  43946. */
  43947. 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>;
  43948. /**
  43949. * Append a scene
  43950. * @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)
  43951. * @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)
  43952. * @param scene is the instance of BABYLON.Scene to append to
  43953. * @param onProgress a callback with a progress event for each file being loaded
  43954. * @param pluginExtension the extension used to determine the plugin
  43955. * @returns The given scene
  43956. */
  43957. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43958. /**
  43959. * Load a scene into an asset container
  43960. * @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)
  43961. * @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)
  43962. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43963. * @param onSuccess a callback with the scene when import succeeds
  43964. * @param onProgress a callback with a progress event for each file being loaded
  43965. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43966. * @param pluginExtension the extension used to determine the plugin
  43967. * @returns The loaded plugin
  43968. */
  43969. 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>;
  43970. /**
  43971. * Load a scene into an asset container
  43972. * @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)
  43973. * @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)
  43974. * @param scene is the instance of Scene to append to
  43975. * @param onProgress a callback with a progress event for each file being loaded
  43976. * @param pluginExtension the extension used to determine the plugin
  43977. * @returns The loaded asset container
  43978. */
  43979. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43980. /**
  43981. * Import animations from a file into a scene
  43982. * @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)
  43983. * @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)
  43984. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43985. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43986. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43987. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43988. * @param onSuccess a callback with the scene when import succeeds
  43989. * @param onProgress a callback with a progress event for each file being loaded
  43990. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43991. */
  43992. 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;
  43993. /**
  43994. * Import animations from a file into a scene
  43995. * @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)
  43996. * @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)
  43997. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43998. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43999. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44000. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44001. * @param onSuccess a callback with the scene when import succeeds
  44002. * @param onProgress a callback with a progress event for each file being loaded
  44003. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44004. * @returns the updated scene with imported animations
  44005. */
  44006. 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>;
  44007. }
  44008. }
  44009. declare module BABYLON {
  44010. /**
  44011. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44012. */
  44013. export type MotionControllerHandness = "none" | "left" | "right";
  44014. /**
  44015. * The type of components available in motion controllers.
  44016. * This is not the name of the component.
  44017. */
  44018. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44019. /**
  44020. * The state of a controller component
  44021. */
  44022. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44023. /**
  44024. * The schema of motion controller layout.
  44025. * No object will be initialized using this interface
  44026. * This is used just to define the profile.
  44027. */
  44028. export interface IMotionControllerLayout {
  44029. /**
  44030. * Path to load the assets. Usually relative to the base path
  44031. */
  44032. assetPath: string;
  44033. /**
  44034. * Available components (unsorted)
  44035. */
  44036. components: {
  44037. /**
  44038. * A map of component Ids
  44039. */
  44040. [componentId: string]: {
  44041. /**
  44042. * The type of input the component outputs
  44043. */
  44044. type: MotionControllerComponentType;
  44045. /**
  44046. * The indices of this component in the gamepad object
  44047. */
  44048. gamepadIndices: {
  44049. /**
  44050. * Index of button
  44051. */
  44052. button?: number;
  44053. /**
  44054. * If available, index of x-axis
  44055. */
  44056. xAxis?: number;
  44057. /**
  44058. * If available, index of y-axis
  44059. */
  44060. yAxis?: number;
  44061. };
  44062. /**
  44063. * The mesh's root node name
  44064. */
  44065. rootNodeName: string;
  44066. /**
  44067. * Animation definitions for this model
  44068. */
  44069. visualResponses: {
  44070. [stateKey: string]: {
  44071. /**
  44072. * What property will be animated
  44073. */
  44074. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44075. /**
  44076. * What states influence this visual response
  44077. */
  44078. states: MotionControllerComponentStateType[];
  44079. /**
  44080. * Type of animation - movement or visibility
  44081. */
  44082. valueNodeProperty: "transform" | "visibility";
  44083. /**
  44084. * Base node name to move. Its position will be calculated according to the min and max nodes
  44085. */
  44086. valueNodeName?: string;
  44087. /**
  44088. * Minimum movement node
  44089. */
  44090. minNodeName?: string;
  44091. /**
  44092. * Max movement node
  44093. */
  44094. maxNodeName?: string;
  44095. };
  44096. };
  44097. /**
  44098. * If touch enabled, what is the name of node to display user feedback
  44099. */
  44100. touchPointNodeName?: string;
  44101. };
  44102. };
  44103. /**
  44104. * Is it xr standard mapping or not
  44105. */
  44106. gamepadMapping: "" | "xr-standard";
  44107. /**
  44108. * Base root node of this entire model
  44109. */
  44110. rootNodeName: string;
  44111. /**
  44112. * Defines the main button component id
  44113. */
  44114. selectComponentId: string;
  44115. }
  44116. /**
  44117. * A definition for the layout map in the input profile
  44118. */
  44119. export interface IMotionControllerLayoutMap {
  44120. /**
  44121. * Layouts with handness type as a key
  44122. */
  44123. [handness: string]: IMotionControllerLayout;
  44124. }
  44125. /**
  44126. * The XR Input profile schema
  44127. * Profiles can be found here:
  44128. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44129. */
  44130. export interface IMotionControllerProfile {
  44131. /**
  44132. * fallback profiles for this profileId
  44133. */
  44134. fallbackProfileIds: string[];
  44135. /**
  44136. * The layout map, with handness as key
  44137. */
  44138. layouts: IMotionControllerLayoutMap;
  44139. /**
  44140. * The id of this profile
  44141. * correlates to the profile(s) in the xrInput.profiles array
  44142. */
  44143. profileId: string;
  44144. }
  44145. /**
  44146. * A helper-interface for the 3 meshes needed for controller button animation
  44147. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44148. */
  44149. export interface IMotionControllerButtonMeshMap {
  44150. /**
  44151. * the mesh that defines the pressed value mesh position.
  44152. * This is used to find the max-position of this button
  44153. */
  44154. pressedMesh: AbstractMesh;
  44155. /**
  44156. * the mesh that defines the unpressed value mesh position.
  44157. * This is used to find the min (or initial) position of this button
  44158. */
  44159. unpressedMesh: AbstractMesh;
  44160. /**
  44161. * The mesh that will be changed when value changes
  44162. */
  44163. valueMesh: AbstractMesh;
  44164. }
  44165. /**
  44166. * A helper-interface for the 3 meshes needed for controller axis animation.
  44167. * This will be expanded when touchpad animations are fully supported
  44168. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44169. */
  44170. export interface IMotionControllerMeshMap {
  44171. /**
  44172. * the mesh that defines the maximum value mesh position.
  44173. */
  44174. maxMesh?: AbstractMesh;
  44175. /**
  44176. * the mesh that defines the minimum value mesh position.
  44177. */
  44178. minMesh?: AbstractMesh;
  44179. /**
  44180. * The mesh that will be changed when axis value changes
  44181. */
  44182. valueMesh: AbstractMesh;
  44183. }
  44184. /**
  44185. * The elements needed for change-detection of the gamepad objects in motion controllers
  44186. */
  44187. export interface IMinimalMotionControllerObject {
  44188. /**
  44189. * Available axes of this controller
  44190. */
  44191. axes: number[];
  44192. /**
  44193. * An array of available buttons
  44194. */
  44195. buttons: Array<{
  44196. /**
  44197. * Value of the button/trigger
  44198. */
  44199. value: number;
  44200. /**
  44201. * If the button/trigger is currently touched
  44202. */
  44203. touched: boolean;
  44204. /**
  44205. * If the button/trigger is currently pressed
  44206. */
  44207. pressed: boolean;
  44208. }>;
  44209. }
  44210. /**
  44211. * An Abstract Motion controller
  44212. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44213. * Each component has an observable to check for changes in value and state
  44214. */
  44215. export abstract class WebXRAbstractMotionController implements IDisposable {
  44216. protected scene: Scene;
  44217. protected layout: IMotionControllerLayout;
  44218. /**
  44219. * The gamepad object correlating to this controller
  44220. */
  44221. gamepadObject: IMinimalMotionControllerObject;
  44222. /**
  44223. * handness (left/right/none) of this controller
  44224. */
  44225. handness: MotionControllerHandness;
  44226. private _initComponent;
  44227. private _modelReady;
  44228. /**
  44229. * A map of components (WebXRControllerComponent) in this motion controller
  44230. * Components have a ComponentType and can also have both button and axis definitions
  44231. */
  44232. readonly components: {
  44233. [id: string]: WebXRControllerComponent;
  44234. };
  44235. /**
  44236. * Disable the model's animation. Can be set at any time.
  44237. */
  44238. disableAnimation: boolean;
  44239. /**
  44240. * Observers registered here will be triggered when the model of this controller is done loading
  44241. */
  44242. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44243. /**
  44244. * The profile id of this motion controller
  44245. */
  44246. abstract profileId: string;
  44247. /**
  44248. * The root mesh of the model. It is null if the model was not yet initialized
  44249. */
  44250. rootMesh: Nullable<AbstractMesh>;
  44251. /**
  44252. * constructs a new abstract motion controller
  44253. * @param scene the scene to which the model of the controller will be added
  44254. * @param layout The profile layout to load
  44255. * @param gamepadObject The gamepad object correlating to this controller
  44256. * @param handness handness (left/right/none) of this controller
  44257. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44258. */
  44259. constructor(scene: Scene, layout: IMotionControllerLayout,
  44260. /**
  44261. * The gamepad object correlating to this controller
  44262. */
  44263. gamepadObject: IMinimalMotionControllerObject,
  44264. /**
  44265. * handness (left/right/none) of this controller
  44266. */
  44267. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44268. /**
  44269. * Dispose this controller, the model mesh and all its components
  44270. */
  44271. dispose(): void;
  44272. /**
  44273. * Returns all components of specific type
  44274. * @param type the type to search for
  44275. * @return an array of components with this type
  44276. */
  44277. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44278. /**
  44279. * get a component based an its component id as defined in layout.components
  44280. * @param id the id of the component
  44281. * @returns the component correlates to the id or undefined if not found
  44282. */
  44283. getComponent(id: string): WebXRControllerComponent;
  44284. /**
  44285. * Get the list of components available in this motion controller
  44286. * @returns an array of strings correlating to available components
  44287. */
  44288. getComponentIds(): string[];
  44289. /**
  44290. * Get the first component of specific type
  44291. * @param type type of component to find
  44292. * @return a controller component or null if not found
  44293. */
  44294. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44295. /**
  44296. * Get the main (Select) component of this controller as defined in the layout
  44297. * @returns the main component of this controller
  44298. */
  44299. getMainComponent(): WebXRControllerComponent;
  44300. /**
  44301. * Loads the model correlating to this controller
  44302. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44303. * @returns A promise fulfilled with the result of the model loading
  44304. */
  44305. loadModel(): Promise<boolean>;
  44306. /**
  44307. * Update this model using the current XRFrame
  44308. * @param xrFrame the current xr frame to use and update the model
  44309. */
  44310. updateFromXRFrame(xrFrame: XRFrame): void;
  44311. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44312. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44313. /**
  44314. * Moves the axis on the controller mesh based on its current state
  44315. * @param axis the index of the axis
  44316. * @param axisValue the value of the axis which determines the meshes new position
  44317. * @hidden
  44318. */
  44319. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44320. /**
  44321. * Update the model itself with the current frame data
  44322. * @param xrFrame the frame to use for updating the model mesh
  44323. */
  44324. protected updateModel(xrFrame: XRFrame): void;
  44325. /**
  44326. * Get the filename and path for this controller's model
  44327. * @returns a map of filename and path
  44328. */
  44329. protected abstract _getFilenameAndPath(): {
  44330. filename: string;
  44331. path: string;
  44332. };
  44333. /**
  44334. * This function is called before the mesh is loaded. It checks for loading constraints.
  44335. * For example, this function can check if the GLB loader is available
  44336. * If this function returns false, the generic controller will be loaded instead
  44337. * @returns Is the client ready to load the mesh
  44338. */
  44339. protected abstract _getModelLoadingConstraints(): boolean;
  44340. /**
  44341. * This function will be called after the model was successfully loaded and can be used
  44342. * for mesh transformations before it is available for the user
  44343. * @param meshes the loaded meshes
  44344. */
  44345. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44346. /**
  44347. * Set the root mesh for this controller. Important for the WebXR controller class
  44348. * @param meshes the loaded meshes
  44349. */
  44350. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44351. /**
  44352. * A function executed each frame that updates the mesh (if needed)
  44353. * @param xrFrame the current xrFrame
  44354. */
  44355. protected abstract _updateModel(xrFrame: XRFrame): void;
  44356. private _getGenericFilenameAndPath;
  44357. private _getGenericParentMesh;
  44358. }
  44359. }
  44360. declare module BABYLON {
  44361. /**
  44362. * A generic trigger-only motion controller for WebXR
  44363. */
  44364. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44365. /**
  44366. * Static version of the profile id of this controller
  44367. */
  44368. static ProfileId: string;
  44369. profileId: string;
  44370. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44371. protected _getFilenameAndPath(): {
  44372. filename: string;
  44373. path: string;
  44374. };
  44375. protected _getModelLoadingConstraints(): boolean;
  44376. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44377. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44378. protected _updateModel(): void;
  44379. }
  44380. }
  44381. declare module BABYLON {
  44382. /**
  44383. * Class containing static functions to help procedurally build meshes
  44384. */
  44385. export class SphereBuilder {
  44386. /**
  44387. * Creates a sphere mesh
  44388. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44389. * * 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`)
  44390. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44391. * * 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
  44392. * * 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)
  44393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44394. * * 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
  44395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44396. * @param name defines the name of the mesh
  44397. * @param options defines the options used to create the mesh
  44398. * @param scene defines the hosting scene
  44399. * @returns the sphere mesh
  44400. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44401. */
  44402. static CreateSphere(name: string, options: {
  44403. segments?: number;
  44404. diameter?: number;
  44405. diameterX?: number;
  44406. diameterY?: number;
  44407. diameterZ?: number;
  44408. arc?: number;
  44409. slice?: number;
  44410. sideOrientation?: number;
  44411. frontUVs?: Vector4;
  44412. backUVs?: Vector4;
  44413. updatable?: boolean;
  44414. }, scene?: Nullable<Scene>): Mesh;
  44415. }
  44416. }
  44417. declare module BABYLON {
  44418. /**
  44419. * A profiled motion controller has its profile loaded from an online repository.
  44420. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44421. */
  44422. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44423. private _repositoryUrl;
  44424. private _buttonMeshMapping;
  44425. private _touchDots;
  44426. /**
  44427. * The profile ID of this controller. Will be populated when the controller initializes.
  44428. */
  44429. profileId: string;
  44430. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44431. dispose(): void;
  44432. protected _getFilenameAndPath(): {
  44433. filename: string;
  44434. path: string;
  44435. };
  44436. protected _getModelLoadingConstraints(): boolean;
  44437. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44438. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44439. protected _updateModel(_xrFrame: XRFrame): void;
  44440. }
  44441. }
  44442. declare module BABYLON {
  44443. /**
  44444. * A construction function type to create a new controller based on an xrInput object
  44445. */
  44446. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44447. /**
  44448. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44449. *
  44450. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44451. * it should be replaced with auto-loaded controllers.
  44452. *
  44453. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44454. */
  44455. export class WebXRMotionControllerManager {
  44456. private static _AvailableControllers;
  44457. private static _Fallbacks;
  44458. private static _ProfileLoadingPromises;
  44459. private static _ProfilesList;
  44460. /**
  44461. * The base URL of the online controller repository. Can be changed at any time.
  44462. */
  44463. static BaseRepositoryUrl: string;
  44464. /**
  44465. * Which repository gets priority - local or online
  44466. */
  44467. static PrioritizeOnlineRepository: boolean;
  44468. /**
  44469. * Use the online repository, or use only locally-defined controllers
  44470. */
  44471. static UseOnlineRepository: boolean;
  44472. /**
  44473. * Clear the cache used for profile loading and reload when requested again
  44474. */
  44475. static ClearProfilesCache(): void;
  44476. /**
  44477. * Register the default fallbacks.
  44478. * This function is called automatically when this file is imported.
  44479. */
  44480. static DefaultFallbacks(): void;
  44481. /**
  44482. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44483. * @param profileId the profile to which a fallback needs to be found
  44484. * @return an array with corresponding fallback profiles
  44485. */
  44486. static FindFallbackWithProfileId(profileId: string): string[];
  44487. /**
  44488. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44489. * The order of search:
  44490. *
  44491. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44492. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44493. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44494. * 4) return the generic trigger controller if none were found
  44495. *
  44496. * @param xrInput the xrInput to which a new controller is initialized
  44497. * @param scene the scene to which the model will be added
  44498. * @param forceProfile force a certain profile for this controller
  44499. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44500. */
  44501. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44502. /**
  44503. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44504. *
  44505. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44506. *
  44507. * @param type the profile type to register
  44508. * @param constructFunction the function to be called when loading this profile
  44509. */
  44510. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44511. /**
  44512. * Register a fallback to a specific profile.
  44513. * @param profileId the profileId that will receive the fallbacks
  44514. * @param fallbacks A list of fallback profiles
  44515. */
  44516. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44517. /**
  44518. * Will update the list of profiles available in the repository
  44519. * @return a promise that resolves to a map of profiles available online
  44520. */
  44521. static UpdateProfilesList(): Promise<{
  44522. [profile: string]: string;
  44523. }>;
  44524. private static _LoadProfileFromRepository;
  44525. private static _LoadProfilesFromAvailableControllers;
  44526. }
  44527. }
  44528. declare module BABYLON {
  44529. /**
  44530. * Configuration options for the WebXR controller creation
  44531. */
  44532. export interface IWebXRControllerOptions {
  44533. /**
  44534. * Should the controller mesh be animated when a user interacts with it
  44535. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44536. */
  44537. disableMotionControllerAnimation?: boolean;
  44538. /**
  44539. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44540. */
  44541. doNotLoadControllerMesh?: boolean;
  44542. /**
  44543. * Force a specific controller type for this controller.
  44544. * This can be used when creating your own profile or when testing different controllers
  44545. */
  44546. forceControllerProfile?: string;
  44547. }
  44548. /**
  44549. * Represents an XR controller
  44550. */
  44551. export class WebXRInputSource {
  44552. private _scene;
  44553. /** The underlying input source for the controller */
  44554. inputSource: XRInputSource;
  44555. private _options;
  44556. private _tmpQuaternion;
  44557. private _tmpVector;
  44558. private _uniqueId;
  44559. /**
  44560. * 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
  44561. */
  44562. grip?: AbstractMesh;
  44563. /**
  44564. * If available, this is the gamepad object related to this controller.
  44565. * Using this object it is possible to get click events and trackpad changes of the
  44566. * webxr controller that is currently being used.
  44567. */
  44568. motionController?: WebXRAbstractMotionController;
  44569. /**
  44570. * Event that fires when the controller is removed/disposed.
  44571. * The object provided as event data is this controller, after associated assets were disposed.
  44572. * uniqueId is still available.
  44573. */
  44574. onDisposeObservable: Observable<WebXRInputSource>;
  44575. /**
  44576. * Will be triggered when the mesh associated with the motion controller is done loading.
  44577. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44578. * A shortened version of controller -> motion controller -> on mesh loaded.
  44579. */
  44580. onMeshLoadedObservable: Observable<AbstractMesh>;
  44581. /**
  44582. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44583. */
  44584. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44585. /**
  44586. * Pointer which can be used to select objects or attach a visible laser to
  44587. */
  44588. pointer: AbstractMesh;
  44589. /**
  44590. * Creates the controller
  44591. * @see https://doc.babylonjs.com/how_to/webxr
  44592. * @param _scene the scene which the controller should be associated to
  44593. * @param inputSource the underlying input source for the controller
  44594. * @param _options options for this controller creation
  44595. */
  44596. constructor(_scene: Scene,
  44597. /** The underlying input source for the controller */
  44598. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44599. /**
  44600. * Get this controllers unique id
  44601. */
  44602. get uniqueId(): string;
  44603. /**
  44604. * Disposes of the object
  44605. */
  44606. dispose(): void;
  44607. /**
  44608. * Gets a world space ray coming from the pointer or grip
  44609. * @param result the resulting ray
  44610. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44611. */
  44612. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44613. /**
  44614. * Updates the controller pose based on the given XRFrame
  44615. * @param xrFrame xr frame to update the pose with
  44616. * @param referenceSpace reference space to use
  44617. */
  44618. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44619. }
  44620. }
  44621. declare module BABYLON {
  44622. /**
  44623. * The schema for initialization options of the XR Input class
  44624. */
  44625. export interface IWebXRInputOptions {
  44626. /**
  44627. * If set to true no model will be automatically loaded
  44628. */
  44629. doNotLoadControllerMeshes?: boolean;
  44630. /**
  44631. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44632. * If not found, the xr input profile data will be used.
  44633. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44634. */
  44635. forceInputProfile?: string;
  44636. /**
  44637. * Do not send a request to the controller repository to load the profile.
  44638. *
  44639. * Instead, use the controllers available in babylon itself.
  44640. */
  44641. disableOnlineControllerRepository?: boolean;
  44642. /**
  44643. * A custom URL for the controllers repository
  44644. */
  44645. customControllersRepositoryURL?: string;
  44646. /**
  44647. * Should the controller model's components not move according to the user input
  44648. */
  44649. disableControllerAnimation?: boolean;
  44650. }
  44651. /**
  44652. * XR input used to track XR inputs such as controllers/rays
  44653. */
  44654. export class WebXRInput implements IDisposable {
  44655. /**
  44656. * the xr session manager for this session
  44657. */
  44658. xrSessionManager: WebXRSessionManager;
  44659. /**
  44660. * the WebXR camera for this session. Mainly used for teleportation
  44661. */
  44662. xrCamera: WebXRCamera;
  44663. private readonly options;
  44664. /**
  44665. * XR controllers being tracked
  44666. */
  44667. controllers: Array<WebXRInputSource>;
  44668. private _frameObserver;
  44669. private _sessionEndedObserver;
  44670. private _sessionInitObserver;
  44671. /**
  44672. * Event when a controller has been connected/added
  44673. */
  44674. onControllerAddedObservable: Observable<WebXRInputSource>;
  44675. /**
  44676. * Event when a controller has been removed/disconnected
  44677. */
  44678. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44679. /**
  44680. * Initializes the WebXRInput
  44681. * @param xrSessionManager the xr session manager for this session
  44682. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44683. * @param options = initialization options for this xr input
  44684. */
  44685. constructor(
  44686. /**
  44687. * the xr session manager for this session
  44688. */
  44689. xrSessionManager: WebXRSessionManager,
  44690. /**
  44691. * the WebXR camera for this session. Mainly used for teleportation
  44692. */
  44693. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44694. private _onInputSourcesChange;
  44695. private _addAndRemoveControllers;
  44696. /**
  44697. * Disposes of the object
  44698. */
  44699. dispose(): void;
  44700. }
  44701. }
  44702. declare module BABYLON {
  44703. /**
  44704. * This is the base class for all WebXR features.
  44705. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44706. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44707. */
  44708. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44709. protected _xrSessionManager: WebXRSessionManager;
  44710. private _attached;
  44711. private _removeOnDetach;
  44712. /**
  44713. * Should auto-attach be disabled?
  44714. */
  44715. disableAutoAttach: boolean;
  44716. /**
  44717. * Construct a new (abstract) WebXR feature
  44718. * @param _xrSessionManager the xr session manager for this feature
  44719. */
  44720. constructor(_xrSessionManager: WebXRSessionManager);
  44721. /**
  44722. * Is this feature attached
  44723. */
  44724. get attached(): boolean;
  44725. /**
  44726. * attach this feature
  44727. *
  44728. * @param force should attachment be forced (even when already attached)
  44729. * @returns true if successful, false is failed or already attached
  44730. */
  44731. attach(force?: boolean): boolean;
  44732. /**
  44733. * detach this feature.
  44734. *
  44735. * @returns true if successful, false if failed or already detached
  44736. */
  44737. detach(): boolean;
  44738. /**
  44739. * Dispose this feature and all of the resources attached
  44740. */
  44741. dispose(): void;
  44742. /**
  44743. * This is used to register callbacks that will automatically be removed when detach is called.
  44744. * @param observable the observable to which the observer will be attached
  44745. * @param callback the callback to register
  44746. */
  44747. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44748. /**
  44749. * Code in this function will be executed on each xrFrame received from the browser.
  44750. * This function will not execute after the feature is detached.
  44751. * @param _xrFrame the current frame
  44752. */
  44753. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44754. }
  44755. }
  44756. declare module BABYLON {
  44757. /**
  44758. * Renders a layer on top of an existing scene
  44759. */
  44760. export class UtilityLayerRenderer implements IDisposable {
  44761. /** the original scene that will be rendered on top of */
  44762. originalScene: Scene;
  44763. private _pointerCaptures;
  44764. private _lastPointerEvents;
  44765. private static _DefaultUtilityLayer;
  44766. private static _DefaultKeepDepthUtilityLayer;
  44767. private _sharedGizmoLight;
  44768. private _renderCamera;
  44769. /**
  44770. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44771. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44772. * @returns the camera that is used when rendering the utility layer
  44773. */
  44774. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44775. /**
  44776. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44777. * @param cam the camera that should be used when rendering the utility layer
  44778. */
  44779. setRenderCamera(cam: Nullable<Camera>): void;
  44780. /**
  44781. * @hidden
  44782. * Light which used by gizmos to get light shading
  44783. */
  44784. _getSharedGizmoLight(): HemisphericLight;
  44785. /**
  44786. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44787. */
  44788. pickUtilitySceneFirst: boolean;
  44789. /**
  44790. * 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)
  44791. */
  44792. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44793. /**
  44794. * 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)
  44795. */
  44796. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44797. /**
  44798. * The scene that is rendered on top of the original scene
  44799. */
  44800. utilityLayerScene: Scene;
  44801. /**
  44802. * If the utility layer should automatically be rendered on top of existing scene
  44803. */
  44804. shouldRender: boolean;
  44805. /**
  44806. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44807. */
  44808. onlyCheckPointerDownEvents: boolean;
  44809. /**
  44810. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44811. */
  44812. processAllEvents: boolean;
  44813. /**
  44814. * Observable raised when the pointer move from the utility layer scene to the main scene
  44815. */
  44816. onPointerOutObservable: Observable<number>;
  44817. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44818. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44819. private _afterRenderObserver;
  44820. private _sceneDisposeObserver;
  44821. private _originalPointerObserver;
  44822. /**
  44823. * Instantiates a UtilityLayerRenderer
  44824. * @param originalScene the original scene that will be rendered on top of
  44825. * @param handleEvents boolean indicating if the utility layer should handle events
  44826. */
  44827. constructor(
  44828. /** the original scene that will be rendered on top of */
  44829. originalScene: Scene, handleEvents?: boolean);
  44830. private _notifyObservers;
  44831. /**
  44832. * Renders the utility layers scene on top of the original scene
  44833. */
  44834. render(): void;
  44835. /**
  44836. * Disposes of the renderer
  44837. */
  44838. dispose(): void;
  44839. private _updateCamera;
  44840. }
  44841. }
  44842. declare module BABYLON {
  44843. /**
  44844. * Options interface for the pointer selection module
  44845. */
  44846. export interface IWebXRControllerPointerSelectionOptions {
  44847. /**
  44848. * if provided, this scene will be used to render meshes.
  44849. */
  44850. customUtilityLayerScene?: Scene;
  44851. /**
  44852. * 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)
  44853. * If not disabled, the last picked point will be used to execute a pointer up event
  44854. * If disabled, pointer up event will be triggered right after the pointer down event.
  44855. * Used in screen and gaze target ray mode only
  44856. */
  44857. disablePointerUpOnTouchOut: boolean;
  44858. /**
  44859. * For gaze mode (time to select instead of press)
  44860. */
  44861. forceGazeMode: boolean;
  44862. /**
  44863. * 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
  44864. * to start a new countdown to the pointer down event.
  44865. * Defaults to 1.
  44866. */
  44867. gazeModePointerMovedFactor?: number;
  44868. /**
  44869. * Different button type to use instead of the main component
  44870. */
  44871. overrideButtonId?: string;
  44872. /**
  44873. * use this rendering group id for the meshes (optional)
  44874. */
  44875. renderingGroupId?: number;
  44876. /**
  44877. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44878. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44879. * 3000 means 3 seconds between pointing at something and selecting it
  44880. */
  44881. timeToSelect?: number;
  44882. /**
  44883. * Should meshes created here be added to a utility layer or the main scene
  44884. */
  44885. useUtilityLayer?: boolean;
  44886. /**
  44887. * the xr input to use with this pointer selection
  44888. */
  44889. xrInput: WebXRInput;
  44890. }
  44891. /**
  44892. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44893. */
  44894. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44895. private readonly _options;
  44896. private static _idCounter;
  44897. private _attachController;
  44898. private _controllers;
  44899. private _scene;
  44900. private _tmpVectorForPickCompare;
  44901. /**
  44902. * The module's name
  44903. */
  44904. static readonly Name: string;
  44905. /**
  44906. * The (Babylon) version of this module.
  44907. * This is an integer representing the implementation version.
  44908. * This number does not correspond to the WebXR specs version
  44909. */
  44910. static readonly Version: number;
  44911. /**
  44912. * Disable lighting on the laser pointer (so it will always be visible)
  44913. */
  44914. disablePointerLighting: boolean;
  44915. /**
  44916. * Disable lighting on the selection mesh (so it will always be visible)
  44917. */
  44918. disableSelectionMeshLighting: boolean;
  44919. /**
  44920. * Should the laser pointer be displayed
  44921. */
  44922. displayLaserPointer: boolean;
  44923. /**
  44924. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44925. */
  44926. displaySelectionMesh: boolean;
  44927. /**
  44928. * This color will be set to the laser pointer when selection is triggered
  44929. */
  44930. laserPointerPickedColor: Color3;
  44931. /**
  44932. * Default color of the laser pointer
  44933. */
  44934. lasterPointerDefaultColor: Color3;
  44935. /**
  44936. * default color of the selection ring
  44937. */
  44938. selectionMeshDefaultColor: Color3;
  44939. /**
  44940. * This color will be applied to the selection ring when selection is triggered
  44941. */
  44942. selectionMeshPickedColor: Color3;
  44943. /**
  44944. * Optional filter to be used for ray selection. This predicate shares behavior with
  44945. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44946. */
  44947. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44948. /**
  44949. * constructs a new background remover module
  44950. * @param _xrSessionManager the session manager for this module
  44951. * @param _options read-only options to be used in this module
  44952. */
  44953. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44954. /**
  44955. * attach this feature
  44956. * Will usually be called by the features manager
  44957. *
  44958. * @returns true if successful.
  44959. */
  44960. attach(): boolean;
  44961. /**
  44962. * detach this feature.
  44963. * Will usually be called by the features manager
  44964. *
  44965. * @returns true if successful.
  44966. */
  44967. detach(): boolean;
  44968. /**
  44969. * Will get the mesh under a specific pointer.
  44970. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44971. * @param controllerId the controllerId to check
  44972. * @returns The mesh under pointer or null if no mesh is under the pointer
  44973. */
  44974. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44975. /**
  44976. * Get the xr controller that correlates to the pointer id in the pointer event
  44977. *
  44978. * @param id the pointer id to search for
  44979. * @returns the controller that correlates to this id or null if not found
  44980. */
  44981. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44982. protected _onXRFrame(_xrFrame: XRFrame): void;
  44983. private _attachGazeMode;
  44984. private _attachScreenRayMode;
  44985. private _attachTrackedPointerRayMode;
  44986. private _convertNormalToDirectionOfRay;
  44987. private _detachController;
  44988. private _generateNewMeshPair;
  44989. private _pickingMoved;
  44990. private _updatePointerDistance;
  44991. }
  44992. }
  44993. declare module BABYLON {
  44994. /**
  44995. * Button which can be used to enter a different mode of XR
  44996. */
  44997. export class WebXREnterExitUIButton {
  44998. /** button element */
  44999. element: HTMLElement;
  45000. /** XR initialization options for the button */
  45001. sessionMode: XRSessionMode;
  45002. /** Reference space type */
  45003. referenceSpaceType: XRReferenceSpaceType;
  45004. /**
  45005. * Creates a WebXREnterExitUIButton
  45006. * @param element button element
  45007. * @param sessionMode XR initialization session mode
  45008. * @param referenceSpaceType the type of reference space to be used
  45009. */
  45010. constructor(
  45011. /** button element */
  45012. element: HTMLElement,
  45013. /** XR initialization options for the button */
  45014. sessionMode: XRSessionMode,
  45015. /** Reference space type */
  45016. referenceSpaceType: XRReferenceSpaceType);
  45017. /**
  45018. * Extendable function which can be used to update the button's visuals when the state changes
  45019. * @param activeButton the current active button in the UI
  45020. */
  45021. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45022. }
  45023. /**
  45024. * Options to create the webXR UI
  45025. */
  45026. export class WebXREnterExitUIOptions {
  45027. /**
  45028. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45029. */
  45030. customButtons?: Array<WebXREnterExitUIButton>;
  45031. /**
  45032. * A reference space type to use when creating the default button.
  45033. * Default is local-floor
  45034. */
  45035. referenceSpaceType?: XRReferenceSpaceType;
  45036. /**
  45037. * Context to enter xr with
  45038. */
  45039. renderTarget?: Nullable<WebXRRenderTarget>;
  45040. /**
  45041. * A session mode to use when creating the default button.
  45042. * Default is immersive-vr
  45043. */
  45044. sessionMode?: XRSessionMode;
  45045. }
  45046. /**
  45047. * UI to allow the user to enter/exit XR mode
  45048. */
  45049. export class WebXREnterExitUI implements IDisposable {
  45050. private scene;
  45051. /** version of the options passed to this UI */
  45052. options: WebXREnterExitUIOptions;
  45053. private _activeButton;
  45054. private _buttons;
  45055. private _overlay;
  45056. /**
  45057. * Fired every time the active button is changed.
  45058. *
  45059. * When xr is entered via a button that launches xr that button will be the callback parameter
  45060. *
  45061. * When exiting xr the callback parameter will be null)
  45062. */
  45063. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45064. /**
  45065. *
  45066. * @param scene babylon scene object to use
  45067. * @param options (read-only) version of the options passed to this UI
  45068. */
  45069. private constructor();
  45070. /**
  45071. * Creates UI to allow the user to enter/exit XR mode
  45072. * @param scene the scene to add the ui to
  45073. * @param helper the xr experience helper to enter/exit xr with
  45074. * @param options options to configure the UI
  45075. * @returns the created ui
  45076. */
  45077. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45078. /**
  45079. * Disposes of the XR UI component
  45080. */
  45081. dispose(): void;
  45082. private _updateButtons;
  45083. }
  45084. }
  45085. declare module BABYLON {
  45086. /**
  45087. * Class containing static functions to help procedurally build meshes
  45088. */
  45089. export class LinesBuilder {
  45090. /**
  45091. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45092. * * 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
  45093. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45094. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45095. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45096. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45097. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45098. * * 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
  45099. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45102. * @param name defines the name of the new line system
  45103. * @param options defines the options used to create the line system
  45104. * @param scene defines the hosting scene
  45105. * @returns a new line system mesh
  45106. */
  45107. static CreateLineSystem(name: string, options: {
  45108. lines: Vector3[][];
  45109. updatable?: boolean;
  45110. instance?: Nullable<LinesMesh>;
  45111. colors?: Nullable<Color4[][]>;
  45112. useVertexAlpha?: boolean;
  45113. }, scene: Nullable<Scene>): LinesMesh;
  45114. /**
  45115. * Creates a line mesh
  45116. * 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
  45117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45118. * * The parameter `points` is an array successive Vector3
  45119. * * 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
  45120. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45121. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45122. * * When updating an instance, remember that only point positions can change, not the number of points
  45123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45125. * @param name defines the name of the new line system
  45126. * @param options defines the options used to create the line system
  45127. * @param scene defines the hosting scene
  45128. * @returns a new line mesh
  45129. */
  45130. static CreateLines(name: string, options: {
  45131. points: Vector3[];
  45132. updatable?: boolean;
  45133. instance?: Nullable<LinesMesh>;
  45134. colors?: Color4[];
  45135. useVertexAlpha?: boolean;
  45136. }, scene?: Nullable<Scene>): LinesMesh;
  45137. /**
  45138. * Creates a dashed line mesh
  45139. * * 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
  45140. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45141. * * The parameter `points` is an array successive Vector3
  45142. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45143. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45144. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45145. * * 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
  45146. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45147. * * When updating an instance, remember that only point positions can change, not the number of points
  45148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45149. * @param name defines the name of the mesh
  45150. * @param options defines the options used to create the mesh
  45151. * @param scene defines the hosting scene
  45152. * @returns the dashed line mesh
  45153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45154. */
  45155. static CreateDashedLines(name: string, options: {
  45156. points: Vector3[];
  45157. dashSize?: number;
  45158. gapSize?: number;
  45159. dashNb?: number;
  45160. updatable?: boolean;
  45161. instance?: LinesMesh;
  45162. useVertexAlpha?: boolean;
  45163. }, scene?: Nullable<Scene>): LinesMesh;
  45164. }
  45165. }
  45166. declare module BABYLON {
  45167. /**
  45168. * The options container for the teleportation module
  45169. */
  45170. export interface IWebXRTeleportationOptions {
  45171. /**
  45172. * if provided, this scene will be used to render meshes.
  45173. */
  45174. customUtilityLayerScene?: Scene;
  45175. /**
  45176. * Values to configure the default target mesh
  45177. */
  45178. defaultTargetMeshOptions?: {
  45179. /**
  45180. * Fill color of the teleportation area
  45181. */
  45182. teleportationFillColor?: string;
  45183. /**
  45184. * Border color for the teleportation area
  45185. */
  45186. teleportationBorderColor?: string;
  45187. /**
  45188. * Disable the mesh's animation sequence
  45189. */
  45190. disableAnimation?: boolean;
  45191. /**
  45192. * Disable lighting on the material or the ring and arrow
  45193. */
  45194. disableLighting?: boolean;
  45195. /**
  45196. * Override the default material of the torus and arrow
  45197. */
  45198. torusArrowMaterial?: Material;
  45199. };
  45200. /**
  45201. * A list of meshes to use as floor meshes.
  45202. * Meshes can be added and removed after initializing the feature using the
  45203. * addFloorMesh and removeFloorMesh functions
  45204. * If empty, rotation will still work
  45205. */
  45206. floorMeshes?: AbstractMesh[];
  45207. /**
  45208. * use this rendering group id for the meshes (optional)
  45209. */
  45210. renderingGroupId?: number;
  45211. /**
  45212. * Should teleportation move only to snap points
  45213. */
  45214. snapPointsOnly?: boolean;
  45215. /**
  45216. * An array of points to which the teleportation will snap to.
  45217. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45218. */
  45219. snapPositions?: Vector3[];
  45220. /**
  45221. * How close should the teleportation ray be in order to snap to position.
  45222. * Default to 0.8 units (meters)
  45223. */
  45224. snapToPositionRadius?: number;
  45225. /**
  45226. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45227. * If you want to support rotation, make sure your mesh has a direction indicator.
  45228. *
  45229. * When left untouched, the default mesh will be initialized.
  45230. */
  45231. teleportationTargetMesh?: AbstractMesh;
  45232. /**
  45233. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45234. */
  45235. timeToTeleport?: number;
  45236. /**
  45237. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45238. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45239. */
  45240. useMainComponentOnly?: boolean;
  45241. /**
  45242. * Should meshes created here be added to a utility layer or the main scene
  45243. */
  45244. useUtilityLayer?: boolean;
  45245. /**
  45246. * Babylon XR Input class for controller
  45247. */
  45248. xrInput: WebXRInput;
  45249. }
  45250. /**
  45251. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45252. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45253. * the input of the attached controllers.
  45254. */
  45255. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45256. private _options;
  45257. private _controllers;
  45258. private _currentTeleportationControllerId;
  45259. private _floorMeshes;
  45260. private _quadraticBezierCurve;
  45261. private _selectionFeature;
  45262. private _snapToPositions;
  45263. private _snappedToPoint;
  45264. private _teleportationRingMaterial?;
  45265. private _tmpRay;
  45266. private _tmpVector;
  45267. /**
  45268. * The module's name
  45269. */
  45270. static readonly Name: string;
  45271. /**
  45272. * The (Babylon) version of this module.
  45273. * This is an integer representing the implementation version.
  45274. * This number does not correspond to the webxr specs version
  45275. */
  45276. static readonly Version: number;
  45277. /**
  45278. * Is movement backwards enabled
  45279. */
  45280. backwardsMovementEnabled: boolean;
  45281. /**
  45282. * Distance to travel when moving backwards
  45283. */
  45284. backwardsTeleportationDistance: number;
  45285. /**
  45286. * The distance from the user to the inspection point in the direction of the controller
  45287. * A higher number will allow the user to move further
  45288. * defaults to 5 (meters, in xr units)
  45289. */
  45290. parabolicCheckRadius: number;
  45291. /**
  45292. * Should the module support parabolic ray on top of direct ray
  45293. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45294. * Very helpful when moving between floors / different heights
  45295. */
  45296. parabolicRayEnabled: boolean;
  45297. /**
  45298. * How much rotation should be applied when rotating right and left
  45299. */
  45300. rotationAngle: number;
  45301. /**
  45302. * Is rotation enabled when moving forward?
  45303. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45304. */
  45305. rotationEnabled: boolean;
  45306. /**
  45307. * constructs a new anchor system
  45308. * @param _xrSessionManager an instance of WebXRSessionManager
  45309. * @param _options configuration object for this feature
  45310. */
  45311. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45312. /**
  45313. * Get the snapPointsOnly flag
  45314. */
  45315. get snapPointsOnly(): boolean;
  45316. /**
  45317. * Sets the snapPointsOnly flag
  45318. * @param snapToPoints should teleportation be exclusively to snap points
  45319. */
  45320. set snapPointsOnly(snapToPoints: boolean);
  45321. /**
  45322. * Add a new mesh to the floor meshes array
  45323. * @param mesh the mesh to use as floor mesh
  45324. */
  45325. addFloorMesh(mesh: AbstractMesh): void;
  45326. /**
  45327. * Add a new snap-to point to fix teleportation to this position
  45328. * @param newSnapPoint The new Snap-To point
  45329. */
  45330. addSnapPoint(newSnapPoint: Vector3): void;
  45331. attach(): boolean;
  45332. detach(): boolean;
  45333. dispose(): void;
  45334. /**
  45335. * Remove a mesh from the floor meshes array
  45336. * @param mesh the mesh to remove
  45337. */
  45338. removeFloorMesh(mesh: AbstractMesh): void;
  45339. /**
  45340. * Remove a mesh from the floor meshes array using its name
  45341. * @param name the mesh name to remove
  45342. */
  45343. removeFloorMeshByName(name: string): void;
  45344. /**
  45345. * 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
  45346. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45347. * @returns was the point found and removed or not
  45348. */
  45349. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45350. /**
  45351. * This function sets a selection feature that will be disabled when
  45352. * the forward ray is shown and will be reattached when hidden.
  45353. * This is used to remove the selection rays when moving.
  45354. * @param selectionFeature the feature to disable when forward movement is enabled
  45355. */
  45356. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45357. protected _onXRFrame(_xrFrame: XRFrame): void;
  45358. private _attachController;
  45359. private _createDefaultTargetMesh;
  45360. private _detachController;
  45361. private _findClosestSnapPointWithRadius;
  45362. private _setTargetMeshPosition;
  45363. private _setTargetMeshVisibility;
  45364. private _showParabolicPath;
  45365. private _teleportForward;
  45366. }
  45367. }
  45368. declare module BABYLON {
  45369. /**
  45370. * Options for the default xr helper
  45371. */
  45372. export class WebXRDefaultExperienceOptions {
  45373. /**
  45374. * Enable or disable default UI to enter XR
  45375. */
  45376. disableDefaultUI?: boolean;
  45377. /**
  45378. * Should teleportation not initialize. defaults to false.
  45379. */
  45380. disableTeleportation?: boolean;
  45381. /**
  45382. * Floor meshes that will be used for teleport
  45383. */
  45384. floorMeshes?: Array<AbstractMesh>;
  45385. /**
  45386. * If set to true, the first frame will not be used to reset position
  45387. * The first frame is mainly used when copying transformation from the old camera
  45388. * Mainly used in AR
  45389. */
  45390. ignoreNativeCameraTransformation?: boolean;
  45391. /**
  45392. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45393. */
  45394. inputOptions?: IWebXRInputOptions;
  45395. /**
  45396. * optional configuration for the output canvas
  45397. */
  45398. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45399. /**
  45400. * optional UI options. This can be used among other to change session mode and reference space type
  45401. */
  45402. uiOptions?: WebXREnterExitUIOptions;
  45403. /**
  45404. * When loading teleportation and pointer select, use stable versions instead of latest.
  45405. */
  45406. useStablePlugins?: boolean;
  45407. }
  45408. /**
  45409. * Default experience which provides a similar setup to the previous webVRExperience
  45410. */
  45411. export class WebXRDefaultExperience {
  45412. /**
  45413. * Base experience
  45414. */
  45415. baseExperience: WebXRExperienceHelper;
  45416. /**
  45417. * Enables ui for entering/exiting xr
  45418. */
  45419. enterExitUI: WebXREnterExitUI;
  45420. /**
  45421. * Input experience extension
  45422. */
  45423. input: WebXRInput;
  45424. /**
  45425. * Enables laser pointer and selection
  45426. */
  45427. pointerSelection: WebXRControllerPointerSelection;
  45428. /**
  45429. * Default target xr should render to
  45430. */
  45431. renderTarget: WebXRRenderTarget;
  45432. /**
  45433. * Enables teleportation
  45434. */
  45435. teleportation: WebXRMotionControllerTeleportation;
  45436. private constructor();
  45437. /**
  45438. * Creates the default xr experience
  45439. * @param scene scene
  45440. * @param options options for basic configuration
  45441. * @returns resulting WebXRDefaultExperience
  45442. */
  45443. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45444. /**
  45445. * DIsposes of the experience helper
  45446. */
  45447. dispose(): void;
  45448. }
  45449. }
  45450. declare module BABYLON {
  45451. /**
  45452. * Options to modify the vr teleportation behavior.
  45453. */
  45454. export interface VRTeleportationOptions {
  45455. /**
  45456. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45457. */
  45458. floorMeshName?: string;
  45459. /**
  45460. * A list of meshes to be used as the teleportation floor. (default: empty)
  45461. */
  45462. floorMeshes?: Mesh[];
  45463. /**
  45464. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45465. */
  45466. teleportationMode?: number;
  45467. /**
  45468. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45469. */
  45470. teleportationTime?: number;
  45471. /**
  45472. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45473. */
  45474. teleportationSpeed?: number;
  45475. /**
  45476. * The easing function used in the animation or null for Linear. (default CircleEase)
  45477. */
  45478. easingFunction?: EasingFunction;
  45479. }
  45480. /**
  45481. * Options to modify the vr experience helper's behavior.
  45482. */
  45483. export interface VRExperienceHelperOptions extends WebVROptions {
  45484. /**
  45485. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45486. */
  45487. createDeviceOrientationCamera?: boolean;
  45488. /**
  45489. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45490. */
  45491. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45492. /**
  45493. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45494. */
  45495. laserToggle?: boolean;
  45496. /**
  45497. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45498. */
  45499. floorMeshes?: Mesh[];
  45500. /**
  45501. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45502. */
  45503. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45504. /**
  45505. * Defines if WebXR should be used instead of WebVR (if available)
  45506. */
  45507. useXR?: boolean;
  45508. }
  45509. /**
  45510. * Event containing information after VR has been entered
  45511. */
  45512. export class OnAfterEnteringVRObservableEvent {
  45513. /**
  45514. * If entering vr was successful
  45515. */
  45516. success: boolean;
  45517. }
  45518. /**
  45519. * Helps to quickly add VR support to an existing scene.
  45520. * See http://doc.babylonjs.com/how_to/webvr_helper
  45521. */
  45522. export class VRExperienceHelper {
  45523. /** Options to modify the vr experience helper's behavior. */
  45524. webVROptions: VRExperienceHelperOptions;
  45525. private _scene;
  45526. private _position;
  45527. private _btnVR;
  45528. private _btnVRDisplayed;
  45529. private _webVRsupported;
  45530. private _webVRready;
  45531. private _webVRrequesting;
  45532. private _webVRpresenting;
  45533. private _hasEnteredVR;
  45534. private _fullscreenVRpresenting;
  45535. private _inputElement;
  45536. private _webVRCamera;
  45537. private _vrDeviceOrientationCamera;
  45538. private _deviceOrientationCamera;
  45539. private _existingCamera;
  45540. private _onKeyDown;
  45541. private _onVrDisplayPresentChange;
  45542. private _onVRDisplayChanged;
  45543. private _onVRRequestPresentStart;
  45544. private _onVRRequestPresentComplete;
  45545. /**
  45546. * 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)
  45547. */
  45548. enableGazeEvenWhenNoPointerLock: boolean;
  45549. /**
  45550. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45551. */
  45552. exitVROnDoubleTap: boolean;
  45553. /**
  45554. * Observable raised right before entering VR.
  45555. */
  45556. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45557. /**
  45558. * Observable raised when entering VR has completed.
  45559. */
  45560. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45561. /**
  45562. * Observable raised when exiting VR.
  45563. */
  45564. onExitingVRObservable: Observable<VRExperienceHelper>;
  45565. /**
  45566. * Observable raised when controller mesh is loaded.
  45567. */
  45568. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45569. /** Return this.onEnteringVRObservable
  45570. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45571. */
  45572. get onEnteringVR(): Observable<VRExperienceHelper>;
  45573. /** Return this.onExitingVRObservable
  45574. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45575. */
  45576. get onExitingVR(): Observable<VRExperienceHelper>;
  45577. /** Return this.onControllerMeshLoadedObservable
  45578. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45579. */
  45580. get onControllerMeshLoaded(): Observable<WebVRController>;
  45581. private _rayLength;
  45582. private _useCustomVRButton;
  45583. private _teleportationRequested;
  45584. private _teleportActive;
  45585. private _floorMeshName;
  45586. private _floorMeshesCollection;
  45587. private _teleportationMode;
  45588. private _teleportationTime;
  45589. private _teleportationSpeed;
  45590. private _teleportationEasing;
  45591. private _rotationAllowed;
  45592. private _teleportBackwardsVector;
  45593. private _teleportationTarget;
  45594. private _isDefaultTeleportationTarget;
  45595. private _postProcessMove;
  45596. private _teleportationFillColor;
  45597. private _teleportationBorderColor;
  45598. private _rotationAngle;
  45599. private _haloCenter;
  45600. private _cameraGazer;
  45601. private _padSensibilityUp;
  45602. private _padSensibilityDown;
  45603. private _leftController;
  45604. private _rightController;
  45605. private _gazeColor;
  45606. private _laserColor;
  45607. private _pickedLaserColor;
  45608. private _pickedGazeColor;
  45609. /**
  45610. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45611. */
  45612. onNewMeshSelected: Observable<AbstractMesh>;
  45613. /**
  45614. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45615. * This observable will provide the mesh and the controller used to select the mesh
  45616. */
  45617. onMeshSelectedWithController: Observable<{
  45618. mesh: AbstractMesh;
  45619. controller: WebVRController;
  45620. }>;
  45621. /**
  45622. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45623. */
  45624. onNewMeshPicked: Observable<PickingInfo>;
  45625. private _circleEase;
  45626. /**
  45627. * Observable raised before camera teleportation
  45628. */
  45629. onBeforeCameraTeleport: Observable<Vector3>;
  45630. /**
  45631. * Observable raised after camera teleportation
  45632. */
  45633. onAfterCameraTeleport: Observable<Vector3>;
  45634. /**
  45635. * Observable raised when current selected mesh gets unselected
  45636. */
  45637. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45638. private _raySelectionPredicate;
  45639. /**
  45640. * To be optionaly changed by user to define custom ray selection
  45641. */
  45642. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45643. /**
  45644. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45645. */
  45646. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45647. /**
  45648. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45649. */
  45650. teleportationEnabled: boolean;
  45651. private _defaultHeight;
  45652. private _teleportationInitialized;
  45653. private _interactionsEnabled;
  45654. private _interactionsRequested;
  45655. private _displayGaze;
  45656. private _displayLaserPointer;
  45657. /**
  45658. * The mesh used to display where the user is going to teleport.
  45659. */
  45660. get teleportationTarget(): Mesh;
  45661. /**
  45662. * Sets the mesh to be used to display where the user is going to teleport.
  45663. */
  45664. set teleportationTarget(value: Mesh);
  45665. /**
  45666. * 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
  45667. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45668. * See http://doc.babylonjs.com/resources/baking_transformations
  45669. */
  45670. get gazeTrackerMesh(): Mesh;
  45671. set gazeTrackerMesh(value: Mesh);
  45672. /**
  45673. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45674. */
  45675. updateGazeTrackerScale: boolean;
  45676. /**
  45677. * If the gaze trackers color should be updated when selecting meshes
  45678. */
  45679. updateGazeTrackerColor: boolean;
  45680. /**
  45681. * If the controller laser color should be updated when selecting meshes
  45682. */
  45683. updateControllerLaserColor: boolean;
  45684. /**
  45685. * The gaze tracking mesh corresponding to the left controller
  45686. */
  45687. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45688. /**
  45689. * The gaze tracking mesh corresponding to the right controller
  45690. */
  45691. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45692. /**
  45693. * If the ray of the gaze should be displayed.
  45694. */
  45695. get displayGaze(): boolean;
  45696. /**
  45697. * Sets if the ray of the gaze should be displayed.
  45698. */
  45699. set displayGaze(value: boolean);
  45700. /**
  45701. * If the ray of the LaserPointer should be displayed.
  45702. */
  45703. get displayLaserPointer(): boolean;
  45704. /**
  45705. * Sets if the ray of the LaserPointer should be displayed.
  45706. */
  45707. set displayLaserPointer(value: boolean);
  45708. /**
  45709. * The deviceOrientationCamera used as the camera when not in VR.
  45710. */
  45711. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45712. /**
  45713. * Based on the current WebVR support, returns the current VR camera used.
  45714. */
  45715. get currentVRCamera(): Nullable<Camera>;
  45716. /**
  45717. * The webVRCamera which is used when in VR.
  45718. */
  45719. get webVRCamera(): WebVRFreeCamera;
  45720. /**
  45721. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45722. */
  45723. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45724. /**
  45725. * The html button that is used to trigger entering into VR.
  45726. */
  45727. get vrButton(): Nullable<HTMLButtonElement>;
  45728. private get _teleportationRequestInitiated();
  45729. /**
  45730. * Defines whether or not Pointer lock should be requested when switching to
  45731. * full screen.
  45732. */
  45733. requestPointerLockOnFullScreen: boolean;
  45734. /**
  45735. * If asking to force XR, this will be populated with the default xr experience
  45736. */
  45737. xr: WebXRDefaultExperience;
  45738. /**
  45739. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45740. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45741. */
  45742. xrTestDone: boolean;
  45743. /**
  45744. * Instantiates a VRExperienceHelper.
  45745. * Helps to quickly add VR support to an existing scene.
  45746. * @param scene The scene the VRExperienceHelper belongs to.
  45747. * @param webVROptions Options to modify the vr experience helper's behavior.
  45748. */
  45749. constructor(scene: Scene,
  45750. /** Options to modify the vr experience helper's behavior. */
  45751. webVROptions?: VRExperienceHelperOptions);
  45752. private completeVRInit;
  45753. private _onDefaultMeshLoaded;
  45754. private _onResize;
  45755. private _onFullscreenChange;
  45756. /**
  45757. * Gets a value indicating if we are currently in VR mode.
  45758. */
  45759. get isInVRMode(): boolean;
  45760. private onVrDisplayPresentChange;
  45761. private onVRDisplayChanged;
  45762. private moveButtonToBottomRight;
  45763. private displayVRButton;
  45764. private updateButtonVisibility;
  45765. private _cachedAngularSensibility;
  45766. /**
  45767. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45768. * Otherwise, will use the fullscreen API.
  45769. */
  45770. enterVR(): void;
  45771. /**
  45772. * Attempt to exit VR, or fullscreen.
  45773. */
  45774. exitVR(): void;
  45775. /**
  45776. * The position of the vr experience helper.
  45777. */
  45778. get position(): Vector3;
  45779. /**
  45780. * Sets the position of the vr experience helper.
  45781. */
  45782. set position(value: Vector3);
  45783. /**
  45784. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45785. */
  45786. enableInteractions(): void;
  45787. private get _noControllerIsActive();
  45788. private beforeRender;
  45789. private _isTeleportationFloor;
  45790. /**
  45791. * Adds a floor mesh to be used for teleportation.
  45792. * @param floorMesh the mesh to be used for teleportation.
  45793. */
  45794. addFloorMesh(floorMesh: Mesh): void;
  45795. /**
  45796. * Removes a floor mesh from being used for teleportation.
  45797. * @param floorMesh the mesh to be removed.
  45798. */
  45799. removeFloorMesh(floorMesh: Mesh): void;
  45800. /**
  45801. * Enables interactions and teleportation using the VR controllers and gaze.
  45802. * @param vrTeleportationOptions options to modify teleportation behavior.
  45803. */
  45804. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45805. private _onNewGamepadConnected;
  45806. private _tryEnableInteractionOnController;
  45807. private _onNewGamepadDisconnected;
  45808. private _enableInteractionOnController;
  45809. private _checkTeleportWithRay;
  45810. private _checkRotate;
  45811. private _checkTeleportBackwards;
  45812. private _enableTeleportationOnController;
  45813. private _createTeleportationCircles;
  45814. private _displayTeleportationTarget;
  45815. private _hideTeleportationTarget;
  45816. private _rotateCamera;
  45817. private _moveTeleportationSelectorTo;
  45818. private _workingVector;
  45819. private _workingQuaternion;
  45820. private _workingMatrix;
  45821. /**
  45822. * Time Constant Teleportation Mode
  45823. */
  45824. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45825. /**
  45826. * Speed Constant Teleportation Mode
  45827. */
  45828. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45829. /**
  45830. * Teleports the users feet to the desired location
  45831. * @param location The location where the user's feet should be placed
  45832. */
  45833. teleportCamera(location: Vector3): void;
  45834. private _convertNormalToDirectionOfRay;
  45835. private _castRayAndSelectObject;
  45836. private _notifySelectedMeshUnselected;
  45837. /**
  45838. * Permanently set new colors for the laser pointer
  45839. * @param color the new laser color
  45840. * @param pickedColor the new laser color when picked mesh detected
  45841. */
  45842. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45843. /**
  45844. * Set lighting enabled / disabled on the laser pointer of both controllers
  45845. * @param enabled should the lighting be enabled on the laser pointer
  45846. */
  45847. setLaserLightingState(enabled?: boolean): void;
  45848. /**
  45849. * Permanently set new colors for the gaze pointer
  45850. * @param color the new gaze color
  45851. * @param pickedColor the new gaze color when picked mesh detected
  45852. */
  45853. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45854. /**
  45855. * Sets the color of the laser ray from the vr controllers.
  45856. * @param color new color for the ray.
  45857. */
  45858. changeLaserColor(color: Color3): void;
  45859. /**
  45860. * Sets the color of the ray from the vr headsets gaze.
  45861. * @param color new color for the ray.
  45862. */
  45863. changeGazeColor(color: Color3): void;
  45864. /**
  45865. * Exits VR and disposes of the vr experience helper
  45866. */
  45867. dispose(): void;
  45868. /**
  45869. * Gets the name of the VRExperienceHelper class
  45870. * @returns "VRExperienceHelper"
  45871. */
  45872. getClassName(): string;
  45873. }
  45874. }
  45875. declare module BABYLON {
  45876. /**
  45877. * Contains an array of blocks representing the octree
  45878. */
  45879. export interface IOctreeContainer<T> {
  45880. /**
  45881. * Blocks within the octree
  45882. */
  45883. blocks: Array<OctreeBlock<T>>;
  45884. }
  45885. /**
  45886. * Class used to store a cell in an octree
  45887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45888. */
  45889. export class OctreeBlock<T> {
  45890. /**
  45891. * Gets the content of the current block
  45892. */
  45893. entries: T[];
  45894. /**
  45895. * Gets the list of block children
  45896. */
  45897. blocks: Array<OctreeBlock<T>>;
  45898. private _depth;
  45899. private _maxDepth;
  45900. private _capacity;
  45901. private _minPoint;
  45902. private _maxPoint;
  45903. private _boundingVectors;
  45904. private _creationFunc;
  45905. /**
  45906. * Creates a new block
  45907. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45908. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45909. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45910. * @param depth defines the current depth of this block in the octree
  45911. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45912. * @param creationFunc defines a callback to call when an element is added to the block
  45913. */
  45914. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45915. /**
  45916. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45917. */
  45918. get capacity(): number;
  45919. /**
  45920. * Gets the minimum vector (in world space) of the block's bounding box
  45921. */
  45922. get minPoint(): Vector3;
  45923. /**
  45924. * Gets the maximum vector (in world space) of the block's bounding box
  45925. */
  45926. get maxPoint(): Vector3;
  45927. /**
  45928. * Add a new element to this block
  45929. * @param entry defines the element to add
  45930. */
  45931. addEntry(entry: T): void;
  45932. /**
  45933. * Remove an element from this block
  45934. * @param entry defines the element to remove
  45935. */
  45936. removeEntry(entry: T): void;
  45937. /**
  45938. * Add an array of elements to this block
  45939. * @param entries defines the array of elements to add
  45940. */
  45941. addEntries(entries: T[]): void;
  45942. /**
  45943. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45944. * @param frustumPlanes defines the frustum planes to test
  45945. * @param selection defines the array to store current content if selection is positive
  45946. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45947. */
  45948. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45949. /**
  45950. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45951. * @param sphereCenter defines the bounding sphere center
  45952. * @param sphereRadius defines the bounding sphere radius
  45953. * @param selection defines the array to store current content if selection is positive
  45954. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45955. */
  45956. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45957. /**
  45958. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45959. * @param ray defines the ray to test with
  45960. * @param selection defines the array to store current content if selection is positive
  45961. */
  45962. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45963. /**
  45964. * Subdivide the content into child blocks (this block will then be empty)
  45965. */
  45966. createInnerBlocks(): void;
  45967. /**
  45968. * @hidden
  45969. */
  45970. 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;
  45971. }
  45972. }
  45973. declare module BABYLON {
  45974. /**
  45975. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45976. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45977. */
  45978. export class Octree<T> {
  45979. /** 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.) */
  45980. maxDepth: number;
  45981. /**
  45982. * Blocks within the octree containing objects
  45983. */
  45984. blocks: Array<OctreeBlock<T>>;
  45985. /**
  45986. * Content stored in the octree
  45987. */
  45988. dynamicContent: T[];
  45989. private _maxBlockCapacity;
  45990. private _selectionContent;
  45991. private _creationFunc;
  45992. /**
  45993. * Creates a octree
  45994. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45995. * @param creationFunc function to be used to instatiate the octree
  45996. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45997. * @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.)
  45998. */
  45999. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46000. /** 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.) */
  46001. maxDepth?: number);
  46002. /**
  46003. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46004. * @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);
  46005. * @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);
  46006. * @param entries meshes to be added to the octree blocks
  46007. */
  46008. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46009. /**
  46010. * Adds a mesh to the octree
  46011. * @param entry Mesh to add to the octree
  46012. */
  46013. addMesh(entry: T): void;
  46014. /**
  46015. * Remove an element from the octree
  46016. * @param entry defines the element to remove
  46017. */
  46018. removeMesh(entry: T): void;
  46019. /**
  46020. * Selects an array of meshes within the frustum
  46021. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46022. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46023. * @returns array of meshes within the frustum
  46024. */
  46025. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46026. /**
  46027. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46028. * @param sphereCenter defines the bounding sphere center
  46029. * @param sphereRadius defines the bounding sphere radius
  46030. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46031. * @returns an array of objects that intersect the sphere
  46032. */
  46033. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46034. /**
  46035. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46036. * @param ray defines the ray to test with
  46037. * @returns array of intersected objects
  46038. */
  46039. intersectsRay(ray: Ray): SmartArray<T>;
  46040. /**
  46041. * Adds a mesh into the octree block if it intersects the block
  46042. */
  46043. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46044. /**
  46045. * Adds a submesh into the octree block if it intersects the block
  46046. */
  46047. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46048. }
  46049. }
  46050. declare module BABYLON {
  46051. interface Scene {
  46052. /**
  46053. * @hidden
  46054. * Backing Filed
  46055. */
  46056. _selectionOctree: Octree<AbstractMesh>;
  46057. /**
  46058. * Gets the octree used to boost mesh selection (picking)
  46059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46060. */
  46061. selectionOctree: Octree<AbstractMesh>;
  46062. /**
  46063. * Creates or updates the octree used to boost selection (picking)
  46064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46065. * @param maxCapacity defines the maximum capacity per leaf
  46066. * @param maxDepth defines the maximum depth of the octree
  46067. * @returns an octree of AbstractMesh
  46068. */
  46069. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46070. }
  46071. interface AbstractMesh {
  46072. /**
  46073. * @hidden
  46074. * Backing Field
  46075. */
  46076. _submeshesOctree: Octree<SubMesh>;
  46077. /**
  46078. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46079. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46080. * @param maxCapacity defines the maximum size of each block (64 by default)
  46081. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46082. * @returns the new octree
  46083. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46085. */
  46086. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46087. }
  46088. /**
  46089. * Defines the octree scene component responsible to manage any octrees
  46090. * in a given scene.
  46091. */
  46092. export class OctreeSceneComponent {
  46093. /**
  46094. * The component name help to identify the component in the list of scene components.
  46095. */
  46096. readonly name: string;
  46097. /**
  46098. * The scene the component belongs to.
  46099. */
  46100. scene: Scene;
  46101. /**
  46102. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46103. */
  46104. readonly checksIsEnabled: boolean;
  46105. /**
  46106. * Creates a new instance of the component for the given scene
  46107. * @param scene Defines the scene to register the component in
  46108. */
  46109. constructor(scene: Scene);
  46110. /**
  46111. * Registers the component in a given scene
  46112. */
  46113. register(): void;
  46114. /**
  46115. * Return the list of active meshes
  46116. * @returns the list of active meshes
  46117. */
  46118. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46119. /**
  46120. * Return the list of active sub meshes
  46121. * @param mesh The mesh to get the candidates sub meshes from
  46122. * @returns the list of active sub meshes
  46123. */
  46124. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46125. private _tempRay;
  46126. /**
  46127. * Return the list of sub meshes intersecting with a given local ray
  46128. * @param mesh defines the mesh to find the submesh for
  46129. * @param localRay defines the ray in local space
  46130. * @returns the list of intersecting sub meshes
  46131. */
  46132. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46133. /**
  46134. * Return the list of sub meshes colliding with a collider
  46135. * @param mesh defines the mesh to find the submesh for
  46136. * @param collider defines the collider to evaluate the collision against
  46137. * @returns the list of colliding sub meshes
  46138. */
  46139. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46140. /**
  46141. * Rebuilds the elements related to this component in case of
  46142. * context lost for instance.
  46143. */
  46144. rebuild(): void;
  46145. /**
  46146. * Disposes the component and the associated ressources.
  46147. */
  46148. dispose(): void;
  46149. }
  46150. }
  46151. declare module BABYLON {
  46152. /**
  46153. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46154. */
  46155. export class Gizmo implements IDisposable {
  46156. /** The utility layer the gizmo will be added to */
  46157. gizmoLayer: UtilityLayerRenderer;
  46158. /**
  46159. * The root mesh of the gizmo
  46160. */
  46161. _rootMesh: Mesh;
  46162. private _attachedMesh;
  46163. /**
  46164. * Ratio for the scale of the gizmo (Default: 1)
  46165. */
  46166. scaleRatio: number;
  46167. /**
  46168. * If a custom mesh has been set (Default: false)
  46169. */
  46170. protected _customMeshSet: boolean;
  46171. /**
  46172. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46173. * * When set, interactions will be enabled
  46174. */
  46175. get attachedMesh(): Nullable<AbstractMesh>;
  46176. set attachedMesh(value: Nullable<AbstractMesh>);
  46177. /**
  46178. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46179. * @param mesh The mesh to replace the default mesh of the gizmo
  46180. */
  46181. setCustomMesh(mesh: Mesh): void;
  46182. /**
  46183. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46184. */
  46185. updateGizmoRotationToMatchAttachedMesh: boolean;
  46186. /**
  46187. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46188. */
  46189. updateGizmoPositionToMatchAttachedMesh: boolean;
  46190. /**
  46191. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46192. */
  46193. updateScale: boolean;
  46194. protected _interactionsEnabled: boolean;
  46195. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46196. private _beforeRenderObserver;
  46197. private _tempVector;
  46198. /**
  46199. * Creates a gizmo
  46200. * @param gizmoLayer The utility layer the gizmo will be added to
  46201. */
  46202. constructor(
  46203. /** The utility layer the gizmo will be added to */
  46204. gizmoLayer?: UtilityLayerRenderer);
  46205. /**
  46206. * Updates the gizmo to match the attached mesh's position/rotation
  46207. */
  46208. protected _update(): void;
  46209. /**
  46210. * Disposes of the gizmo
  46211. */
  46212. dispose(): void;
  46213. }
  46214. }
  46215. declare module BABYLON {
  46216. /**
  46217. * Single plane drag gizmo
  46218. */
  46219. export class PlaneDragGizmo extends Gizmo {
  46220. /**
  46221. * Drag behavior responsible for the gizmos dragging interactions
  46222. */
  46223. dragBehavior: PointerDragBehavior;
  46224. private _pointerObserver;
  46225. /**
  46226. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46227. */
  46228. snapDistance: number;
  46229. /**
  46230. * Event that fires each time the gizmo snaps to a new location.
  46231. * * snapDistance is the the change in distance
  46232. */
  46233. onSnapObservable: Observable<{
  46234. snapDistance: number;
  46235. }>;
  46236. private _plane;
  46237. private _coloredMaterial;
  46238. private _hoverMaterial;
  46239. private _isEnabled;
  46240. private _parent;
  46241. /** @hidden */
  46242. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46243. /** @hidden */
  46244. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46245. /**
  46246. * Creates a PlaneDragGizmo
  46247. * @param gizmoLayer The utility layer the gizmo will be added to
  46248. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46249. * @param color The color of the gizmo
  46250. */
  46251. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46252. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46253. /**
  46254. * If the gizmo is enabled
  46255. */
  46256. set isEnabled(value: boolean);
  46257. get isEnabled(): boolean;
  46258. /**
  46259. * Disposes of the gizmo
  46260. */
  46261. dispose(): void;
  46262. }
  46263. }
  46264. declare module BABYLON {
  46265. /**
  46266. * Gizmo that enables dragging a mesh along 3 axis
  46267. */
  46268. export class PositionGizmo extends Gizmo {
  46269. /**
  46270. * Internal gizmo used for interactions on the x axis
  46271. */
  46272. xGizmo: AxisDragGizmo;
  46273. /**
  46274. * Internal gizmo used for interactions on the y axis
  46275. */
  46276. yGizmo: AxisDragGizmo;
  46277. /**
  46278. * Internal gizmo used for interactions on the z axis
  46279. */
  46280. zGizmo: AxisDragGizmo;
  46281. /**
  46282. * Internal gizmo used for interactions on the yz plane
  46283. */
  46284. xPlaneGizmo: PlaneDragGizmo;
  46285. /**
  46286. * Internal gizmo used for interactions on the xz plane
  46287. */
  46288. yPlaneGizmo: PlaneDragGizmo;
  46289. /**
  46290. * Internal gizmo used for interactions on the xy plane
  46291. */
  46292. zPlaneGizmo: PlaneDragGizmo;
  46293. /**
  46294. * private variables
  46295. */
  46296. private _meshAttached;
  46297. private _updateGizmoRotationToMatchAttachedMesh;
  46298. private _snapDistance;
  46299. private _scaleRatio;
  46300. /** Fires an event when any of it's sub gizmos are dragged */
  46301. onDragStartObservable: Observable<unknown>;
  46302. /** Fires an event when any of it's sub gizmos are released from dragging */
  46303. onDragEndObservable: Observable<unknown>;
  46304. /**
  46305. * If set to true, planar drag is enabled
  46306. */
  46307. private _planarGizmoEnabled;
  46308. get attachedMesh(): Nullable<AbstractMesh>;
  46309. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46310. /**
  46311. * Creates a PositionGizmo
  46312. * @param gizmoLayer The utility layer the gizmo will be added to
  46313. */
  46314. constructor(gizmoLayer?: UtilityLayerRenderer);
  46315. /**
  46316. * If the planar drag gizmo is enabled
  46317. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46318. */
  46319. set planarGizmoEnabled(value: boolean);
  46320. get planarGizmoEnabled(): boolean;
  46321. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46322. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46323. /**
  46324. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46325. */
  46326. set snapDistance(value: number);
  46327. get snapDistance(): number;
  46328. /**
  46329. * Ratio for the scale of the gizmo (Default: 1)
  46330. */
  46331. set scaleRatio(value: number);
  46332. get scaleRatio(): number;
  46333. /**
  46334. * Disposes of the gizmo
  46335. */
  46336. dispose(): void;
  46337. /**
  46338. * CustomMeshes are not supported by this gizmo
  46339. * @param mesh The mesh to replace the default mesh of the gizmo
  46340. */
  46341. setCustomMesh(mesh: Mesh): void;
  46342. }
  46343. }
  46344. declare module BABYLON {
  46345. /**
  46346. * Single axis drag gizmo
  46347. */
  46348. export class AxisDragGizmo extends Gizmo {
  46349. /**
  46350. * Drag behavior responsible for the gizmos dragging interactions
  46351. */
  46352. dragBehavior: PointerDragBehavior;
  46353. private _pointerObserver;
  46354. /**
  46355. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46356. */
  46357. snapDistance: number;
  46358. /**
  46359. * Event that fires each time the gizmo snaps to a new location.
  46360. * * snapDistance is the the change in distance
  46361. */
  46362. onSnapObservable: Observable<{
  46363. snapDistance: number;
  46364. }>;
  46365. private _isEnabled;
  46366. private _parent;
  46367. private _arrow;
  46368. private _coloredMaterial;
  46369. private _hoverMaterial;
  46370. /** @hidden */
  46371. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46372. /** @hidden */
  46373. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46374. /**
  46375. * Creates an AxisDragGizmo
  46376. * @param gizmoLayer The utility layer the gizmo will be added to
  46377. * @param dragAxis The axis which the gizmo will be able to drag on
  46378. * @param color The color of the gizmo
  46379. */
  46380. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46381. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46382. /**
  46383. * If the gizmo is enabled
  46384. */
  46385. set isEnabled(value: boolean);
  46386. get isEnabled(): boolean;
  46387. /**
  46388. * Disposes of the gizmo
  46389. */
  46390. dispose(): void;
  46391. }
  46392. }
  46393. declare module BABYLON.Debug {
  46394. /**
  46395. * The Axes viewer will show 3 axes in a specific point in space
  46396. */
  46397. export class AxesViewer {
  46398. private _xAxis;
  46399. private _yAxis;
  46400. private _zAxis;
  46401. private _scaleLinesFactor;
  46402. private _instanced;
  46403. /**
  46404. * Gets the hosting scene
  46405. */
  46406. scene: Scene;
  46407. /**
  46408. * Gets or sets a number used to scale line length
  46409. */
  46410. scaleLines: number;
  46411. /** Gets the node hierarchy used to render x-axis */
  46412. get xAxis(): TransformNode;
  46413. /** Gets the node hierarchy used to render y-axis */
  46414. get yAxis(): TransformNode;
  46415. /** Gets the node hierarchy used to render z-axis */
  46416. get zAxis(): TransformNode;
  46417. /**
  46418. * Creates a new AxesViewer
  46419. * @param scene defines the hosting scene
  46420. * @param scaleLines defines a number used to scale line length (1 by default)
  46421. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46422. * @param xAxis defines the node hierarchy used to render the x-axis
  46423. * @param yAxis defines the node hierarchy used to render the y-axis
  46424. * @param zAxis defines the node hierarchy used to render the z-axis
  46425. */
  46426. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46427. /**
  46428. * Force the viewer to update
  46429. * @param position defines the position of the viewer
  46430. * @param xaxis defines the x axis of the viewer
  46431. * @param yaxis defines the y axis of the viewer
  46432. * @param zaxis defines the z axis of the viewer
  46433. */
  46434. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46435. /**
  46436. * Creates an instance of this axes viewer.
  46437. * @returns a new axes viewer with instanced meshes
  46438. */
  46439. createInstance(): AxesViewer;
  46440. /** Releases resources */
  46441. dispose(): void;
  46442. private static _SetRenderingGroupId;
  46443. }
  46444. }
  46445. declare module BABYLON.Debug {
  46446. /**
  46447. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46448. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46449. */
  46450. export class BoneAxesViewer extends AxesViewer {
  46451. /**
  46452. * Gets or sets the target mesh where to display the axes viewer
  46453. */
  46454. mesh: Nullable<Mesh>;
  46455. /**
  46456. * Gets or sets the target bone where to display the axes viewer
  46457. */
  46458. bone: Nullable<Bone>;
  46459. /** Gets current position */
  46460. pos: Vector3;
  46461. /** Gets direction of X axis */
  46462. xaxis: Vector3;
  46463. /** Gets direction of Y axis */
  46464. yaxis: Vector3;
  46465. /** Gets direction of Z axis */
  46466. zaxis: Vector3;
  46467. /**
  46468. * Creates a new BoneAxesViewer
  46469. * @param scene defines the hosting scene
  46470. * @param bone defines the target bone
  46471. * @param mesh defines the target mesh
  46472. * @param scaleLines defines a scaling factor for line length (1 by default)
  46473. */
  46474. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46475. /**
  46476. * Force the viewer to update
  46477. */
  46478. update(): void;
  46479. /** Releases resources */
  46480. dispose(): void;
  46481. }
  46482. }
  46483. declare module BABYLON {
  46484. /**
  46485. * Interface used to define scene explorer extensibility option
  46486. */
  46487. export interface IExplorerExtensibilityOption {
  46488. /**
  46489. * Define the option label
  46490. */
  46491. label: string;
  46492. /**
  46493. * Defines the action to execute on click
  46494. */
  46495. action: (entity: any) => void;
  46496. }
  46497. /**
  46498. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46499. */
  46500. export interface IExplorerExtensibilityGroup {
  46501. /**
  46502. * Defines a predicate to test if a given type mut be extended
  46503. */
  46504. predicate: (entity: any) => boolean;
  46505. /**
  46506. * Gets the list of options added to a type
  46507. */
  46508. entries: IExplorerExtensibilityOption[];
  46509. }
  46510. /**
  46511. * Interface used to define the options to use to create the Inspector
  46512. */
  46513. export interface IInspectorOptions {
  46514. /**
  46515. * Display in overlay mode (default: false)
  46516. */
  46517. overlay?: boolean;
  46518. /**
  46519. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46520. */
  46521. globalRoot?: HTMLElement;
  46522. /**
  46523. * Display the Scene explorer
  46524. */
  46525. showExplorer?: boolean;
  46526. /**
  46527. * Display the property inspector
  46528. */
  46529. showInspector?: boolean;
  46530. /**
  46531. * Display in embed mode (both panes on the right)
  46532. */
  46533. embedMode?: boolean;
  46534. /**
  46535. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46536. */
  46537. handleResize?: boolean;
  46538. /**
  46539. * Allow the panes to popup (default: true)
  46540. */
  46541. enablePopup?: boolean;
  46542. /**
  46543. * Allow the panes to be closed by users (default: true)
  46544. */
  46545. enableClose?: boolean;
  46546. /**
  46547. * Optional list of extensibility entries
  46548. */
  46549. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46550. /**
  46551. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46552. */
  46553. inspectorURL?: string;
  46554. /**
  46555. * Optional initial tab (default to DebugLayerTab.Properties)
  46556. */
  46557. initialTab?: DebugLayerTab;
  46558. }
  46559. interface Scene {
  46560. /**
  46561. * @hidden
  46562. * Backing field
  46563. */
  46564. _debugLayer: DebugLayer;
  46565. /**
  46566. * Gets the debug layer (aka Inspector) associated with the scene
  46567. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46568. */
  46569. debugLayer: DebugLayer;
  46570. }
  46571. /**
  46572. * Enum of inspector action tab
  46573. */
  46574. export enum DebugLayerTab {
  46575. /**
  46576. * Properties tag (default)
  46577. */
  46578. Properties = 0,
  46579. /**
  46580. * Debug tab
  46581. */
  46582. Debug = 1,
  46583. /**
  46584. * Statistics tab
  46585. */
  46586. Statistics = 2,
  46587. /**
  46588. * Tools tab
  46589. */
  46590. Tools = 3,
  46591. /**
  46592. * Settings tab
  46593. */
  46594. Settings = 4
  46595. }
  46596. /**
  46597. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46598. * what is happening in your scene
  46599. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46600. */
  46601. export class DebugLayer {
  46602. /**
  46603. * Define the url to get the inspector script from.
  46604. * By default it uses the babylonjs CDN.
  46605. * @ignoreNaming
  46606. */
  46607. static InspectorURL: string;
  46608. private _scene;
  46609. private BJSINSPECTOR;
  46610. private _onPropertyChangedObservable?;
  46611. /**
  46612. * Observable triggered when a property is changed through the inspector.
  46613. */
  46614. get onPropertyChangedObservable(): any;
  46615. /**
  46616. * Instantiates a new debug layer.
  46617. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46618. * what is happening in your scene
  46619. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46620. * @param scene Defines the scene to inspect
  46621. */
  46622. constructor(scene: Scene);
  46623. /** Creates the inspector window. */
  46624. private _createInspector;
  46625. /**
  46626. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46627. * @param entity defines the entity to select
  46628. * @param lineContainerTitle defines the specific block to highlight
  46629. */
  46630. select(entity: any, lineContainerTitle?: string): void;
  46631. /** Get the inspector from bundle or global */
  46632. private _getGlobalInspector;
  46633. /**
  46634. * Get if the inspector is visible or not.
  46635. * @returns true if visible otherwise, false
  46636. */
  46637. isVisible(): boolean;
  46638. /**
  46639. * Hide the inspector and close its window.
  46640. */
  46641. hide(): void;
  46642. /**
  46643. * Launch the debugLayer.
  46644. * @param config Define the configuration of the inspector
  46645. * @return a promise fulfilled when the debug layer is visible
  46646. */
  46647. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46648. }
  46649. }
  46650. declare module BABYLON {
  46651. /**
  46652. * Class containing static functions to help procedurally build meshes
  46653. */
  46654. export class BoxBuilder {
  46655. /**
  46656. * Creates a box mesh
  46657. * * The parameter `size` sets the size (float) of each box side (default 1)
  46658. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46659. * * 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)
  46660. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46662. * * 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
  46663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46664. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46665. * @param name defines the name of the mesh
  46666. * @param options defines the options used to create the mesh
  46667. * @param scene defines the hosting scene
  46668. * @returns the box mesh
  46669. */
  46670. static CreateBox(name: string, options: {
  46671. size?: number;
  46672. width?: number;
  46673. height?: number;
  46674. depth?: number;
  46675. faceUV?: Vector4[];
  46676. faceColors?: Color4[];
  46677. sideOrientation?: number;
  46678. frontUVs?: Vector4;
  46679. backUVs?: Vector4;
  46680. wrap?: boolean;
  46681. topBaseAt?: number;
  46682. bottomBaseAt?: number;
  46683. updatable?: boolean;
  46684. }, scene?: Nullable<Scene>): Mesh;
  46685. }
  46686. }
  46687. declare module BABYLON.Debug {
  46688. /**
  46689. * Used to show the physics impostor around the specific mesh
  46690. */
  46691. export class PhysicsViewer {
  46692. /** @hidden */
  46693. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46694. /** @hidden */
  46695. protected _meshes: Array<Nullable<AbstractMesh>>;
  46696. /** @hidden */
  46697. protected _scene: Nullable<Scene>;
  46698. /** @hidden */
  46699. protected _numMeshes: number;
  46700. /** @hidden */
  46701. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46702. private _renderFunction;
  46703. private _utilityLayer;
  46704. private _debugBoxMesh;
  46705. private _debugSphereMesh;
  46706. private _debugCylinderMesh;
  46707. private _debugMaterial;
  46708. private _debugMeshMeshes;
  46709. /**
  46710. * Creates a new PhysicsViewer
  46711. * @param scene defines the hosting scene
  46712. */
  46713. constructor(scene: Scene);
  46714. /** @hidden */
  46715. protected _updateDebugMeshes(): void;
  46716. /**
  46717. * Renders a specified physic impostor
  46718. * @param impostor defines the impostor to render
  46719. * @param targetMesh defines the mesh represented by the impostor
  46720. * @returns the new debug mesh used to render the impostor
  46721. */
  46722. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46723. /**
  46724. * Hides a specified physic impostor
  46725. * @param impostor defines the impostor to hide
  46726. */
  46727. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46728. private _getDebugMaterial;
  46729. private _getDebugBoxMesh;
  46730. private _getDebugSphereMesh;
  46731. private _getDebugCylinderMesh;
  46732. private _getDebugMeshMesh;
  46733. private _getDebugMesh;
  46734. /** Releases all resources */
  46735. dispose(): void;
  46736. }
  46737. }
  46738. declare module BABYLON {
  46739. /**
  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. */
  46744. export class RayHelper {
  46745. /**
  46746. * Defines the ray we are currently tryin to visualize.
  46747. */
  46748. ray: Nullable<Ray>;
  46749. private _renderPoints;
  46750. private _renderLine;
  46751. private _renderFunction;
  46752. private _scene;
  46753. private _updateToMeshFunction;
  46754. private _attachedToMesh;
  46755. private _meshSpaceDirection;
  46756. private _meshSpaceOrigin;
  46757. /**
  46758. * Helper function to create a colored helper in a scene in one line.
  46759. * @param ray Defines the ray we are currently tryin to visualize
  46760. * @param scene Defines the scene the ray is used in
  46761. * @param color Defines the color we want to see the ray in
  46762. * @returns The newly created ray helper.
  46763. */
  46764. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46765. /**
  46766. * Instantiate a new ray helper.
  46767. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46768. * in order to better appreciate the issue one might have.
  46769. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46770. * @param ray Defines the ray we are currently tryin to visualize
  46771. */
  46772. constructor(ray: Ray);
  46773. /**
  46774. * Shows the ray we are willing to debug.
  46775. * @param scene Defines the scene the ray needs to be rendered in
  46776. * @param color Defines the color the ray needs to be rendered in
  46777. */
  46778. show(scene: Scene, color?: Color3): void;
  46779. /**
  46780. * Hides the ray we are debugging.
  46781. */
  46782. hide(): void;
  46783. private _render;
  46784. /**
  46785. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46786. * @param mesh Defines the mesh we want the helper attached to
  46787. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46788. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46789. * @param length Defines the length of the ray
  46790. */
  46791. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46792. /**
  46793. * Detach the ray helper from the mesh it has previously been attached to.
  46794. */
  46795. detachFromMesh(): void;
  46796. private _updateToMesh;
  46797. /**
  46798. * Dispose the helper and release its associated resources.
  46799. */
  46800. dispose(): void;
  46801. }
  46802. }
  46803. declare module BABYLON.Debug {
  46804. /**
  46805. * Class used to render a debug view of a given skeleton
  46806. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46807. */
  46808. export class SkeletonViewer {
  46809. /** defines the skeleton to render */
  46810. skeleton: Skeleton;
  46811. /** defines the mesh attached to the skeleton */
  46812. mesh: AbstractMesh;
  46813. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46814. autoUpdateBonesMatrices: boolean;
  46815. /** defines the rendering group id to use with the viewer */
  46816. renderingGroupId: number;
  46817. /** Gets or sets the color used to render the skeleton */
  46818. color: Color3;
  46819. private _scene;
  46820. private _debugLines;
  46821. private _debugMesh;
  46822. private _isEnabled;
  46823. private _renderFunction;
  46824. private _utilityLayer;
  46825. /**
  46826. * Returns the mesh used to render the bones
  46827. */
  46828. get debugMesh(): Nullable<LinesMesh>;
  46829. /**
  46830. * Creates a new SkeletonViewer
  46831. * @param skeleton defines the skeleton to render
  46832. * @param mesh defines the mesh attached to the skeleton
  46833. * @param scene defines the hosting scene
  46834. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46835. * @param renderingGroupId defines the rendering group id to use with the viewer
  46836. */
  46837. constructor(
  46838. /** defines the skeleton to render */
  46839. skeleton: Skeleton,
  46840. /** defines the mesh attached to the skeleton */
  46841. mesh: AbstractMesh, scene: Scene,
  46842. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46843. autoUpdateBonesMatrices?: boolean,
  46844. /** defines the rendering group id to use with the viewer */
  46845. renderingGroupId?: number);
  46846. /** Gets or sets a boolean indicating if the viewer is enabled */
  46847. set isEnabled(value: boolean);
  46848. get isEnabled(): boolean;
  46849. private _getBonePosition;
  46850. private _getLinesForBonesWithLength;
  46851. private _getLinesForBonesNoLength;
  46852. /** Update the viewer to sync with current skeleton state */
  46853. update(): void;
  46854. /** Release associated resources */
  46855. dispose(): void;
  46856. }
  46857. }
  46858. declare module BABYLON {
  46859. /**
  46860. * Options to create the null engine
  46861. */
  46862. export class NullEngineOptions {
  46863. /**
  46864. * Render width (Default: 512)
  46865. */
  46866. renderWidth: number;
  46867. /**
  46868. * Render height (Default: 256)
  46869. */
  46870. renderHeight: number;
  46871. /**
  46872. * Texture size (Default: 512)
  46873. */
  46874. textureSize: number;
  46875. /**
  46876. * If delta time between frames should be constant
  46877. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46878. */
  46879. deterministicLockstep: boolean;
  46880. /**
  46881. * Maximum about of steps between frames (Default: 4)
  46882. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46883. */
  46884. lockstepMaxSteps: number;
  46885. }
  46886. /**
  46887. * The null engine class provides support for headless version of babylon.js.
  46888. * This can be used in server side scenario or for testing purposes
  46889. */
  46890. export class NullEngine extends Engine {
  46891. private _options;
  46892. /**
  46893. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46894. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46895. * @returns true if engine is in deterministic lock step mode
  46896. */
  46897. isDeterministicLockStep(): boolean;
  46898. /**
  46899. * Gets the max steps when engine is running in deterministic lock step
  46900. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46901. * @returns the max steps
  46902. */
  46903. getLockstepMaxSteps(): number;
  46904. /**
  46905. * Gets the current hardware scaling level.
  46906. * By default the hardware scaling level is computed from the window device ratio.
  46907. * 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.
  46908. * @returns a number indicating the current hardware scaling level
  46909. */
  46910. getHardwareScalingLevel(): number;
  46911. constructor(options?: NullEngineOptions);
  46912. /**
  46913. * Creates a vertex buffer
  46914. * @param vertices the data for the vertex buffer
  46915. * @returns the new WebGL static buffer
  46916. */
  46917. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46918. /**
  46919. * Creates a new index buffer
  46920. * @param indices defines the content of the index buffer
  46921. * @param updatable defines if the index buffer must be updatable
  46922. * @returns a new webGL buffer
  46923. */
  46924. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46925. /**
  46926. * Clear the current render buffer or the current render target (if any is set up)
  46927. * @param color defines the color to use
  46928. * @param backBuffer defines if the back buffer must be cleared
  46929. * @param depth defines if the depth buffer must be cleared
  46930. * @param stencil defines if the stencil buffer must be cleared
  46931. */
  46932. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46933. /**
  46934. * Gets the current render width
  46935. * @param useScreen defines if screen size must be used (or the current render target if any)
  46936. * @returns a number defining the current render width
  46937. */
  46938. getRenderWidth(useScreen?: boolean): number;
  46939. /**
  46940. * Gets the current render height
  46941. * @param useScreen defines if screen size must be used (or the current render target if any)
  46942. * @returns a number defining the current render height
  46943. */
  46944. getRenderHeight(useScreen?: boolean): number;
  46945. /**
  46946. * Set the WebGL's viewport
  46947. * @param viewport defines the viewport element to be used
  46948. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46949. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46950. */
  46951. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46952. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46953. /**
  46954. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46955. * @param pipelineContext defines the pipeline context to use
  46956. * @param uniformsNames defines the list of uniform names
  46957. * @returns an array of webGL uniform locations
  46958. */
  46959. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46960. /**
  46961. * Gets the lsit of active attributes for a given webGL program
  46962. * @param pipelineContext defines the pipeline context to use
  46963. * @param attributesNames defines the list of attribute names to get
  46964. * @returns an array of indices indicating the offset of each attribute
  46965. */
  46966. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46967. /**
  46968. * Binds an effect to the webGL context
  46969. * @param effect defines the effect to bind
  46970. */
  46971. bindSamplers(effect: Effect): void;
  46972. /**
  46973. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46974. * @param effect defines the effect to activate
  46975. */
  46976. enableEffect(effect: Effect): void;
  46977. /**
  46978. * Set various states to the webGL context
  46979. * @param culling defines backface culling state
  46980. * @param zOffset defines the value to apply to zOffset (0 by default)
  46981. * @param force defines if states must be applied even if cache is up to date
  46982. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46983. */
  46984. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46985. /**
  46986. * Set the value of an uniform to an array of int32
  46987. * @param uniform defines the webGL uniform location where to store the value
  46988. * @param array defines the array of int32 to store
  46989. */
  46990. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46991. /**
  46992. * Set the value of an uniform to an array of int32 (stored as vec2)
  46993. * @param uniform defines the webGL uniform location where to store the value
  46994. * @param array defines the array of int32 to store
  46995. */
  46996. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46997. /**
  46998. * Set the value of an uniform to an array of int32 (stored as vec3)
  46999. * @param uniform defines the webGL uniform location where to store the value
  47000. * @param array defines the array of int32 to store
  47001. */
  47002. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47003. /**
  47004. * Set the value of an uniform to an array of int32 (stored as vec4)
  47005. * @param uniform defines the webGL uniform location where to store the value
  47006. * @param array defines the array of int32 to store
  47007. */
  47008. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47009. /**
  47010. * Set the value of an uniform to an array of float32
  47011. * @param uniform defines the webGL uniform location where to store the value
  47012. * @param array defines the array of float32 to store
  47013. */
  47014. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47015. /**
  47016. * Set the value of an uniform to an array of float32 (stored as vec2)
  47017. * @param uniform defines the webGL uniform location where to store the value
  47018. * @param array defines the array of float32 to store
  47019. */
  47020. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47021. /**
  47022. * Set the value of an uniform to an array of float32 (stored as vec3)
  47023. * @param uniform defines the webGL uniform location where to store the value
  47024. * @param array defines the array of float32 to store
  47025. */
  47026. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47027. /**
  47028. * Set the value of an uniform to an array of float32 (stored as vec4)
  47029. * @param uniform defines the webGL uniform location where to store the value
  47030. * @param array defines the array of float32 to store
  47031. */
  47032. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47033. /**
  47034. * Set the value of an uniform to an array of number
  47035. * @param uniform defines the webGL uniform location where to store the value
  47036. * @param array defines the array of number to store
  47037. */
  47038. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47039. /**
  47040. * Set the value of an uniform to an array of number (stored as vec2)
  47041. * @param uniform defines the webGL uniform location where to store the value
  47042. * @param array defines the array of number to store
  47043. */
  47044. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47045. /**
  47046. * Set the value of an uniform to an array of number (stored as vec3)
  47047. * @param uniform defines the webGL uniform location where to store the value
  47048. * @param array defines the array of number to store
  47049. */
  47050. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47051. /**
  47052. * Set the value of an uniform to an array of number (stored as vec4)
  47053. * @param uniform defines the webGL uniform location where to store the value
  47054. * @param array defines the array of number to store
  47055. */
  47056. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47057. /**
  47058. * Set the value of an uniform to an array of float32 (stored as matrices)
  47059. * @param uniform defines the webGL uniform location where to store the value
  47060. * @param matrices defines the array of float32 to store
  47061. */
  47062. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47063. /**
  47064. * Set the value of an uniform to a matrix (3x3)
  47065. * @param uniform defines the webGL uniform location where to store the value
  47066. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47067. */
  47068. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47069. /**
  47070. * Set the value of an uniform to a matrix (2x2)
  47071. * @param uniform defines the webGL uniform location where to store the value
  47072. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47073. */
  47074. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47075. /**
  47076. * Set the value of an uniform to a number (float)
  47077. * @param uniform defines the webGL uniform location where to store the value
  47078. * @param value defines the float number to store
  47079. */
  47080. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47081. /**
  47082. * Set the value of an uniform to a vec2
  47083. * @param uniform defines the webGL uniform location where to store the value
  47084. * @param x defines the 1st component of the value
  47085. * @param y defines the 2nd component of the value
  47086. */
  47087. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47088. /**
  47089. * Set the value of an uniform to a vec3
  47090. * @param uniform defines the webGL uniform location where to store the value
  47091. * @param x defines the 1st component of the value
  47092. * @param y defines the 2nd component of the value
  47093. * @param z defines the 3rd component of the value
  47094. */
  47095. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47096. /**
  47097. * Set the value of an uniform to a boolean
  47098. * @param uniform defines the webGL uniform location where to store the value
  47099. * @param bool defines the boolean to store
  47100. */
  47101. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47102. /**
  47103. * Set the value of an uniform to a vec4
  47104. * @param uniform defines the webGL uniform location where to store the value
  47105. * @param x defines the 1st component of the value
  47106. * @param y defines the 2nd component of the value
  47107. * @param z defines the 3rd component of the value
  47108. * @param w defines the 4th component of the value
  47109. */
  47110. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47111. /**
  47112. * Sets the current alpha mode
  47113. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47114. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47115. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47116. */
  47117. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47118. /**
  47119. * Bind webGl buffers directly to the webGL context
  47120. * @param vertexBuffers defines the vertex buffer to bind
  47121. * @param indexBuffer defines the index buffer to bind
  47122. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47123. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47124. * @param effect defines the effect associated with the vertex buffer
  47125. */
  47126. bindBuffers(vertexBuffers: {
  47127. [key: string]: VertexBuffer;
  47128. }, indexBuffer: DataBuffer, effect: Effect): void;
  47129. /**
  47130. * Force the entire cache to be cleared
  47131. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47132. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47133. */
  47134. wipeCaches(bruteForce?: boolean): void;
  47135. /**
  47136. * Send a draw order
  47137. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47138. * @param indexStart defines the starting index
  47139. * @param indexCount defines the number of index to draw
  47140. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47141. */
  47142. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47143. /**
  47144. * Draw a list of indexed primitives
  47145. * @param fillMode defines the primitive to use
  47146. * @param indexStart defines the starting index
  47147. * @param indexCount defines the number of index to draw
  47148. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47149. */
  47150. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47151. /**
  47152. * Draw a list of unindexed primitives
  47153. * @param fillMode defines the primitive to use
  47154. * @param verticesStart defines the index of first vertex to draw
  47155. * @param verticesCount defines the count of vertices to draw
  47156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47157. */
  47158. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47159. /** @hidden */
  47160. _createTexture(): WebGLTexture;
  47161. /** @hidden */
  47162. _releaseTexture(texture: InternalTexture): void;
  47163. /**
  47164. * Usually called from Texture.ts.
  47165. * Passed information to create a WebGLTexture
  47166. * @param urlArg defines a value which contains one of the following:
  47167. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47168. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47169. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47170. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47171. * @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)
  47172. * @param scene needed for loading to the correct scene
  47173. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47174. * @param onLoad optional callback to be called upon successful completion
  47175. * @param onError optional callback to be called upon failure
  47176. * @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
  47177. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47178. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47179. * @param forcedExtension defines the extension to use to pick the right loader
  47180. * @param mimeType defines an optional mime type
  47181. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47182. */
  47183. 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;
  47184. /**
  47185. * Creates a new render target texture
  47186. * @param size defines the size of the texture
  47187. * @param options defines the options used to create the texture
  47188. * @returns a new render target texture stored in an InternalTexture
  47189. */
  47190. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47191. /**
  47192. * Update the sampling mode of a given texture
  47193. * @param samplingMode defines the required sampling mode
  47194. * @param texture defines the texture to update
  47195. */
  47196. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47197. /**
  47198. * Binds the frame buffer to the specified texture.
  47199. * @param texture The texture to render to or null for the default canvas
  47200. * @param faceIndex The face of the texture to render to in case of cube texture
  47201. * @param requiredWidth The width of the target to render to
  47202. * @param requiredHeight The height of the target to render to
  47203. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47204. * @param lodLevel defines le lod level to bind to the frame buffer
  47205. */
  47206. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47207. /**
  47208. * Unbind the current render target texture from the webGL context
  47209. * @param texture defines the render target texture to unbind
  47210. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47211. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47212. */
  47213. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47214. /**
  47215. * Creates a dynamic vertex buffer
  47216. * @param vertices the data for the dynamic vertex buffer
  47217. * @returns the new WebGL dynamic buffer
  47218. */
  47219. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47220. /**
  47221. * Update the content of a dynamic texture
  47222. * @param texture defines the texture to update
  47223. * @param canvas defines the canvas containing the source
  47224. * @param invertY defines if data must be stored with Y axis inverted
  47225. * @param premulAlpha defines if alpha is stored as premultiplied
  47226. * @param format defines the format of the data
  47227. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47228. */
  47229. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47230. /**
  47231. * Gets a boolean indicating if all created effects are ready
  47232. * @returns true if all effects are ready
  47233. */
  47234. areAllEffectsReady(): boolean;
  47235. /**
  47236. * @hidden
  47237. * Get the current error code of the webGL context
  47238. * @returns the error code
  47239. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47240. */
  47241. getError(): number;
  47242. /** @hidden */
  47243. _getUnpackAlignement(): number;
  47244. /** @hidden */
  47245. _unpackFlipY(value: boolean): void;
  47246. /**
  47247. * Update a dynamic index buffer
  47248. * @param indexBuffer defines the target index buffer
  47249. * @param indices defines the data to update
  47250. * @param offset defines the offset in the target index buffer where update should start
  47251. */
  47252. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47253. /**
  47254. * Updates a dynamic vertex buffer.
  47255. * @param vertexBuffer the vertex buffer to update
  47256. * @param vertices the data used to update the vertex buffer
  47257. * @param byteOffset the byte offset of the data (optional)
  47258. * @param byteLength the byte length of the data (optional)
  47259. */
  47260. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47261. /** @hidden */
  47262. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47263. /** @hidden */
  47264. _bindTexture(channel: number, texture: InternalTexture): void;
  47265. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47266. /**
  47267. * 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
  47268. */
  47269. releaseEffects(): void;
  47270. displayLoadingUI(): void;
  47271. hideLoadingUI(): void;
  47272. /** @hidden */
  47273. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47274. /** @hidden */
  47275. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47276. /** @hidden */
  47277. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47278. /** @hidden */
  47279. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47280. }
  47281. }
  47282. declare module BABYLON {
  47283. /**
  47284. * @hidden
  47285. **/
  47286. export class _TimeToken {
  47287. _startTimeQuery: Nullable<WebGLQuery>;
  47288. _endTimeQuery: Nullable<WebGLQuery>;
  47289. _timeElapsedQuery: Nullable<WebGLQuery>;
  47290. _timeElapsedQueryEnded: boolean;
  47291. }
  47292. }
  47293. declare module BABYLON {
  47294. /** @hidden */
  47295. export class _OcclusionDataStorage {
  47296. /** @hidden */
  47297. occlusionInternalRetryCounter: number;
  47298. /** @hidden */
  47299. isOcclusionQueryInProgress: boolean;
  47300. /** @hidden */
  47301. isOccluded: boolean;
  47302. /** @hidden */
  47303. occlusionRetryCount: number;
  47304. /** @hidden */
  47305. occlusionType: number;
  47306. /** @hidden */
  47307. occlusionQueryAlgorithmType: number;
  47308. }
  47309. interface Engine {
  47310. /**
  47311. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47312. * @return the new query
  47313. */
  47314. createQuery(): WebGLQuery;
  47315. /**
  47316. * Delete and release a webGL query
  47317. * @param query defines the query to delete
  47318. * @return the current engine
  47319. */
  47320. deleteQuery(query: WebGLQuery): Engine;
  47321. /**
  47322. * Check if a given query has resolved and got its value
  47323. * @param query defines the query to check
  47324. * @returns true if the query got its value
  47325. */
  47326. isQueryResultAvailable(query: WebGLQuery): boolean;
  47327. /**
  47328. * Gets the value of a given query
  47329. * @param query defines the query to check
  47330. * @returns the value of the query
  47331. */
  47332. getQueryResult(query: WebGLQuery): number;
  47333. /**
  47334. * Initiates an occlusion query
  47335. * @param algorithmType defines the algorithm to use
  47336. * @param query defines the query to use
  47337. * @returns the current engine
  47338. * @see http://doc.babylonjs.com/features/occlusionquery
  47339. */
  47340. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47341. /**
  47342. * Ends an occlusion query
  47343. * @see http://doc.babylonjs.com/features/occlusionquery
  47344. * @param algorithmType defines the algorithm to use
  47345. * @returns the current engine
  47346. */
  47347. endOcclusionQuery(algorithmType: number): Engine;
  47348. /**
  47349. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47350. * Please note that only one query can be issued at a time
  47351. * @returns a time token used to track the time span
  47352. */
  47353. startTimeQuery(): Nullable<_TimeToken>;
  47354. /**
  47355. * Ends a time query
  47356. * @param token defines the token used to measure the time span
  47357. * @returns the time spent (in ns)
  47358. */
  47359. endTimeQuery(token: _TimeToken): int;
  47360. /** @hidden */
  47361. _currentNonTimestampToken: Nullable<_TimeToken>;
  47362. /** @hidden */
  47363. _createTimeQuery(): WebGLQuery;
  47364. /** @hidden */
  47365. _deleteTimeQuery(query: WebGLQuery): void;
  47366. /** @hidden */
  47367. _getGlAlgorithmType(algorithmType: number): number;
  47368. /** @hidden */
  47369. _getTimeQueryResult(query: WebGLQuery): any;
  47370. /** @hidden */
  47371. _getTimeQueryAvailability(query: WebGLQuery): any;
  47372. }
  47373. interface AbstractMesh {
  47374. /**
  47375. * Backing filed
  47376. * @hidden
  47377. */
  47378. __occlusionDataStorage: _OcclusionDataStorage;
  47379. /**
  47380. * Access property
  47381. * @hidden
  47382. */
  47383. _occlusionDataStorage: _OcclusionDataStorage;
  47384. /**
  47385. * 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.
  47386. * The default value is -1 which means don't break the query and wait till the result
  47387. * @see http://doc.babylonjs.com/features/occlusionquery
  47388. */
  47389. occlusionRetryCount: number;
  47390. /**
  47391. * 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:
  47392. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47393. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47394. * * 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.
  47395. * @see http://doc.babylonjs.com/features/occlusionquery
  47396. */
  47397. occlusionType: number;
  47398. /**
  47399. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47400. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47401. * * 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.
  47402. * @see http://doc.babylonjs.com/features/occlusionquery
  47403. */
  47404. occlusionQueryAlgorithmType: number;
  47405. /**
  47406. * 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
  47407. * @see http://doc.babylonjs.com/features/occlusionquery
  47408. */
  47409. isOccluded: boolean;
  47410. /**
  47411. * Flag to check the progress status of the query
  47412. * @see http://doc.babylonjs.com/features/occlusionquery
  47413. */
  47414. isOcclusionQueryInProgress: boolean;
  47415. }
  47416. }
  47417. declare module BABYLON {
  47418. /** @hidden */
  47419. export var _forceTransformFeedbackToBundle: boolean;
  47420. interface Engine {
  47421. /**
  47422. * Creates a webGL transform feedback object
  47423. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47424. * @returns the webGL transform feedback object
  47425. */
  47426. createTransformFeedback(): WebGLTransformFeedback;
  47427. /**
  47428. * Delete a webGL transform feedback object
  47429. * @param value defines the webGL transform feedback object to delete
  47430. */
  47431. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47432. /**
  47433. * Bind a webGL transform feedback object to the webgl context
  47434. * @param value defines the webGL transform feedback object to bind
  47435. */
  47436. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47437. /**
  47438. * Begins a transform feedback operation
  47439. * @param usePoints defines if points or triangles must be used
  47440. */
  47441. beginTransformFeedback(usePoints: boolean): void;
  47442. /**
  47443. * Ends a transform feedback operation
  47444. */
  47445. endTransformFeedback(): void;
  47446. /**
  47447. * Specify the varyings to use with transform feedback
  47448. * @param program defines the associated webGL program
  47449. * @param value defines the list of strings representing the varying names
  47450. */
  47451. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47452. /**
  47453. * Bind a webGL buffer for a transform feedback operation
  47454. * @param value defines the webGL buffer to bind
  47455. */
  47456. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47457. }
  47458. }
  47459. declare module BABYLON {
  47460. /**
  47461. * Creation options of the multi render target texture.
  47462. */
  47463. export interface IMultiRenderTargetOptions {
  47464. /**
  47465. * Define if the texture needs to create mip maps after render.
  47466. */
  47467. generateMipMaps?: boolean;
  47468. /**
  47469. * Define the types of all the draw buffers we want to create
  47470. */
  47471. types?: number[];
  47472. /**
  47473. * Define the sampling modes of all the draw buffers we want to create
  47474. */
  47475. samplingModes?: number[];
  47476. /**
  47477. * Define if a depth buffer is required
  47478. */
  47479. generateDepthBuffer?: boolean;
  47480. /**
  47481. * Define if a stencil buffer is required
  47482. */
  47483. generateStencilBuffer?: boolean;
  47484. /**
  47485. * Define if a depth texture is required instead of a depth buffer
  47486. */
  47487. generateDepthTexture?: boolean;
  47488. /**
  47489. * Define the number of desired draw buffers
  47490. */
  47491. textureCount?: number;
  47492. /**
  47493. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47494. */
  47495. doNotChangeAspectRatio?: boolean;
  47496. /**
  47497. * Define the default type of the buffers we are creating
  47498. */
  47499. defaultType?: number;
  47500. }
  47501. /**
  47502. * A multi render target, like a render target provides the ability to render to a texture.
  47503. * Unlike the render target, it can render to several draw buffers in one draw.
  47504. * This is specially interesting in deferred rendering or for any effects requiring more than
  47505. * just one color from a single pass.
  47506. */
  47507. export class MultiRenderTarget extends RenderTargetTexture {
  47508. private _internalTextures;
  47509. private _textures;
  47510. private _multiRenderTargetOptions;
  47511. /**
  47512. * Get if draw buffers are currently supported by the used hardware and browser.
  47513. */
  47514. get isSupported(): boolean;
  47515. /**
  47516. * Get the list of textures generated by the multi render target.
  47517. */
  47518. get textures(): Texture[];
  47519. /**
  47520. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47521. */
  47522. get depthTexture(): Texture;
  47523. /**
  47524. * Set the wrapping mode on U of all the textures we are rendering to.
  47525. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47526. */
  47527. set wrapU(wrap: number);
  47528. /**
  47529. * Set the wrapping mode on V of all the textures we are rendering to.
  47530. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47531. */
  47532. set wrapV(wrap: number);
  47533. /**
  47534. * Instantiate a new multi render target texture.
  47535. * A multi render target, like a render target provides the ability to render to a texture.
  47536. * Unlike the render target, it can render to several draw buffers in one draw.
  47537. * This is specially interesting in deferred rendering or for any effects requiring more than
  47538. * just one color from a single pass.
  47539. * @param name Define the name of the texture
  47540. * @param size Define the size of the buffers to render to
  47541. * @param count Define the number of target we are rendering into
  47542. * @param scene Define the scene the texture belongs to
  47543. * @param options Define the options used to create the multi render target
  47544. */
  47545. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47546. /** @hidden */
  47547. _rebuild(): void;
  47548. private _createInternalTextures;
  47549. private _createTextures;
  47550. /**
  47551. * Define the number of samples used if MSAA is enabled.
  47552. */
  47553. get samples(): number;
  47554. set samples(value: number);
  47555. /**
  47556. * Resize all the textures in the multi render target.
  47557. * Be carrefull as it will recreate all the data in the new texture.
  47558. * @param size Define the new size
  47559. */
  47560. resize(size: any): void;
  47561. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47562. /**
  47563. * Dispose the render targets and their associated resources
  47564. */
  47565. dispose(): void;
  47566. /**
  47567. * Release all the underlying texture used as draw buffers.
  47568. */
  47569. releaseInternalTextures(): void;
  47570. }
  47571. }
  47572. declare module BABYLON {
  47573. interface ThinEngine {
  47574. /**
  47575. * Unbind a list of render target textures from the webGL context
  47576. * This is used only when drawBuffer extension or webGL2 are active
  47577. * @param textures defines the render target textures to unbind
  47578. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47579. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47580. */
  47581. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47582. /**
  47583. * Create a multi render target texture
  47584. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47585. * @param size defines the size of the texture
  47586. * @param options defines the creation options
  47587. * @returns the cube texture as an InternalTexture
  47588. */
  47589. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47590. /**
  47591. * Update the sample count for a given multiple render target texture
  47592. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47593. * @param textures defines the textures to update
  47594. * @param samples defines the sample count to set
  47595. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47596. */
  47597. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47598. }
  47599. }
  47600. declare module BABYLON {
  47601. /**
  47602. * Class used to define an additional view for the engine
  47603. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47604. */
  47605. export class EngineView {
  47606. /** Defines the canvas where to render the view */
  47607. target: HTMLCanvasElement;
  47608. /** Defines an optional camera used to render the view (will use active camera else) */
  47609. camera?: Camera;
  47610. }
  47611. interface Engine {
  47612. /**
  47613. * Gets or sets the HTML element to use for attaching events
  47614. */
  47615. inputElement: Nullable<HTMLElement>;
  47616. /**
  47617. * Gets the current engine view
  47618. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47619. */
  47620. activeView: Nullable<EngineView>;
  47621. /** Gets or sets the list of views */
  47622. views: EngineView[];
  47623. /**
  47624. * Register a new child canvas
  47625. * @param canvas defines the canvas to register
  47626. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47627. * @returns the associated view
  47628. */
  47629. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47630. /**
  47631. * Remove a registered child canvas
  47632. * @param canvas defines the canvas to remove
  47633. * @returns the current engine
  47634. */
  47635. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47636. }
  47637. }
  47638. declare module BABYLON {
  47639. interface Engine {
  47640. /** @hidden */
  47641. _excludedCompressedTextures: string[];
  47642. /** @hidden */
  47643. _textureFormatInUse: string;
  47644. /**
  47645. * Gets the list of texture formats supported
  47646. */
  47647. readonly texturesSupported: Array<string>;
  47648. /**
  47649. * Gets the texture format in use
  47650. */
  47651. readonly textureFormatInUse: Nullable<string>;
  47652. /**
  47653. * Set the compressed texture extensions or file names to skip.
  47654. *
  47655. * @param skippedFiles defines the list of those texture files you want to skip
  47656. * Example: [".dds", ".env", "myfile.png"]
  47657. */
  47658. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47659. /**
  47660. * Set the compressed texture format to use, based on the formats you have, and the formats
  47661. * supported by the hardware / browser.
  47662. *
  47663. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47664. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47665. * to API arguments needed to compressed textures. This puts the burden on the container
  47666. * generator to house the arcane code for determining these for current & future formats.
  47667. *
  47668. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47669. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47670. *
  47671. * Note: The result of this call is not taken into account when a texture is base64.
  47672. *
  47673. * @param formatsAvailable defines the list of those format families you have created
  47674. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47675. *
  47676. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47677. * @returns The extension selected.
  47678. */
  47679. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47680. }
  47681. }
  47682. declare module BABYLON {
  47683. /**
  47684. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47685. */
  47686. export interface CubeMapInfo {
  47687. /**
  47688. * The pixel array for the front face.
  47689. * This is stored in format, left to right, up to down format.
  47690. */
  47691. front: Nullable<ArrayBufferView>;
  47692. /**
  47693. * The pixel array for the back face.
  47694. * This is stored in format, left to right, up to down format.
  47695. */
  47696. back: Nullable<ArrayBufferView>;
  47697. /**
  47698. * The pixel array for the left face.
  47699. * This is stored in format, left to right, up to down format.
  47700. */
  47701. left: Nullable<ArrayBufferView>;
  47702. /**
  47703. * The pixel array for the right face.
  47704. * This is stored in format, left to right, up to down format.
  47705. */
  47706. right: Nullable<ArrayBufferView>;
  47707. /**
  47708. * The pixel array for the up face.
  47709. * This is stored in format, left to right, up to down format.
  47710. */
  47711. up: Nullable<ArrayBufferView>;
  47712. /**
  47713. * The pixel array for the down face.
  47714. * This is stored in format, left to right, up to down format.
  47715. */
  47716. down: Nullable<ArrayBufferView>;
  47717. /**
  47718. * The size of the cubemap stored.
  47719. *
  47720. * Each faces will be size * size pixels.
  47721. */
  47722. size: number;
  47723. /**
  47724. * The format of the texture.
  47725. *
  47726. * RGBA, RGB.
  47727. */
  47728. format: number;
  47729. /**
  47730. * The type of the texture data.
  47731. *
  47732. * UNSIGNED_INT, FLOAT.
  47733. */
  47734. type: number;
  47735. /**
  47736. * Specifies whether the texture is in gamma space.
  47737. */
  47738. gammaSpace: boolean;
  47739. }
  47740. /**
  47741. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47742. */
  47743. export class PanoramaToCubeMapTools {
  47744. private static FACE_FRONT;
  47745. private static FACE_BACK;
  47746. private static FACE_RIGHT;
  47747. private static FACE_LEFT;
  47748. private static FACE_DOWN;
  47749. private static FACE_UP;
  47750. /**
  47751. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47752. *
  47753. * @param float32Array The source data.
  47754. * @param inputWidth The width of the input panorama.
  47755. * @param inputHeight The height of the input panorama.
  47756. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47757. * @return The cubemap data
  47758. */
  47759. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47760. private static CreateCubemapTexture;
  47761. private static CalcProjectionSpherical;
  47762. }
  47763. }
  47764. declare module BABYLON {
  47765. /**
  47766. * Helper class dealing with the extraction of spherical polynomial dataArray
  47767. * from a cube map.
  47768. */
  47769. export class CubeMapToSphericalPolynomialTools {
  47770. private static FileFaces;
  47771. /**
  47772. * Converts a texture to the according Spherical Polynomial data.
  47773. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47774. *
  47775. * @param texture The texture to extract the information from.
  47776. * @return The Spherical Polynomial data.
  47777. */
  47778. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47779. /**
  47780. * Converts a cubemap to the according Spherical Polynomial data.
  47781. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47782. *
  47783. * @param cubeInfo The Cube map to extract the information from.
  47784. * @return The Spherical Polynomial data.
  47785. */
  47786. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47787. }
  47788. }
  47789. declare module BABYLON {
  47790. interface BaseTexture {
  47791. /**
  47792. * Get the polynomial representation of the texture data.
  47793. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47794. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47795. */
  47796. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47797. }
  47798. }
  47799. declare module BABYLON {
  47800. /** @hidden */
  47801. export var rgbdEncodePixelShader: {
  47802. name: string;
  47803. shader: string;
  47804. };
  47805. }
  47806. declare module BABYLON {
  47807. /** @hidden */
  47808. export var rgbdDecodePixelShader: {
  47809. name: string;
  47810. shader: string;
  47811. };
  47812. }
  47813. declare module BABYLON {
  47814. /**
  47815. * Raw texture data and descriptor sufficient for WebGL texture upload
  47816. */
  47817. export interface EnvironmentTextureInfo {
  47818. /**
  47819. * Version of the environment map
  47820. */
  47821. version: number;
  47822. /**
  47823. * Width of image
  47824. */
  47825. width: number;
  47826. /**
  47827. * Irradiance information stored in the file.
  47828. */
  47829. irradiance: any;
  47830. /**
  47831. * Specular information stored in the file.
  47832. */
  47833. specular: any;
  47834. }
  47835. /**
  47836. * Defines One Image in the file. It requires only the position in the file
  47837. * as well as the length.
  47838. */
  47839. interface BufferImageData {
  47840. /**
  47841. * Length of the image data.
  47842. */
  47843. length: number;
  47844. /**
  47845. * Position of the data from the null terminator delimiting the end of the JSON.
  47846. */
  47847. position: number;
  47848. }
  47849. /**
  47850. * Defines the specular data enclosed in the file.
  47851. * This corresponds to the version 1 of the data.
  47852. */
  47853. export interface EnvironmentTextureSpecularInfoV1 {
  47854. /**
  47855. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47856. */
  47857. specularDataPosition?: number;
  47858. /**
  47859. * This contains all the images data needed to reconstruct the cubemap.
  47860. */
  47861. mipmaps: Array<BufferImageData>;
  47862. /**
  47863. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47864. */
  47865. lodGenerationScale: number;
  47866. }
  47867. /**
  47868. * Sets of helpers addressing the serialization and deserialization of environment texture
  47869. * stored in a BabylonJS env file.
  47870. * Those files are usually stored as .env files.
  47871. */
  47872. export class EnvironmentTextureTools {
  47873. /**
  47874. * Magic number identifying the env file.
  47875. */
  47876. private static _MagicBytes;
  47877. /**
  47878. * Gets the environment info from an env file.
  47879. * @param data The array buffer containing the .env bytes.
  47880. * @returns the environment file info (the json header) if successfully parsed.
  47881. */
  47882. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47883. /**
  47884. * Creates an environment texture from a loaded cube texture.
  47885. * @param texture defines the cube texture to convert in env file
  47886. * @return a promise containing the environment data if succesfull.
  47887. */
  47888. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47889. /**
  47890. * Creates a JSON representation of the spherical data.
  47891. * @param texture defines the texture containing the polynomials
  47892. * @return the JSON representation of the spherical info
  47893. */
  47894. private static _CreateEnvTextureIrradiance;
  47895. /**
  47896. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47897. * @param data the image data
  47898. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47899. * @return the views described by info providing access to the underlying buffer
  47900. */
  47901. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47902. /**
  47903. * Uploads the texture info contained in the env file to the GPU.
  47904. * @param texture defines the internal texture to upload to
  47905. * @param data defines the data to load
  47906. * @param info defines the texture info retrieved through the GetEnvInfo method
  47907. * @returns a promise
  47908. */
  47909. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47910. private static _OnImageReadyAsync;
  47911. /**
  47912. * Uploads the levels of image data to the GPU.
  47913. * @param texture defines the internal texture to upload to
  47914. * @param imageData defines the array buffer views of image data [mipmap][face]
  47915. * @returns a promise
  47916. */
  47917. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47918. /**
  47919. * Uploads spherical polynomials information to the texture.
  47920. * @param texture defines the texture we are trying to upload the information to
  47921. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47922. */
  47923. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47924. /** @hidden */
  47925. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47926. }
  47927. }
  47928. declare module BABYLON {
  47929. /**
  47930. * Contains position and normal vectors for a vertex
  47931. */
  47932. export class PositionNormalVertex {
  47933. /** the position of the vertex (defaut: 0,0,0) */
  47934. position: Vector3;
  47935. /** the normal of the vertex (defaut: 0,1,0) */
  47936. normal: Vector3;
  47937. /**
  47938. * Creates a PositionNormalVertex
  47939. * @param position the position of the vertex (defaut: 0,0,0)
  47940. * @param normal the normal of the vertex (defaut: 0,1,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. /**
  47948. * Clones the PositionNormalVertex
  47949. * @returns the cloned PositionNormalVertex
  47950. */
  47951. clone(): PositionNormalVertex;
  47952. }
  47953. /**
  47954. * Contains position, normal and uv vectors for a vertex
  47955. */
  47956. export class PositionNormalTextureVertex {
  47957. /** the position of the vertex (defaut: 0,0,0) */
  47958. position: Vector3;
  47959. /** the normal of the vertex (defaut: 0,1,0) */
  47960. normal: Vector3;
  47961. /** the uv of the vertex (default: 0,0) */
  47962. uv: Vector2;
  47963. /**
  47964. * Creates a PositionNormalTextureVertex
  47965. * @param position the position of the vertex (defaut: 0,0,0)
  47966. * @param normal the normal of the vertex (defaut: 0,1,0)
  47967. * @param uv the uv of the vertex (default: 0,0)
  47968. */
  47969. constructor(
  47970. /** the position of the vertex (defaut: 0,0,0) */
  47971. position?: Vector3,
  47972. /** the normal of the vertex (defaut: 0,1,0) */
  47973. normal?: Vector3,
  47974. /** the uv of the vertex (default: 0,0) */
  47975. uv?: Vector2);
  47976. /**
  47977. * Clones the PositionNormalTextureVertex
  47978. * @returns the cloned PositionNormalTextureVertex
  47979. */
  47980. clone(): PositionNormalTextureVertex;
  47981. }
  47982. }
  47983. declare module BABYLON {
  47984. /** @hidden */
  47985. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47986. private _genericAttributeLocation;
  47987. private _varyingLocationCount;
  47988. private _varyingLocationMap;
  47989. private _replacements;
  47990. private _textureCount;
  47991. private _uniforms;
  47992. lineProcessor(line: string): string;
  47993. attributeProcessor(attribute: string): string;
  47994. varyingProcessor(varying: string, isFragment: boolean): string;
  47995. uniformProcessor(uniform: string): string;
  47996. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47997. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47998. }
  47999. }
  48000. declare module BABYLON {
  48001. /**
  48002. * Container for accessors for natively-stored mesh data buffers.
  48003. */
  48004. class NativeDataBuffer extends DataBuffer {
  48005. /**
  48006. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48007. */
  48008. nativeIndexBuffer?: any;
  48009. /**
  48010. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48011. */
  48012. nativeVertexBuffer?: any;
  48013. }
  48014. /** @hidden */
  48015. class NativeTexture extends InternalTexture {
  48016. getInternalTexture(): InternalTexture;
  48017. getViewCount(): number;
  48018. }
  48019. /** @hidden */
  48020. export class NativeEngine extends Engine {
  48021. private readonly _native;
  48022. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48023. private readonly INVALID_HANDLE;
  48024. getHardwareScalingLevel(): number;
  48025. constructor();
  48026. dispose(): void;
  48027. /**
  48028. * Can be used to override the current requestAnimationFrame requester.
  48029. * @hidden
  48030. */
  48031. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48032. /**
  48033. * Override default engine behavior.
  48034. * @param color
  48035. * @param backBuffer
  48036. * @param depth
  48037. * @param stencil
  48038. */
  48039. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48040. /**
  48041. * Gets host document
  48042. * @returns the host document object
  48043. */
  48044. getHostDocument(): Nullable<Document>;
  48045. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48046. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48047. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48048. recordVertexArrayObject(vertexBuffers: {
  48049. [key: string]: VertexBuffer;
  48050. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48051. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48052. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48053. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48054. /**
  48055. * Draw a list of indexed primitives
  48056. * @param fillMode defines the primitive to use
  48057. * @param indexStart defines the starting index
  48058. * @param indexCount defines the number of index to draw
  48059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48060. */
  48061. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48062. /**
  48063. * Draw a list of unindexed primitives
  48064. * @param fillMode defines the primitive to use
  48065. * @param verticesStart defines the index of first vertex to draw
  48066. * @param verticesCount defines the count of vertices to draw
  48067. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48068. */
  48069. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48070. createPipelineContext(): IPipelineContext;
  48071. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48072. /** @hidden */
  48073. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48074. /** @hidden */
  48075. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48076. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48077. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48078. protected _setProgram(program: WebGLProgram): void;
  48079. _releaseEffect(effect: Effect): void;
  48080. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48081. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48082. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48083. bindSamplers(effect: Effect): void;
  48084. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48085. getRenderWidth(useScreen?: boolean): number;
  48086. getRenderHeight(useScreen?: boolean): number;
  48087. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48088. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48089. /**
  48090. * Set the z offset to apply to current rendering
  48091. * @param value defines the offset to apply
  48092. */
  48093. setZOffset(value: number): void;
  48094. /**
  48095. * Gets the current value of the zOffset
  48096. * @returns the current zOffset state
  48097. */
  48098. getZOffset(): number;
  48099. /**
  48100. * Enable or disable depth buffering
  48101. * @param enable defines the state to set
  48102. */
  48103. setDepthBuffer(enable: boolean): void;
  48104. /**
  48105. * Gets a boolean indicating if depth writing is enabled
  48106. * @returns the current depth writing state
  48107. */
  48108. getDepthWrite(): boolean;
  48109. /**
  48110. * Enable or disable depth writing
  48111. * @param enable defines the state to set
  48112. */
  48113. setDepthWrite(enable: boolean): void;
  48114. /**
  48115. * Enable or disable color writing
  48116. * @param enable defines the state to set
  48117. */
  48118. setColorWrite(enable: boolean): void;
  48119. /**
  48120. * Gets a boolean indicating if color writing is enabled
  48121. * @returns the current color writing state
  48122. */
  48123. getColorWrite(): boolean;
  48124. /**
  48125. * Sets alpha constants used by some alpha blending modes
  48126. * @param r defines the red component
  48127. * @param g defines the green component
  48128. * @param b defines the blue component
  48129. * @param a defines the alpha component
  48130. */
  48131. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48132. /**
  48133. * Sets the current alpha mode
  48134. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48135. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48136. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48137. */
  48138. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48139. /**
  48140. * Gets the current alpha mode
  48141. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48142. * @returns the current alpha mode
  48143. */
  48144. getAlphaMode(): number;
  48145. setInt(uniform: WebGLUniformLocation, int: number): void;
  48146. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48147. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48148. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48149. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48150. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48151. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48152. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48153. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48154. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48155. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48156. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48157. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48158. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48159. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48160. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48161. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48162. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48163. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48164. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48165. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48166. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48167. wipeCaches(bruteForce?: boolean): void;
  48168. _createTexture(): WebGLTexture;
  48169. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48170. /**
  48171. * Usually called from Texture.ts.
  48172. * Passed information to create a WebGLTexture
  48173. * @param url defines a value which contains one of the following:
  48174. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48175. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48176. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48177. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48178. * @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)
  48179. * @param scene needed for loading to the correct scene
  48180. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48181. * @param onLoad optional callback to be called upon successful completion
  48182. * @param onError optional callback to be called upon failure
  48183. * @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
  48184. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48185. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48186. * @param forcedExtension defines the extension to use to pick the right loader
  48187. * @param mimeType defines an optional mime type
  48188. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48189. */
  48190. 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;
  48191. /**
  48192. * Creates a cube texture
  48193. * @param rootUrl defines the url where the files to load is located
  48194. * @param scene defines the current scene
  48195. * @param files defines the list of files to load (1 per face)
  48196. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48197. * @param onLoad defines an optional callback raised when the texture is loaded
  48198. * @param onError defines an optional callback raised if there is an issue to load the texture
  48199. * @param format defines the format of the data
  48200. * @param forcedExtension defines the extension to use to pick the right loader
  48201. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48202. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48203. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48204. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48205. * @returns the cube texture as an InternalTexture
  48206. */
  48207. 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;
  48208. private _getSamplingFilter;
  48209. private static _GetNativeTextureFormat;
  48210. createRenderTargetTexture(size: number | {
  48211. width: number;
  48212. height: number;
  48213. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48214. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48215. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48216. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48217. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48218. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48219. /**
  48220. * Updates a dynamic vertex buffer.
  48221. * @param vertexBuffer the vertex buffer to update
  48222. * @param data the data used to update the vertex buffer
  48223. * @param byteOffset the byte offset of the data (optional)
  48224. * @param byteLength the byte length of the data (optional)
  48225. */
  48226. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48227. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48228. private _updateAnisotropicLevel;
  48229. private _getAddressMode;
  48230. /** @hidden */
  48231. _bindTexture(channel: number, texture: InternalTexture): void;
  48232. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48233. releaseEffects(): void;
  48234. /** @hidden */
  48235. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48236. /** @hidden */
  48237. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48238. /** @hidden */
  48239. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48240. /** @hidden */
  48241. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48242. }
  48243. }
  48244. declare module BABYLON {
  48245. /**
  48246. * Gather the list of clipboard event types as constants.
  48247. */
  48248. export class ClipboardEventTypes {
  48249. /**
  48250. * The clipboard event is fired when a copy command is active (pressed).
  48251. */
  48252. static readonly COPY: number;
  48253. /**
  48254. * The clipboard event is fired when a cut command is active (pressed).
  48255. */
  48256. static readonly CUT: number;
  48257. /**
  48258. * The clipboard event is fired when a paste command is active (pressed).
  48259. */
  48260. static readonly PASTE: number;
  48261. }
  48262. /**
  48263. * This class is used to store clipboard related info for the onClipboardObservable event.
  48264. */
  48265. export class ClipboardInfo {
  48266. /**
  48267. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48268. */
  48269. type: number;
  48270. /**
  48271. * Defines the related dom event
  48272. */
  48273. event: ClipboardEvent;
  48274. /**
  48275. *Creates an instance of ClipboardInfo.
  48276. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48277. * @param event Defines the related dom event
  48278. */
  48279. constructor(
  48280. /**
  48281. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48282. */
  48283. type: number,
  48284. /**
  48285. * Defines the related dom event
  48286. */
  48287. event: ClipboardEvent);
  48288. /**
  48289. * Get the clipboard event's type from the keycode.
  48290. * @param keyCode Defines the keyCode for the current keyboard event.
  48291. * @return {number}
  48292. */
  48293. static GetTypeFromCharacter(keyCode: number): number;
  48294. }
  48295. }
  48296. declare module BABYLON {
  48297. /**
  48298. * Google Daydream controller
  48299. */
  48300. export class DaydreamController extends WebVRController {
  48301. /**
  48302. * Base Url for the controller model.
  48303. */
  48304. static MODEL_BASE_URL: string;
  48305. /**
  48306. * File name for the controller model.
  48307. */
  48308. static MODEL_FILENAME: string;
  48309. /**
  48310. * Gamepad Id prefix used to identify Daydream Controller.
  48311. */
  48312. static readonly GAMEPAD_ID_PREFIX: string;
  48313. /**
  48314. * Creates a new DaydreamController from a gamepad
  48315. * @param vrGamepad the gamepad that the controller should be created from
  48316. */
  48317. constructor(vrGamepad: any);
  48318. /**
  48319. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48320. * @param scene scene in which to add meshes
  48321. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48322. */
  48323. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48324. /**
  48325. * Called once for each button that changed state since the last frame
  48326. * @param buttonIdx Which button index changed
  48327. * @param state New state of the button
  48328. * @param changes Which properties on the state changed since last frame
  48329. */
  48330. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48331. }
  48332. }
  48333. declare module BABYLON {
  48334. /**
  48335. * Gear VR Controller
  48336. */
  48337. export class GearVRController extends WebVRController {
  48338. /**
  48339. * Base Url for the controller model.
  48340. */
  48341. static MODEL_BASE_URL: string;
  48342. /**
  48343. * File name for the controller model.
  48344. */
  48345. static MODEL_FILENAME: string;
  48346. /**
  48347. * Gamepad Id prefix used to identify this controller.
  48348. */
  48349. static readonly GAMEPAD_ID_PREFIX: string;
  48350. private readonly _buttonIndexToObservableNameMap;
  48351. /**
  48352. * Creates a new GearVRController from a gamepad
  48353. * @param vrGamepad the gamepad that the controller should be created from
  48354. */
  48355. constructor(vrGamepad: any);
  48356. /**
  48357. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48358. * @param scene scene in which to add meshes
  48359. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48360. */
  48361. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48362. /**
  48363. * Called once for each button that changed state since the last frame
  48364. * @param buttonIdx Which button index changed
  48365. * @param state New state of the button
  48366. * @param changes Which properties on the state changed since last frame
  48367. */
  48368. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48369. }
  48370. }
  48371. declare module BABYLON {
  48372. /**
  48373. * Generic Controller
  48374. */
  48375. export class GenericController extends WebVRController {
  48376. /**
  48377. * Base Url for the controller model.
  48378. */
  48379. static readonly MODEL_BASE_URL: string;
  48380. /**
  48381. * File name for the controller model.
  48382. */
  48383. static readonly MODEL_FILENAME: string;
  48384. /**
  48385. * Creates a new GenericController from a gamepad
  48386. * @param vrGamepad the gamepad that the controller should be created from
  48387. */
  48388. constructor(vrGamepad: any);
  48389. /**
  48390. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48391. * @param scene scene in which to add meshes
  48392. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48393. */
  48394. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48395. /**
  48396. * Called once for each button that changed state since the last frame
  48397. * @param buttonIdx Which button index changed
  48398. * @param state New state of the button
  48399. * @param changes Which properties on the state changed since last frame
  48400. */
  48401. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48402. }
  48403. }
  48404. declare module BABYLON {
  48405. /**
  48406. * Oculus Touch Controller
  48407. */
  48408. export class OculusTouchController extends WebVRController {
  48409. /**
  48410. * Base Url for the controller model.
  48411. */
  48412. static MODEL_BASE_URL: string;
  48413. /**
  48414. * File name for the left controller model.
  48415. */
  48416. static MODEL_LEFT_FILENAME: string;
  48417. /**
  48418. * File name for the right controller model.
  48419. */
  48420. static MODEL_RIGHT_FILENAME: string;
  48421. /**
  48422. * Base Url for the Quest controller model.
  48423. */
  48424. static QUEST_MODEL_BASE_URL: string;
  48425. /**
  48426. * @hidden
  48427. * If the controllers are running on a device that needs the updated Quest controller models
  48428. */
  48429. static _IsQuest: boolean;
  48430. /**
  48431. * Fired when the secondary trigger on this controller is modified
  48432. */
  48433. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48434. /**
  48435. * Fired when the thumb rest on this controller is modified
  48436. */
  48437. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48438. /**
  48439. * Creates a new OculusTouchController from a gamepad
  48440. * @param vrGamepad the gamepad that the controller should be created from
  48441. */
  48442. constructor(vrGamepad: any);
  48443. /**
  48444. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48445. * @param scene scene in which to add meshes
  48446. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48447. */
  48448. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48449. /**
  48450. * Fired when the A button on this controller is modified
  48451. */
  48452. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48453. /**
  48454. * Fired when the B button on this controller is modified
  48455. */
  48456. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48457. /**
  48458. * Fired when the X button on this controller is modified
  48459. */
  48460. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48461. /**
  48462. * Fired when the Y button on this controller is modified
  48463. */
  48464. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48465. /**
  48466. * Called once for each button that changed state since the last frame
  48467. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48468. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48469. * 2) secondary trigger (same)
  48470. * 3) A (right) X (left), touch, pressed = value
  48471. * 4) B / Y
  48472. * 5) thumb rest
  48473. * @param buttonIdx Which button index changed
  48474. * @param state New state of the button
  48475. * @param changes Which properties on the state changed since last frame
  48476. */
  48477. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48478. }
  48479. }
  48480. declare module BABYLON {
  48481. /**
  48482. * Vive Controller
  48483. */
  48484. export class ViveController extends WebVRController {
  48485. /**
  48486. * Base Url for the controller model.
  48487. */
  48488. static MODEL_BASE_URL: string;
  48489. /**
  48490. * File name for the controller model.
  48491. */
  48492. static MODEL_FILENAME: string;
  48493. /**
  48494. * Creates a new ViveController from a gamepad
  48495. * @param vrGamepad the gamepad that the controller should be created from
  48496. */
  48497. constructor(vrGamepad: any);
  48498. /**
  48499. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48500. * @param scene scene in which to add meshes
  48501. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48502. */
  48503. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48504. /**
  48505. * Fired when the left button on this controller is modified
  48506. */
  48507. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48508. /**
  48509. * Fired when the right button on this controller is modified
  48510. */
  48511. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48512. /**
  48513. * Fired when the menu button on this controller is modified
  48514. */
  48515. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48516. /**
  48517. * Called once for each button that changed state since the last frame
  48518. * Vive mapping:
  48519. * 0: touchpad
  48520. * 1: trigger
  48521. * 2: left AND right buttons
  48522. * 3: menu button
  48523. * @param buttonIdx Which button index changed
  48524. * @param state New state of the button
  48525. * @param changes Which properties on the state changed since last frame
  48526. */
  48527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48528. }
  48529. }
  48530. declare module BABYLON {
  48531. /**
  48532. * Defines the WindowsMotionController object that the state of the windows motion controller
  48533. */
  48534. export class WindowsMotionController extends WebVRController {
  48535. /**
  48536. * The base url used to load the left and right controller models
  48537. */
  48538. static MODEL_BASE_URL: string;
  48539. /**
  48540. * The name of the left controller model file
  48541. */
  48542. static MODEL_LEFT_FILENAME: string;
  48543. /**
  48544. * The name of the right controller model file
  48545. */
  48546. static MODEL_RIGHT_FILENAME: string;
  48547. /**
  48548. * The controller name prefix for this controller type
  48549. */
  48550. static readonly GAMEPAD_ID_PREFIX: string;
  48551. /**
  48552. * The controller id pattern for this controller type
  48553. */
  48554. private static readonly GAMEPAD_ID_PATTERN;
  48555. private _loadedMeshInfo;
  48556. protected readonly _mapping: {
  48557. buttons: string[];
  48558. buttonMeshNames: {
  48559. trigger: string;
  48560. menu: string;
  48561. grip: string;
  48562. thumbstick: string;
  48563. trackpad: string;
  48564. };
  48565. buttonObservableNames: {
  48566. trigger: string;
  48567. menu: string;
  48568. grip: string;
  48569. thumbstick: string;
  48570. trackpad: string;
  48571. };
  48572. axisMeshNames: string[];
  48573. pointingPoseMeshName: string;
  48574. };
  48575. /**
  48576. * Fired when the trackpad on this controller is clicked
  48577. */
  48578. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48579. /**
  48580. * Fired when the trackpad on this controller is modified
  48581. */
  48582. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48583. /**
  48584. * The current x and y values of this controller's trackpad
  48585. */
  48586. trackpad: StickValues;
  48587. /**
  48588. * Creates a new WindowsMotionController from a gamepad
  48589. * @param vrGamepad the gamepad that the controller should be created from
  48590. */
  48591. constructor(vrGamepad: any);
  48592. /**
  48593. * Fired when the trigger on this controller is modified
  48594. */
  48595. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48596. /**
  48597. * Fired when the menu button on this controller is modified
  48598. */
  48599. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48600. /**
  48601. * Fired when the grip button on this controller is modified
  48602. */
  48603. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48604. /**
  48605. * Fired when the thumbstick button on this controller is modified
  48606. */
  48607. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48608. /**
  48609. * Fired when the touchpad button on this controller is modified
  48610. */
  48611. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48612. /**
  48613. * Fired when the touchpad values on this controller are modified
  48614. */
  48615. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48616. protected _updateTrackpad(): void;
  48617. /**
  48618. * Called once per frame by the engine.
  48619. */
  48620. update(): void;
  48621. /**
  48622. * Called once for each button that changed state since the last frame
  48623. * @param buttonIdx Which button index changed
  48624. * @param state New state of the button
  48625. * @param changes Which properties on the state changed since last frame
  48626. */
  48627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48628. /**
  48629. * Moves the buttons on the controller mesh based on their current state
  48630. * @param buttonName the name of the button to move
  48631. * @param buttonValue the value of the button which determines the buttons new position
  48632. */
  48633. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48634. /**
  48635. * Moves the axis on the controller mesh based on its current state
  48636. * @param axis the index of the axis
  48637. * @param axisValue the value of the axis which determines the meshes new position
  48638. * @hidden
  48639. */
  48640. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48641. /**
  48642. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48643. * @param scene scene in which to add meshes
  48644. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48645. */
  48646. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48647. /**
  48648. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48649. * can be transformed by button presses and axes values, based on this._mapping.
  48650. *
  48651. * @param scene scene in which the meshes exist
  48652. * @param meshes list of meshes that make up the controller model to process
  48653. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48654. */
  48655. private processModel;
  48656. private createMeshInfo;
  48657. /**
  48658. * Gets the ray of the controller in the direction the controller is pointing
  48659. * @param length the length the resulting ray should be
  48660. * @returns a ray in the direction the controller is pointing
  48661. */
  48662. getForwardRay(length?: number): Ray;
  48663. /**
  48664. * Disposes of the controller
  48665. */
  48666. dispose(): void;
  48667. }
  48668. /**
  48669. * This class represents a new windows motion controller in XR.
  48670. */
  48671. export class XRWindowsMotionController extends WindowsMotionController {
  48672. /**
  48673. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48674. */
  48675. protected readonly _mapping: {
  48676. buttons: string[];
  48677. buttonMeshNames: {
  48678. trigger: string;
  48679. menu: string;
  48680. grip: string;
  48681. thumbstick: string;
  48682. trackpad: string;
  48683. };
  48684. buttonObservableNames: {
  48685. trigger: string;
  48686. menu: string;
  48687. grip: string;
  48688. thumbstick: string;
  48689. trackpad: string;
  48690. };
  48691. axisMeshNames: string[];
  48692. pointingPoseMeshName: string;
  48693. };
  48694. /**
  48695. * Construct a new XR-Based windows motion controller
  48696. *
  48697. * @param gamepadInfo the gamepad object from the browser
  48698. */
  48699. constructor(gamepadInfo: any);
  48700. /**
  48701. * holds the thumbstick values (X,Y)
  48702. */
  48703. thumbstickValues: StickValues;
  48704. /**
  48705. * Fired when the thumbstick on this controller is clicked
  48706. */
  48707. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48708. /**
  48709. * Fired when the thumbstick on this controller is modified
  48710. */
  48711. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48712. /**
  48713. * Fired when the touchpad button on this controller is modified
  48714. */
  48715. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48716. /**
  48717. * Fired when the touchpad values on this controller are modified
  48718. */
  48719. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48720. /**
  48721. * Fired when the thumbstick button on this controller is modified
  48722. * here to prevent breaking changes
  48723. */
  48724. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48725. /**
  48726. * updating the thumbstick(!) and not the trackpad.
  48727. * This is named this way due to the difference between WebVR and XR and to avoid
  48728. * changing the parent class.
  48729. */
  48730. protected _updateTrackpad(): void;
  48731. /**
  48732. * Disposes the class with joy
  48733. */
  48734. dispose(): void;
  48735. }
  48736. }
  48737. declare module BABYLON {
  48738. /**
  48739. * Class containing static functions to help procedurally build meshes
  48740. */
  48741. export class PolyhedronBuilder {
  48742. /**
  48743. * Creates a polyhedron mesh
  48744. * * 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
  48745. * * The parameter `size` (positive float, default 1) sets the polygon size
  48746. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48747. * * 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`
  48748. * * 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
  48749. * * 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)`)
  48750. * * 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
  48751. * * 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
  48752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48753. * * 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
  48754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48755. * @param name defines the name of the mesh
  48756. * @param options defines the options used to create the mesh
  48757. * @param scene defines the hosting scene
  48758. * @returns the polyhedron mesh
  48759. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48760. */
  48761. static CreatePolyhedron(name: string, options: {
  48762. type?: number;
  48763. size?: number;
  48764. sizeX?: number;
  48765. sizeY?: number;
  48766. sizeZ?: number;
  48767. custom?: any;
  48768. faceUV?: Vector4[];
  48769. faceColors?: Color4[];
  48770. flat?: boolean;
  48771. updatable?: boolean;
  48772. sideOrientation?: number;
  48773. frontUVs?: Vector4;
  48774. backUVs?: Vector4;
  48775. }, scene?: Nullable<Scene>): Mesh;
  48776. }
  48777. }
  48778. declare module BABYLON {
  48779. /**
  48780. * Gizmo that enables scaling a mesh along 3 axis
  48781. */
  48782. export class ScaleGizmo extends Gizmo {
  48783. /**
  48784. * Internal gizmo used for interactions on the x axis
  48785. */
  48786. xGizmo: AxisScaleGizmo;
  48787. /**
  48788. * Internal gizmo used for interactions on the y axis
  48789. */
  48790. yGizmo: AxisScaleGizmo;
  48791. /**
  48792. * Internal gizmo used for interactions on the z axis
  48793. */
  48794. zGizmo: AxisScaleGizmo;
  48795. /**
  48796. * Internal gizmo used to scale all axis equally
  48797. */
  48798. uniformScaleGizmo: AxisScaleGizmo;
  48799. private _meshAttached;
  48800. private _updateGizmoRotationToMatchAttachedMesh;
  48801. private _snapDistance;
  48802. private _scaleRatio;
  48803. private _uniformScalingMesh;
  48804. private _octahedron;
  48805. private _sensitivity;
  48806. /** Fires an event when any of it's sub gizmos are dragged */
  48807. onDragStartObservable: Observable<unknown>;
  48808. /** Fires an event when any of it's sub gizmos are released from dragging */
  48809. onDragEndObservable: Observable<unknown>;
  48810. get attachedMesh(): Nullable<AbstractMesh>;
  48811. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48812. /**
  48813. * Creates a ScaleGizmo
  48814. * @param gizmoLayer The utility layer the gizmo will be added to
  48815. */
  48816. constructor(gizmoLayer?: UtilityLayerRenderer);
  48817. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48818. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48819. /**
  48820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48821. */
  48822. set snapDistance(value: number);
  48823. get snapDistance(): number;
  48824. /**
  48825. * Ratio for the scale of the gizmo (Default: 1)
  48826. */
  48827. set scaleRatio(value: number);
  48828. get scaleRatio(): number;
  48829. /**
  48830. * Sensitivity factor for dragging (Default: 1)
  48831. */
  48832. set sensitivity(value: number);
  48833. get sensitivity(): number;
  48834. /**
  48835. * Disposes of the gizmo
  48836. */
  48837. dispose(): void;
  48838. }
  48839. }
  48840. declare module BABYLON {
  48841. /**
  48842. * Single axis scale gizmo
  48843. */
  48844. export class AxisScaleGizmo extends Gizmo {
  48845. /**
  48846. * Drag behavior responsible for the gizmos dragging interactions
  48847. */
  48848. dragBehavior: PointerDragBehavior;
  48849. private _pointerObserver;
  48850. /**
  48851. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48852. */
  48853. snapDistance: number;
  48854. /**
  48855. * Event that fires each time the gizmo snaps to a new location.
  48856. * * snapDistance is the the change in distance
  48857. */
  48858. onSnapObservable: Observable<{
  48859. snapDistance: number;
  48860. }>;
  48861. /**
  48862. * If the scaling operation should be done on all axis (default: false)
  48863. */
  48864. uniformScaling: boolean;
  48865. /**
  48866. * Custom sensitivity value for the drag strength
  48867. */
  48868. sensitivity: number;
  48869. private _isEnabled;
  48870. private _parent;
  48871. private _arrow;
  48872. private _coloredMaterial;
  48873. private _hoverMaterial;
  48874. /**
  48875. * Creates an AxisScaleGizmo
  48876. * @param gizmoLayer The utility layer the gizmo will be added to
  48877. * @param dragAxis The axis which the gizmo will be able to scale on
  48878. * @param color The color of the gizmo
  48879. */
  48880. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48881. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48882. /**
  48883. * If the gizmo is enabled
  48884. */
  48885. set isEnabled(value: boolean);
  48886. get isEnabled(): boolean;
  48887. /**
  48888. * Disposes of the gizmo
  48889. */
  48890. dispose(): void;
  48891. /**
  48892. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48893. * @param mesh The mesh to replace the default mesh of the gizmo
  48894. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48895. */
  48896. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48897. }
  48898. }
  48899. declare module BABYLON {
  48900. /**
  48901. * Bounding box gizmo
  48902. */
  48903. export class BoundingBoxGizmo extends Gizmo {
  48904. private _lineBoundingBox;
  48905. private _rotateSpheresParent;
  48906. private _scaleBoxesParent;
  48907. private _boundingDimensions;
  48908. private _renderObserver;
  48909. private _pointerObserver;
  48910. private _scaleDragSpeed;
  48911. private _tmpQuaternion;
  48912. private _tmpVector;
  48913. private _tmpRotationMatrix;
  48914. /**
  48915. * 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)
  48916. */
  48917. ignoreChildren: boolean;
  48918. /**
  48919. * 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)
  48920. */
  48921. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48922. /**
  48923. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48924. */
  48925. rotationSphereSize: number;
  48926. /**
  48927. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48928. */
  48929. scaleBoxSize: number;
  48930. /**
  48931. * 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)
  48932. */
  48933. fixedDragMeshScreenSize: boolean;
  48934. /**
  48935. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48936. */
  48937. fixedDragMeshScreenSizeDistanceFactor: number;
  48938. /**
  48939. * Fired when a rotation sphere or scale box is dragged
  48940. */
  48941. onDragStartObservable: Observable<{}>;
  48942. /**
  48943. * Fired when a scale box is dragged
  48944. */
  48945. onScaleBoxDragObservable: Observable<{}>;
  48946. /**
  48947. * Fired when a scale box drag is ended
  48948. */
  48949. onScaleBoxDragEndObservable: Observable<{}>;
  48950. /**
  48951. * Fired when a rotation sphere is dragged
  48952. */
  48953. onRotationSphereDragObservable: Observable<{}>;
  48954. /**
  48955. * Fired when a rotation sphere drag is ended
  48956. */
  48957. onRotationSphereDragEndObservable: Observable<{}>;
  48958. /**
  48959. * 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)
  48960. */
  48961. scalePivot: Nullable<Vector3>;
  48962. /**
  48963. * Mesh used as a pivot to rotate the attached mesh
  48964. */
  48965. private _anchorMesh;
  48966. private _existingMeshScale;
  48967. private _dragMesh;
  48968. private pointerDragBehavior;
  48969. private coloredMaterial;
  48970. private hoverColoredMaterial;
  48971. /**
  48972. * Sets the color of the bounding box gizmo
  48973. * @param color the color to set
  48974. */
  48975. setColor(color: Color3): void;
  48976. /**
  48977. * Creates an BoundingBoxGizmo
  48978. * @param gizmoLayer The utility layer the gizmo will be added to
  48979. * @param color The color of the gizmo
  48980. */
  48981. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48982. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48983. private _selectNode;
  48984. /**
  48985. * Updates the bounding box information for the Gizmo
  48986. */
  48987. updateBoundingBox(): void;
  48988. private _updateRotationSpheres;
  48989. private _updateScaleBoxes;
  48990. /**
  48991. * Enables rotation on the specified axis and disables rotation on the others
  48992. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48993. */
  48994. setEnabledRotationAxis(axis: string): void;
  48995. /**
  48996. * Enables/disables scaling
  48997. * @param enable if scaling should be enabled
  48998. * @param homogeneousScaling defines if scaling should only be homogeneous
  48999. */
  49000. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49001. private _updateDummy;
  49002. /**
  49003. * Enables a pointer drag behavior on the bounding box of the gizmo
  49004. */
  49005. enableDragBehavior(): void;
  49006. /**
  49007. * Disposes of the gizmo
  49008. */
  49009. dispose(): void;
  49010. /**
  49011. * 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)
  49012. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49013. * @returns the bounding box mesh with the passed in mesh as a child
  49014. */
  49015. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49016. /**
  49017. * CustomMeshes are not supported by this gizmo
  49018. * @param mesh The mesh to replace the default mesh of the gizmo
  49019. */
  49020. setCustomMesh(mesh: Mesh): void;
  49021. }
  49022. }
  49023. declare module BABYLON {
  49024. /**
  49025. * Single plane rotation gizmo
  49026. */
  49027. export class PlaneRotationGizmo extends Gizmo {
  49028. /**
  49029. * Drag behavior responsible for the gizmos dragging interactions
  49030. */
  49031. dragBehavior: PointerDragBehavior;
  49032. private _pointerObserver;
  49033. /**
  49034. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49035. */
  49036. snapDistance: number;
  49037. /**
  49038. * Event that fires each time the gizmo snaps to a new location.
  49039. * * snapDistance is the the change in distance
  49040. */
  49041. onSnapObservable: Observable<{
  49042. snapDistance: number;
  49043. }>;
  49044. private _isEnabled;
  49045. private _parent;
  49046. /**
  49047. * Creates a PlaneRotationGizmo
  49048. * @param gizmoLayer The utility layer the gizmo will be added to
  49049. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49050. * @param color The color of the gizmo
  49051. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49052. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49053. */
  49054. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49055. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49056. /**
  49057. * If the gizmo is enabled
  49058. */
  49059. set isEnabled(value: boolean);
  49060. get isEnabled(): boolean;
  49061. /**
  49062. * Disposes of the gizmo
  49063. */
  49064. dispose(): void;
  49065. }
  49066. }
  49067. declare module BABYLON {
  49068. /**
  49069. * Gizmo that enables rotating a mesh along 3 axis
  49070. */
  49071. export class RotationGizmo extends Gizmo {
  49072. /**
  49073. * Internal gizmo used for interactions on the x axis
  49074. */
  49075. xGizmo: PlaneRotationGizmo;
  49076. /**
  49077. * Internal gizmo used for interactions on the y axis
  49078. */
  49079. yGizmo: PlaneRotationGizmo;
  49080. /**
  49081. * Internal gizmo used for interactions on the z axis
  49082. */
  49083. zGizmo: PlaneRotationGizmo;
  49084. /** Fires an event when any of it's sub gizmos are dragged */
  49085. onDragStartObservable: Observable<unknown>;
  49086. /** Fires an event when any of it's sub gizmos are released from dragging */
  49087. onDragEndObservable: Observable<unknown>;
  49088. private _meshAttached;
  49089. get attachedMesh(): Nullable<AbstractMesh>;
  49090. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49091. /**
  49092. * Creates a RotationGizmo
  49093. * @param gizmoLayer The utility layer the gizmo will be added to
  49094. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49095. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49096. */
  49097. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49098. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49099. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49100. /**
  49101. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49102. */
  49103. set snapDistance(value: number);
  49104. get snapDistance(): number;
  49105. /**
  49106. * Ratio for the scale of the gizmo (Default: 1)
  49107. */
  49108. set scaleRatio(value: number);
  49109. get scaleRatio(): number;
  49110. /**
  49111. * Disposes of the gizmo
  49112. */
  49113. dispose(): void;
  49114. /**
  49115. * CustomMeshes are not supported by this gizmo
  49116. * @param mesh The mesh to replace the default mesh of the gizmo
  49117. */
  49118. setCustomMesh(mesh: Mesh): void;
  49119. }
  49120. }
  49121. declare module BABYLON {
  49122. /**
  49123. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49124. */
  49125. export class GizmoManager implements IDisposable {
  49126. private scene;
  49127. /**
  49128. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49129. */
  49130. gizmos: {
  49131. positionGizmo: Nullable<PositionGizmo>;
  49132. rotationGizmo: Nullable<RotationGizmo>;
  49133. scaleGizmo: Nullable<ScaleGizmo>;
  49134. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49135. };
  49136. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49137. clearGizmoOnEmptyPointerEvent: boolean;
  49138. /** Fires an event when the manager is attached to a mesh */
  49139. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49140. private _gizmosEnabled;
  49141. private _pointerObserver;
  49142. private _attachedMesh;
  49143. private _boundingBoxColor;
  49144. private _defaultUtilityLayer;
  49145. private _defaultKeepDepthUtilityLayer;
  49146. /**
  49147. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49148. */
  49149. boundingBoxDragBehavior: SixDofDragBehavior;
  49150. /**
  49151. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49152. */
  49153. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49154. /**
  49155. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49156. */
  49157. usePointerToAttachGizmos: boolean;
  49158. /**
  49159. * Utility layer that the bounding box gizmo belongs to
  49160. */
  49161. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49162. /**
  49163. * Utility layer that all gizmos besides bounding box belong to
  49164. */
  49165. get utilityLayer(): UtilityLayerRenderer;
  49166. /**
  49167. * Instatiates a gizmo manager
  49168. * @param scene the scene to overlay the gizmos on top of
  49169. */
  49170. constructor(scene: Scene);
  49171. /**
  49172. * Attaches a set of gizmos to the specified mesh
  49173. * @param mesh The mesh the gizmo's should be attached to
  49174. */
  49175. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49176. /**
  49177. * If the position gizmo is enabled
  49178. */
  49179. set positionGizmoEnabled(value: boolean);
  49180. get positionGizmoEnabled(): boolean;
  49181. /**
  49182. * If the rotation gizmo is enabled
  49183. */
  49184. set rotationGizmoEnabled(value: boolean);
  49185. get rotationGizmoEnabled(): boolean;
  49186. /**
  49187. * If the scale gizmo is enabled
  49188. */
  49189. set scaleGizmoEnabled(value: boolean);
  49190. get scaleGizmoEnabled(): boolean;
  49191. /**
  49192. * If the boundingBox gizmo is enabled
  49193. */
  49194. set boundingBoxGizmoEnabled(value: boolean);
  49195. get boundingBoxGizmoEnabled(): boolean;
  49196. /**
  49197. * Disposes of the gizmo manager
  49198. */
  49199. dispose(): void;
  49200. }
  49201. }
  49202. declare module BABYLON {
  49203. /**
  49204. * A directional light is defined by a direction (what a surprise!).
  49205. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49206. * 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.
  49207. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49208. */
  49209. export class DirectionalLight extends ShadowLight {
  49210. private _shadowFrustumSize;
  49211. /**
  49212. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49213. */
  49214. get shadowFrustumSize(): number;
  49215. /**
  49216. * Specifies a fix frustum size for the shadow generation.
  49217. */
  49218. set shadowFrustumSize(value: number);
  49219. private _shadowOrthoScale;
  49220. /**
  49221. * Gets the shadow projection scale against the optimal computed one.
  49222. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49223. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49224. */
  49225. get shadowOrthoScale(): number;
  49226. /**
  49227. * Sets the shadow projection scale against the optimal computed one.
  49228. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49229. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49230. */
  49231. set shadowOrthoScale(value: number);
  49232. /**
  49233. * Automatically compute the projection matrix to best fit (including all the casters)
  49234. * on each frame.
  49235. */
  49236. autoUpdateExtends: boolean;
  49237. /**
  49238. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49239. * on each frame. autoUpdateExtends must be set to true for this to work
  49240. */
  49241. autoCalcShadowZBounds: boolean;
  49242. private _orthoLeft;
  49243. private _orthoRight;
  49244. private _orthoTop;
  49245. private _orthoBottom;
  49246. /**
  49247. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49248. * The directional light is emitted from everywhere in the given direction.
  49249. * It can cast shadows.
  49250. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49251. * @param name The friendly name of the light
  49252. * @param direction The direction of the light
  49253. * @param scene The scene the light belongs to
  49254. */
  49255. constructor(name: string, direction: Vector3, scene: Scene);
  49256. /**
  49257. * Returns the string "DirectionalLight".
  49258. * @return The class name
  49259. */
  49260. getClassName(): string;
  49261. /**
  49262. * Returns the integer 1.
  49263. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49264. */
  49265. getTypeID(): number;
  49266. /**
  49267. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49268. * Returns the DirectionalLight Shadow projection matrix.
  49269. */
  49270. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49271. /**
  49272. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49273. * Returns the DirectionalLight Shadow projection matrix.
  49274. */
  49275. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49276. /**
  49277. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49278. * Returns the DirectionalLight Shadow projection matrix.
  49279. */
  49280. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49281. protected _buildUniformLayout(): void;
  49282. /**
  49283. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49284. * @param effect The effect to update
  49285. * @param lightIndex The index of the light in the effect to update
  49286. * @returns The directional light
  49287. */
  49288. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49289. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49290. /**
  49291. * Gets the minZ used for shadow according to both the scene and the light.
  49292. *
  49293. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49294. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49295. * @param activeCamera The camera we are returning the min for
  49296. * @returns the depth min z
  49297. */
  49298. getDepthMinZ(activeCamera: Camera): number;
  49299. /**
  49300. * Gets the maxZ used for shadow according to both the scene and the light.
  49301. *
  49302. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49303. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49304. * @param activeCamera The camera we are returning the max for
  49305. * @returns the depth max z
  49306. */
  49307. getDepthMaxZ(activeCamera: Camera): number;
  49308. /**
  49309. * Prepares the list of defines specific to the light type.
  49310. * @param defines the list of defines
  49311. * @param lightIndex defines the index of the light for the effect
  49312. */
  49313. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49314. }
  49315. }
  49316. declare module BABYLON {
  49317. /**
  49318. * Class containing static functions to help procedurally build meshes
  49319. */
  49320. export class HemisphereBuilder {
  49321. /**
  49322. * Creates a hemisphere mesh
  49323. * @param name defines the name of the mesh
  49324. * @param options defines the options used to create the mesh
  49325. * @param scene defines the hosting scene
  49326. * @returns the hemisphere mesh
  49327. */
  49328. static CreateHemisphere(name: string, options: {
  49329. segments?: number;
  49330. diameter?: number;
  49331. sideOrientation?: number;
  49332. }, scene: any): Mesh;
  49333. }
  49334. }
  49335. declare module BABYLON {
  49336. /**
  49337. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49338. * These values define a cone of light starting from the position, emitting toward the direction.
  49339. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49340. * and the exponent defines the speed of the decay of the light with distance (reach).
  49341. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49342. */
  49343. export class SpotLight extends ShadowLight {
  49344. private _angle;
  49345. private _innerAngle;
  49346. private _cosHalfAngle;
  49347. private _lightAngleScale;
  49348. private _lightAngleOffset;
  49349. /**
  49350. * Gets the cone angle of the spot light in Radians.
  49351. */
  49352. get angle(): number;
  49353. /**
  49354. * Sets the cone angle of the spot light in Radians.
  49355. */
  49356. set angle(value: number);
  49357. /**
  49358. * Only used in gltf falloff mode, this defines the angle where
  49359. * the directional falloff will start before cutting at angle which could be seen
  49360. * as outer angle.
  49361. */
  49362. get innerAngle(): number;
  49363. /**
  49364. * Only used in gltf falloff mode, this defines the angle where
  49365. * the directional falloff will start before cutting at angle which could be seen
  49366. * as outer angle.
  49367. */
  49368. set innerAngle(value: number);
  49369. private _shadowAngleScale;
  49370. /**
  49371. * Allows scaling the angle of the light for shadow generation only.
  49372. */
  49373. get shadowAngleScale(): number;
  49374. /**
  49375. * Allows scaling the angle of the light for shadow generation only.
  49376. */
  49377. set shadowAngleScale(value: number);
  49378. /**
  49379. * The light decay speed with the distance from the emission spot.
  49380. */
  49381. exponent: number;
  49382. private _projectionTextureMatrix;
  49383. /**
  49384. * Allows reading the projecton texture
  49385. */
  49386. get projectionTextureMatrix(): Matrix;
  49387. protected _projectionTextureLightNear: number;
  49388. /**
  49389. * Gets the near clip of the Spotlight for texture projection.
  49390. */
  49391. get projectionTextureLightNear(): number;
  49392. /**
  49393. * Sets the near clip of the Spotlight for texture projection.
  49394. */
  49395. set projectionTextureLightNear(value: number);
  49396. protected _projectionTextureLightFar: number;
  49397. /**
  49398. * Gets the far clip of the Spotlight for texture projection.
  49399. */
  49400. get projectionTextureLightFar(): number;
  49401. /**
  49402. * Sets the far clip of the Spotlight for texture projection.
  49403. */
  49404. set projectionTextureLightFar(value: number);
  49405. protected _projectionTextureUpDirection: Vector3;
  49406. /**
  49407. * Gets the Up vector of the Spotlight for texture projection.
  49408. */
  49409. get projectionTextureUpDirection(): Vector3;
  49410. /**
  49411. * Sets the Up vector of the Spotlight for texture projection.
  49412. */
  49413. set projectionTextureUpDirection(value: Vector3);
  49414. private _projectionTexture;
  49415. /**
  49416. * Gets the projection texture of the light.
  49417. */
  49418. get projectionTexture(): Nullable<BaseTexture>;
  49419. /**
  49420. * Sets the projection texture of the light.
  49421. */
  49422. set projectionTexture(value: Nullable<BaseTexture>);
  49423. private _projectionTextureViewLightDirty;
  49424. private _projectionTextureProjectionLightDirty;
  49425. private _projectionTextureDirty;
  49426. private _projectionTextureViewTargetVector;
  49427. private _projectionTextureViewLightMatrix;
  49428. private _projectionTextureProjectionLightMatrix;
  49429. private _projectionTextureScalingMatrix;
  49430. /**
  49431. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49432. * It can cast shadows.
  49433. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49434. * @param name The light friendly name
  49435. * @param position The position of the spot light in the scene
  49436. * @param direction The direction of the light in the scene
  49437. * @param angle The cone angle of the light in Radians
  49438. * @param exponent The light decay speed with the distance from the emission spot
  49439. * @param scene The scene the lights belongs to
  49440. */
  49441. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49442. /**
  49443. * Returns the string "SpotLight".
  49444. * @returns the class name
  49445. */
  49446. getClassName(): string;
  49447. /**
  49448. * Returns the integer 2.
  49449. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49450. */
  49451. getTypeID(): number;
  49452. /**
  49453. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49454. */
  49455. protected _setDirection(value: Vector3): void;
  49456. /**
  49457. * Overrides the position setter to recompute the projection texture view light Matrix.
  49458. */
  49459. protected _setPosition(value: Vector3): void;
  49460. /**
  49461. * 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.
  49462. * Returns the SpotLight.
  49463. */
  49464. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49465. protected _computeProjectionTextureViewLightMatrix(): void;
  49466. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49467. /**
  49468. * Main function for light texture projection matrix computing.
  49469. */
  49470. protected _computeProjectionTextureMatrix(): void;
  49471. protected _buildUniformLayout(): void;
  49472. private _computeAngleValues;
  49473. /**
  49474. * Sets the passed Effect "effect" with the Light textures.
  49475. * @param effect The effect to update
  49476. * @param lightIndex The index of the light in the effect to update
  49477. * @returns The light
  49478. */
  49479. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49480. /**
  49481. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49482. * @param effect The effect to update
  49483. * @param lightIndex The index of the light in the effect to update
  49484. * @returns The spot light
  49485. */
  49486. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49487. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49488. /**
  49489. * Disposes the light and the associated resources.
  49490. */
  49491. dispose(): void;
  49492. /**
  49493. * Prepares the list of defines specific to the light type.
  49494. * @param defines the list of defines
  49495. * @param lightIndex defines the index of the light for the effect
  49496. */
  49497. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49498. }
  49499. }
  49500. declare module BABYLON {
  49501. /**
  49502. * Gizmo that enables viewing a light
  49503. */
  49504. export class LightGizmo extends Gizmo {
  49505. private _lightMesh;
  49506. private _material;
  49507. private _cachedPosition;
  49508. private _cachedForward;
  49509. private _attachedMeshParent;
  49510. /**
  49511. * Creates a LightGizmo
  49512. * @param gizmoLayer The utility layer the gizmo will be added to
  49513. */
  49514. constructor(gizmoLayer?: UtilityLayerRenderer);
  49515. private _light;
  49516. /**
  49517. * The light that the gizmo is attached to
  49518. */
  49519. set light(light: Nullable<Light>);
  49520. get light(): Nullable<Light>;
  49521. /**
  49522. * Gets the material used to render the light gizmo
  49523. */
  49524. get material(): StandardMaterial;
  49525. /**
  49526. * @hidden
  49527. * Updates the gizmo to match the attached mesh's position/rotation
  49528. */
  49529. protected _update(): void;
  49530. private static _Scale;
  49531. /**
  49532. * Creates the lines for a light mesh
  49533. */
  49534. private static _CreateLightLines;
  49535. /**
  49536. * Disposes of the light gizmo
  49537. */
  49538. dispose(): void;
  49539. private static _CreateHemisphericLightMesh;
  49540. private static _CreatePointLightMesh;
  49541. private static _CreateSpotLightMesh;
  49542. private static _CreateDirectionalLightMesh;
  49543. }
  49544. }
  49545. declare module BABYLON {
  49546. /** @hidden */
  49547. export var backgroundFragmentDeclaration: {
  49548. name: string;
  49549. shader: string;
  49550. };
  49551. }
  49552. declare module BABYLON {
  49553. /** @hidden */
  49554. export var backgroundUboDeclaration: {
  49555. name: string;
  49556. shader: string;
  49557. };
  49558. }
  49559. declare module BABYLON {
  49560. /** @hidden */
  49561. export var backgroundPixelShader: {
  49562. name: string;
  49563. shader: string;
  49564. };
  49565. }
  49566. declare module BABYLON {
  49567. /** @hidden */
  49568. export var backgroundVertexDeclaration: {
  49569. name: string;
  49570. shader: string;
  49571. };
  49572. }
  49573. declare module BABYLON {
  49574. /** @hidden */
  49575. export var backgroundVertexShader: {
  49576. name: string;
  49577. shader: string;
  49578. };
  49579. }
  49580. declare module BABYLON {
  49581. /**
  49582. * Background material used to create an efficient environement around your scene.
  49583. */
  49584. export class BackgroundMaterial extends PushMaterial {
  49585. /**
  49586. * Standard reflectance value at parallel view angle.
  49587. */
  49588. static StandardReflectance0: number;
  49589. /**
  49590. * Standard reflectance value at grazing angle.
  49591. */
  49592. static StandardReflectance90: number;
  49593. protected _primaryColor: Color3;
  49594. /**
  49595. * Key light Color (multiply against the environement texture)
  49596. */
  49597. primaryColor: Color3;
  49598. protected __perceptualColor: Nullable<Color3>;
  49599. /**
  49600. * Experimental Internal Use Only.
  49601. *
  49602. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49603. * This acts as a helper to set the primary color to a more "human friendly" value.
  49604. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49605. * output color as close as possible from the chosen value.
  49606. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49607. * part of lighting setup.)
  49608. */
  49609. get _perceptualColor(): Nullable<Color3>;
  49610. set _perceptualColor(value: Nullable<Color3>);
  49611. protected _primaryColorShadowLevel: float;
  49612. /**
  49613. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49614. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49615. */
  49616. get primaryColorShadowLevel(): float;
  49617. set primaryColorShadowLevel(value: float);
  49618. protected _primaryColorHighlightLevel: float;
  49619. /**
  49620. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49621. * The primary color is used at the level chosen to define what the white area would look.
  49622. */
  49623. get primaryColorHighlightLevel(): float;
  49624. set primaryColorHighlightLevel(value: float);
  49625. protected _reflectionTexture: Nullable<BaseTexture>;
  49626. /**
  49627. * Reflection Texture used in the material.
  49628. * Should be author in a specific way for the best result (refer to the documentation).
  49629. */
  49630. reflectionTexture: Nullable<BaseTexture>;
  49631. protected _reflectionBlur: float;
  49632. /**
  49633. * Reflection Texture level of blur.
  49634. *
  49635. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49636. * texture twice.
  49637. */
  49638. reflectionBlur: float;
  49639. protected _diffuseTexture: Nullable<BaseTexture>;
  49640. /**
  49641. * Diffuse Texture used in the material.
  49642. * Should be author in a specific way for the best result (refer to the documentation).
  49643. */
  49644. diffuseTexture: Nullable<BaseTexture>;
  49645. protected _shadowLights: Nullable<IShadowLight[]>;
  49646. /**
  49647. * Specify the list of lights casting shadow on the material.
  49648. * All scene shadow lights will be included if null.
  49649. */
  49650. shadowLights: Nullable<IShadowLight[]>;
  49651. protected _shadowLevel: float;
  49652. /**
  49653. * Helps adjusting the shadow to a softer level if required.
  49654. * 0 means black shadows and 1 means no shadows.
  49655. */
  49656. shadowLevel: float;
  49657. protected _sceneCenter: Vector3;
  49658. /**
  49659. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49660. * It is usually zero but might be interesting to modify according to your setup.
  49661. */
  49662. sceneCenter: Vector3;
  49663. protected _opacityFresnel: boolean;
  49664. /**
  49665. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49666. * This helps ensuring a nice transition when the camera goes under the ground.
  49667. */
  49668. opacityFresnel: boolean;
  49669. protected _reflectionFresnel: boolean;
  49670. /**
  49671. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49672. * This helps adding a mirror texture on the ground.
  49673. */
  49674. reflectionFresnel: boolean;
  49675. protected _reflectionFalloffDistance: number;
  49676. /**
  49677. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49678. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49679. */
  49680. reflectionFalloffDistance: number;
  49681. protected _reflectionAmount: number;
  49682. /**
  49683. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49684. */
  49685. reflectionAmount: number;
  49686. protected _reflectionReflectance0: number;
  49687. /**
  49688. * This specifies the weight of the reflection at grazing angle.
  49689. */
  49690. reflectionReflectance0: number;
  49691. protected _reflectionReflectance90: number;
  49692. /**
  49693. * This specifies the weight of the reflection at a perpendicular point of view.
  49694. */
  49695. reflectionReflectance90: number;
  49696. /**
  49697. * Sets the reflection reflectance fresnel values according to the default standard
  49698. * empirically know to work well :-)
  49699. */
  49700. set reflectionStandardFresnelWeight(value: number);
  49701. protected _useRGBColor: boolean;
  49702. /**
  49703. * Helps to directly use the maps channels instead of their level.
  49704. */
  49705. useRGBColor: boolean;
  49706. protected _enableNoise: boolean;
  49707. /**
  49708. * This helps reducing the banding effect that could occur on the background.
  49709. */
  49710. enableNoise: boolean;
  49711. /**
  49712. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49713. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49714. * Recommended to be keep at 1.0 except for special cases.
  49715. */
  49716. get fovMultiplier(): number;
  49717. set fovMultiplier(value: number);
  49718. private _fovMultiplier;
  49719. /**
  49720. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49721. */
  49722. useEquirectangularFOV: boolean;
  49723. private _maxSimultaneousLights;
  49724. /**
  49725. * Number of Simultaneous lights allowed on the material.
  49726. */
  49727. maxSimultaneousLights: int;
  49728. /**
  49729. * Default configuration related to image processing available in the Background Material.
  49730. */
  49731. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49732. /**
  49733. * Keep track of the image processing observer to allow dispose and replace.
  49734. */
  49735. private _imageProcessingObserver;
  49736. /**
  49737. * Attaches a new image processing configuration to the PBR Material.
  49738. * @param configuration (if null the scene configuration will be use)
  49739. */
  49740. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49741. /**
  49742. * Gets the image processing configuration used either in this material.
  49743. */
  49744. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49745. /**
  49746. * Sets the Default image processing configuration used either in the this material.
  49747. *
  49748. * If sets to null, the scene one is in use.
  49749. */
  49750. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49751. /**
  49752. * Gets wether the color curves effect is enabled.
  49753. */
  49754. get cameraColorCurvesEnabled(): boolean;
  49755. /**
  49756. * Sets wether the color curves effect is enabled.
  49757. */
  49758. set cameraColorCurvesEnabled(value: boolean);
  49759. /**
  49760. * Gets wether the color grading effect is enabled.
  49761. */
  49762. get cameraColorGradingEnabled(): boolean;
  49763. /**
  49764. * Gets wether the color grading effect is enabled.
  49765. */
  49766. set cameraColorGradingEnabled(value: boolean);
  49767. /**
  49768. * Gets wether tonemapping is enabled or not.
  49769. */
  49770. get cameraToneMappingEnabled(): boolean;
  49771. /**
  49772. * Sets wether tonemapping is enabled or not
  49773. */
  49774. set cameraToneMappingEnabled(value: boolean);
  49775. /**
  49776. * The camera exposure used on this material.
  49777. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49778. * This corresponds to a photographic exposure.
  49779. */
  49780. get cameraExposure(): float;
  49781. /**
  49782. * The camera exposure used on this material.
  49783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49784. * This corresponds to a photographic exposure.
  49785. */
  49786. set cameraExposure(value: float);
  49787. /**
  49788. * Gets The camera contrast used on this material.
  49789. */
  49790. get cameraContrast(): float;
  49791. /**
  49792. * Sets The camera contrast used on this material.
  49793. */
  49794. set cameraContrast(value: float);
  49795. /**
  49796. * Gets the Color Grading 2D Lookup Texture.
  49797. */
  49798. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49799. /**
  49800. * Sets the Color Grading 2D Lookup Texture.
  49801. */
  49802. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49803. /**
  49804. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49805. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49806. * 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;
  49807. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49808. */
  49809. get cameraColorCurves(): Nullable<ColorCurves>;
  49810. /**
  49811. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49812. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49813. * 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;
  49814. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49815. */
  49816. set cameraColorCurves(value: Nullable<ColorCurves>);
  49817. /**
  49818. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49819. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49820. */
  49821. switchToBGR: boolean;
  49822. private _renderTargets;
  49823. private _reflectionControls;
  49824. private _white;
  49825. private _primaryShadowColor;
  49826. private _primaryHighlightColor;
  49827. /**
  49828. * Instantiates a Background Material in the given scene
  49829. * @param name The friendly name of the material
  49830. * @param scene The scene to add the material to
  49831. */
  49832. constructor(name: string, scene: Scene);
  49833. /**
  49834. * Gets a boolean indicating that current material needs to register RTT
  49835. */
  49836. get hasRenderTargetTextures(): boolean;
  49837. /**
  49838. * The entire material has been created in order to prevent overdraw.
  49839. * @returns false
  49840. */
  49841. needAlphaTesting(): boolean;
  49842. /**
  49843. * The entire material has been created in order to prevent overdraw.
  49844. * @returns true if blending is enable
  49845. */
  49846. needAlphaBlending(): boolean;
  49847. /**
  49848. * Checks wether the material is ready to be rendered for a given mesh.
  49849. * @param mesh The mesh to render
  49850. * @param subMesh The submesh to check against
  49851. * @param useInstances Specify wether or not the material is used with instances
  49852. * @returns true if all the dependencies are ready (Textures, Effects...)
  49853. */
  49854. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49855. /**
  49856. * Compute the primary color according to the chosen perceptual color.
  49857. */
  49858. private _computePrimaryColorFromPerceptualColor;
  49859. /**
  49860. * Compute the highlights and shadow colors according to their chosen levels.
  49861. */
  49862. private _computePrimaryColors;
  49863. /**
  49864. * Build the uniform buffer used in the material.
  49865. */
  49866. buildUniformLayout(): void;
  49867. /**
  49868. * Unbind the material.
  49869. */
  49870. unbind(): void;
  49871. /**
  49872. * Bind only the world matrix to the material.
  49873. * @param world The world matrix to bind.
  49874. */
  49875. bindOnlyWorldMatrix(world: Matrix): void;
  49876. /**
  49877. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49878. * @param world The world matrix to bind.
  49879. * @param subMesh The submesh to bind for.
  49880. */
  49881. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49882. /**
  49883. * Checks to see if a texture is used in the material.
  49884. * @param texture - Base texture to use.
  49885. * @returns - Boolean specifying if a texture is used in the material.
  49886. */
  49887. hasTexture(texture: BaseTexture): boolean;
  49888. /**
  49889. * Dispose the material.
  49890. * @param forceDisposeEffect Force disposal of the associated effect.
  49891. * @param forceDisposeTextures Force disposal of the associated textures.
  49892. */
  49893. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49894. /**
  49895. * Clones the material.
  49896. * @param name The cloned name.
  49897. * @returns The cloned material.
  49898. */
  49899. clone(name: string): BackgroundMaterial;
  49900. /**
  49901. * Serializes the current material to its JSON representation.
  49902. * @returns The JSON representation.
  49903. */
  49904. serialize(): any;
  49905. /**
  49906. * Gets the class name of the material
  49907. * @returns "BackgroundMaterial"
  49908. */
  49909. getClassName(): string;
  49910. /**
  49911. * Parse a JSON input to create back a background material.
  49912. * @param source The JSON data to parse
  49913. * @param scene The scene to create the parsed material in
  49914. * @param rootUrl The root url of the assets the material depends upon
  49915. * @returns the instantiated BackgroundMaterial.
  49916. */
  49917. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49918. }
  49919. }
  49920. declare module BABYLON {
  49921. /**
  49922. * Represents the different options available during the creation of
  49923. * a Environment helper.
  49924. *
  49925. * This can control the default ground, skybox and image processing setup of your scene.
  49926. */
  49927. export interface IEnvironmentHelperOptions {
  49928. /**
  49929. * Specifies whether or not to create a ground.
  49930. * True by default.
  49931. */
  49932. createGround: boolean;
  49933. /**
  49934. * Specifies the ground size.
  49935. * 15 by default.
  49936. */
  49937. groundSize: number;
  49938. /**
  49939. * The texture used on the ground for the main color.
  49940. * Comes from the BabylonJS CDN by default.
  49941. *
  49942. * Remarks: Can be either a texture or a url.
  49943. */
  49944. groundTexture: string | BaseTexture;
  49945. /**
  49946. * The color mixed in the ground texture by default.
  49947. * BabylonJS clearColor by default.
  49948. */
  49949. groundColor: Color3;
  49950. /**
  49951. * Specifies the ground opacity.
  49952. * 1 by default.
  49953. */
  49954. groundOpacity: number;
  49955. /**
  49956. * Enables the ground to receive shadows.
  49957. * True by default.
  49958. */
  49959. enableGroundShadow: boolean;
  49960. /**
  49961. * Helps preventing the shadow to be fully black on the ground.
  49962. * 0.5 by default.
  49963. */
  49964. groundShadowLevel: number;
  49965. /**
  49966. * Creates a mirror texture attach to the ground.
  49967. * false by default.
  49968. */
  49969. enableGroundMirror: boolean;
  49970. /**
  49971. * Specifies the ground mirror size ratio.
  49972. * 0.3 by default as the default kernel is 64.
  49973. */
  49974. groundMirrorSizeRatio: number;
  49975. /**
  49976. * Specifies the ground mirror blur kernel size.
  49977. * 64 by default.
  49978. */
  49979. groundMirrorBlurKernel: number;
  49980. /**
  49981. * Specifies the ground mirror visibility amount.
  49982. * 1 by default
  49983. */
  49984. groundMirrorAmount: number;
  49985. /**
  49986. * Specifies the ground mirror reflectance weight.
  49987. * This uses the standard weight of the background material to setup the fresnel effect
  49988. * of the mirror.
  49989. * 1 by default.
  49990. */
  49991. groundMirrorFresnelWeight: number;
  49992. /**
  49993. * Specifies the ground mirror Falloff distance.
  49994. * This can helps reducing the size of the reflection.
  49995. * 0 by Default.
  49996. */
  49997. groundMirrorFallOffDistance: number;
  49998. /**
  49999. * Specifies the ground mirror texture type.
  50000. * Unsigned Int by Default.
  50001. */
  50002. groundMirrorTextureType: number;
  50003. /**
  50004. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50005. * the shown objects.
  50006. */
  50007. groundYBias: number;
  50008. /**
  50009. * Specifies whether or not to create a skybox.
  50010. * True by default.
  50011. */
  50012. createSkybox: boolean;
  50013. /**
  50014. * Specifies the skybox size.
  50015. * 20 by default.
  50016. */
  50017. skyboxSize: number;
  50018. /**
  50019. * The texture used on the skybox for the main color.
  50020. * Comes from the BabylonJS CDN by default.
  50021. *
  50022. * Remarks: Can be either a texture or a url.
  50023. */
  50024. skyboxTexture: string | BaseTexture;
  50025. /**
  50026. * The color mixed in the skybox texture by default.
  50027. * BabylonJS clearColor by default.
  50028. */
  50029. skyboxColor: Color3;
  50030. /**
  50031. * The background rotation around the Y axis of the scene.
  50032. * This helps aligning the key lights of your scene with the background.
  50033. * 0 by default.
  50034. */
  50035. backgroundYRotation: number;
  50036. /**
  50037. * Compute automatically the size of the elements to best fit with the scene.
  50038. */
  50039. sizeAuto: boolean;
  50040. /**
  50041. * Default position of the rootMesh if autoSize is not true.
  50042. */
  50043. rootPosition: Vector3;
  50044. /**
  50045. * Sets up the image processing in the scene.
  50046. * true by default.
  50047. */
  50048. setupImageProcessing: boolean;
  50049. /**
  50050. * The texture used as your environment texture in the scene.
  50051. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50052. *
  50053. * Remarks: Can be either a texture or a url.
  50054. */
  50055. environmentTexture: string | BaseTexture;
  50056. /**
  50057. * The value of the exposure to apply to the scene.
  50058. * 0.6 by default if setupImageProcessing is true.
  50059. */
  50060. cameraExposure: number;
  50061. /**
  50062. * The value of the contrast to apply to the scene.
  50063. * 1.6 by default if setupImageProcessing is true.
  50064. */
  50065. cameraContrast: number;
  50066. /**
  50067. * Specifies whether or not tonemapping should be enabled in the scene.
  50068. * true by default if setupImageProcessing is true.
  50069. */
  50070. toneMappingEnabled: boolean;
  50071. }
  50072. /**
  50073. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50074. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50075. * It also helps with the default setup of your imageProcessing configuration.
  50076. */
  50077. export class EnvironmentHelper {
  50078. /**
  50079. * Default ground texture URL.
  50080. */
  50081. private static _groundTextureCDNUrl;
  50082. /**
  50083. * Default skybox texture URL.
  50084. */
  50085. private static _skyboxTextureCDNUrl;
  50086. /**
  50087. * Default environment texture URL.
  50088. */
  50089. private static _environmentTextureCDNUrl;
  50090. /**
  50091. * Creates the default options for the helper.
  50092. */
  50093. private static _getDefaultOptions;
  50094. private _rootMesh;
  50095. /**
  50096. * Gets the root mesh created by the helper.
  50097. */
  50098. get rootMesh(): Mesh;
  50099. private _skybox;
  50100. /**
  50101. * Gets the skybox created by the helper.
  50102. */
  50103. get skybox(): Nullable<Mesh>;
  50104. private _skyboxTexture;
  50105. /**
  50106. * Gets the skybox texture created by the helper.
  50107. */
  50108. get skyboxTexture(): Nullable<BaseTexture>;
  50109. private _skyboxMaterial;
  50110. /**
  50111. * Gets the skybox material created by the helper.
  50112. */
  50113. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50114. private _ground;
  50115. /**
  50116. * Gets the ground mesh created by the helper.
  50117. */
  50118. get ground(): Nullable<Mesh>;
  50119. private _groundTexture;
  50120. /**
  50121. * Gets the ground texture created by the helper.
  50122. */
  50123. get groundTexture(): Nullable<BaseTexture>;
  50124. private _groundMirror;
  50125. /**
  50126. * Gets the ground mirror created by the helper.
  50127. */
  50128. get groundMirror(): Nullable<MirrorTexture>;
  50129. /**
  50130. * Gets the ground mirror render list to helps pushing the meshes
  50131. * you wish in the ground reflection.
  50132. */
  50133. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50134. private _groundMaterial;
  50135. /**
  50136. * Gets the ground material created by the helper.
  50137. */
  50138. get groundMaterial(): Nullable<BackgroundMaterial>;
  50139. /**
  50140. * Stores the creation options.
  50141. */
  50142. private readonly _scene;
  50143. private _options;
  50144. /**
  50145. * This observable will be notified with any error during the creation of the environment,
  50146. * mainly texture creation errors.
  50147. */
  50148. onErrorObservable: Observable<{
  50149. message?: string;
  50150. exception?: any;
  50151. }>;
  50152. /**
  50153. * constructor
  50154. * @param options Defines the options we want to customize the helper
  50155. * @param scene The scene to add the material to
  50156. */
  50157. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50158. /**
  50159. * Updates the background according to the new options
  50160. * @param options
  50161. */
  50162. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50163. /**
  50164. * Sets the primary color of all the available elements.
  50165. * @param color the main color to affect to the ground and the background
  50166. */
  50167. setMainColor(color: Color3): void;
  50168. /**
  50169. * Setup the image processing according to the specified options.
  50170. */
  50171. private _setupImageProcessing;
  50172. /**
  50173. * Setup the environment texture according to the specified options.
  50174. */
  50175. private _setupEnvironmentTexture;
  50176. /**
  50177. * Setup the background according to the specified options.
  50178. */
  50179. private _setupBackground;
  50180. /**
  50181. * Get the scene sizes according to the setup.
  50182. */
  50183. private _getSceneSize;
  50184. /**
  50185. * Setup the ground according to the specified options.
  50186. */
  50187. private _setupGround;
  50188. /**
  50189. * Setup the ground material according to the specified options.
  50190. */
  50191. private _setupGroundMaterial;
  50192. /**
  50193. * Setup the ground diffuse texture according to the specified options.
  50194. */
  50195. private _setupGroundDiffuseTexture;
  50196. /**
  50197. * Setup the ground mirror texture according to the specified options.
  50198. */
  50199. private _setupGroundMirrorTexture;
  50200. /**
  50201. * Setup the ground to receive the mirror texture.
  50202. */
  50203. private _setupMirrorInGroundMaterial;
  50204. /**
  50205. * Setup the skybox according to the specified options.
  50206. */
  50207. private _setupSkybox;
  50208. /**
  50209. * Setup the skybox material according to the specified options.
  50210. */
  50211. private _setupSkyboxMaterial;
  50212. /**
  50213. * Setup the skybox reflection texture according to the specified options.
  50214. */
  50215. private _setupSkyboxReflectionTexture;
  50216. private _errorHandler;
  50217. /**
  50218. * Dispose all the elements created by the Helper.
  50219. */
  50220. dispose(): void;
  50221. }
  50222. }
  50223. declare module BABYLON {
  50224. /**
  50225. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50226. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50227. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50228. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50229. */
  50230. export class PhotoDome extends TransformNode {
  50231. /**
  50232. * Define the image as a Monoscopic panoramic 360 image.
  50233. */
  50234. static readonly MODE_MONOSCOPIC: number;
  50235. /**
  50236. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50237. */
  50238. static readonly MODE_TOPBOTTOM: number;
  50239. /**
  50240. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50241. */
  50242. static readonly MODE_SIDEBYSIDE: number;
  50243. private _useDirectMapping;
  50244. /**
  50245. * The texture being displayed on the sphere
  50246. */
  50247. protected _photoTexture: Texture;
  50248. /**
  50249. * Gets or sets the texture being displayed on the sphere
  50250. */
  50251. get photoTexture(): Texture;
  50252. set photoTexture(value: Texture);
  50253. /**
  50254. * Observable raised when an error occured while loading the 360 image
  50255. */
  50256. onLoadErrorObservable: Observable<string>;
  50257. /**
  50258. * The skybox material
  50259. */
  50260. protected _material: BackgroundMaterial;
  50261. /**
  50262. * The surface used for the skybox
  50263. */
  50264. protected _mesh: Mesh;
  50265. /**
  50266. * Gets the mesh used for the skybox.
  50267. */
  50268. get mesh(): Mesh;
  50269. /**
  50270. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50271. * Also see the options.resolution property.
  50272. */
  50273. get fovMultiplier(): number;
  50274. set fovMultiplier(value: number);
  50275. private _imageMode;
  50276. /**
  50277. * Gets or set the current video mode for the video. It can be:
  50278. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50279. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50280. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50281. */
  50282. get imageMode(): number;
  50283. set imageMode(value: number);
  50284. /**
  50285. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50286. * @param name Element's name, child elements will append suffixes for their own names.
  50287. * @param urlsOfPhoto defines the url of the photo to display
  50288. * @param options defines an object containing optional or exposed sub element properties
  50289. * @param onError defines a callback called when an error occured while loading the texture
  50290. */
  50291. constructor(name: string, urlOfPhoto: string, options: {
  50292. resolution?: number;
  50293. size?: number;
  50294. useDirectMapping?: boolean;
  50295. faceForward?: boolean;
  50296. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50297. private _onBeforeCameraRenderObserver;
  50298. private _changeImageMode;
  50299. /**
  50300. * Releases resources associated with this node.
  50301. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50302. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50303. */
  50304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50305. }
  50306. }
  50307. declare module BABYLON {
  50308. /**
  50309. * Class used to host RGBD texture specific utilities
  50310. */
  50311. export class RGBDTextureTools {
  50312. /**
  50313. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50314. * @param texture the texture to expand.
  50315. */
  50316. static ExpandRGBDTexture(texture: Texture): void;
  50317. }
  50318. }
  50319. declare module BABYLON {
  50320. /**
  50321. * Class used to host texture specific utilities
  50322. */
  50323. export class BRDFTextureTools {
  50324. /**
  50325. * Prevents texture cache collision
  50326. */
  50327. private static _instanceNumber;
  50328. /**
  50329. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50330. * @param scene defines the hosting scene
  50331. * @returns the environment BRDF texture
  50332. */
  50333. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50334. private static _environmentBRDFBase64Texture;
  50335. }
  50336. }
  50337. declare module BABYLON {
  50338. /**
  50339. * @hidden
  50340. */
  50341. export interface IMaterialClearCoatDefines {
  50342. CLEARCOAT: boolean;
  50343. CLEARCOAT_DEFAULTIOR: boolean;
  50344. CLEARCOAT_TEXTURE: boolean;
  50345. CLEARCOAT_TEXTUREDIRECTUV: number;
  50346. CLEARCOAT_BUMP: boolean;
  50347. CLEARCOAT_BUMPDIRECTUV: number;
  50348. CLEARCOAT_TINT: boolean;
  50349. CLEARCOAT_TINT_TEXTURE: boolean;
  50350. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50351. /** @hidden */
  50352. _areTexturesDirty: boolean;
  50353. }
  50354. /**
  50355. * Define the code related to the clear coat parameters of the pbr material.
  50356. */
  50357. export class PBRClearCoatConfiguration {
  50358. /**
  50359. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50360. * The default fits with a polyurethane material.
  50361. */
  50362. private static readonly _DefaultIndexOfRefraction;
  50363. private _isEnabled;
  50364. /**
  50365. * Defines if the clear coat is enabled in the material.
  50366. */
  50367. isEnabled: boolean;
  50368. /**
  50369. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50370. */
  50371. intensity: number;
  50372. /**
  50373. * Defines the clear coat layer roughness.
  50374. */
  50375. roughness: number;
  50376. private _indexOfRefraction;
  50377. /**
  50378. * Defines the index of refraction of the clear coat.
  50379. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50380. * The default fits with a polyurethane material.
  50381. * Changing the default value is more performance intensive.
  50382. */
  50383. indexOfRefraction: number;
  50384. private _texture;
  50385. /**
  50386. * Stores the clear coat values in a texture.
  50387. */
  50388. texture: Nullable<BaseTexture>;
  50389. private _bumpTexture;
  50390. /**
  50391. * Define the clear coat specific bump texture.
  50392. */
  50393. bumpTexture: Nullable<BaseTexture>;
  50394. private _isTintEnabled;
  50395. /**
  50396. * Defines if the clear coat tint is enabled in the material.
  50397. */
  50398. isTintEnabled: boolean;
  50399. /**
  50400. * Defines the clear coat tint of the material.
  50401. * This is only use if tint is enabled
  50402. */
  50403. tintColor: Color3;
  50404. /**
  50405. * Defines the distance at which the tint color should be found in the
  50406. * clear coat media.
  50407. * This is only use if tint is enabled
  50408. */
  50409. tintColorAtDistance: number;
  50410. /**
  50411. * Defines the clear coat layer thickness.
  50412. * This is only use if tint is enabled
  50413. */
  50414. tintThickness: number;
  50415. private _tintTexture;
  50416. /**
  50417. * Stores the clear tint values in a texture.
  50418. * rgb is tint
  50419. * a is a thickness factor
  50420. */
  50421. tintTexture: Nullable<BaseTexture>;
  50422. /** @hidden */
  50423. private _internalMarkAllSubMeshesAsTexturesDirty;
  50424. /** @hidden */
  50425. _markAllSubMeshesAsTexturesDirty(): void;
  50426. /**
  50427. * Instantiate a new istance of clear coat configuration.
  50428. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50429. */
  50430. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50431. /**
  50432. * Gets wehter the submesh is ready to be used or not.
  50433. * @param defines the list of "defines" to update.
  50434. * @param scene defines the scene the material belongs to.
  50435. * @param engine defines the engine the material belongs to.
  50436. * @param disableBumpMap defines wether the material disables bump or not.
  50437. * @returns - boolean indicating that the submesh is ready or not.
  50438. */
  50439. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50440. /**
  50441. * Checks to see if a texture is used in the material.
  50442. * @param defines the list of "defines" to update.
  50443. * @param scene defines the scene to the material belongs to.
  50444. */
  50445. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50446. /**
  50447. * Binds the material data.
  50448. * @param uniformBuffer defines the Uniform buffer to fill in.
  50449. * @param scene defines the scene the material belongs to.
  50450. * @param engine defines the engine the material belongs to.
  50451. * @param disableBumpMap defines wether the material disables bump or not.
  50452. * @param isFrozen defines wether the material is frozen or not.
  50453. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50454. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50455. */
  50456. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50457. /**
  50458. * Checks to see if a texture is used in the material.
  50459. * @param texture - Base texture to use.
  50460. * @returns - Boolean specifying if a texture is used in the material.
  50461. */
  50462. hasTexture(texture: BaseTexture): boolean;
  50463. /**
  50464. * Returns an array of the actively used textures.
  50465. * @param activeTextures Array of BaseTextures
  50466. */
  50467. getActiveTextures(activeTextures: BaseTexture[]): void;
  50468. /**
  50469. * Returns the animatable textures.
  50470. * @param animatables Array of animatable textures.
  50471. */
  50472. getAnimatables(animatables: IAnimatable[]): void;
  50473. /**
  50474. * Disposes the resources of the material.
  50475. * @param forceDisposeTextures - Forces the disposal of all textures.
  50476. */
  50477. dispose(forceDisposeTextures?: boolean): void;
  50478. /**
  50479. * Get the current class name of the texture useful for serialization or dynamic coding.
  50480. * @returns "PBRClearCoatConfiguration"
  50481. */
  50482. getClassName(): string;
  50483. /**
  50484. * Add fallbacks to the effect fallbacks list.
  50485. * @param defines defines the Base texture to use.
  50486. * @param fallbacks defines the current fallback list.
  50487. * @param currentRank defines the current fallback rank.
  50488. * @returns the new fallback rank.
  50489. */
  50490. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50491. /**
  50492. * Add the required uniforms to the current list.
  50493. * @param uniforms defines the current uniform list.
  50494. */
  50495. static AddUniforms(uniforms: string[]): void;
  50496. /**
  50497. * Add the required samplers to the current list.
  50498. * @param samplers defines the current sampler list.
  50499. */
  50500. static AddSamplers(samplers: string[]): void;
  50501. /**
  50502. * Add the required uniforms to the current buffer.
  50503. * @param uniformBuffer defines the current uniform buffer.
  50504. */
  50505. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50506. /**
  50507. * Makes a duplicate of the current configuration into another one.
  50508. * @param clearCoatConfiguration define the config where to copy the info
  50509. */
  50510. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50511. /**
  50512. * Serializes this clear coat configuration.
  50513. * @returns - An object with the serialized config.
  50514. */
  50515. serialize(): any;
  50516. /**
  50517. * Parses a anisotropy Configuration from a serialized object.
  50518. * @param source - Serialized object.
  50519. * @param scene Defines the scene we are parsing for
  50520. * @param rootUrl Defines the rootUrl to load from
  50521. */
  50522. parse(source: any, scene: Scene, rootUrl: string): void;
  50523. }
  50524. }
  50525. declare module BABYLON {
  50526. /**
  50527. * @hidden
  50528. */
  50529. export interface IMaterialAnisotropicDefines {
  50530. ANISOTROPIC: boolean;
  50531. ANISOTROPIC_TEXTURE: boolean;
  50532. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50533. MAINUV1: boolean;
  50534. _areTexturesDirty: boolean;
  50535. _needUVs: boolean;
  50536. }
  50537. /**
  50538. * Define the code related to the anisotropic parameters of the pbr material.
  50539. */
  50540. export class PBRAnisotropicConfiguration {
  50541. private _isEnabled;
  50542. /**
  50543. * Defines if the anisotropy is enabled in the material.
  50544. */
  50545. isEnabled: boolean;
  50546. /**
  50547. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50548. */
  50549. intensity: number;
  50550. /**
  50551. * Defines if the effect is along the tangents, bitangents or in between.
  50552. * By default, the effect is "strectching" the highlights along the tangents.
  50553. */
  50554. direction: Vector2;
  50555. private _texture;
  50556. /**
  50557. * Stores the anisotropy values in a texture.
  50558. * rg is direction (like normal from -1 to 1)
  50559. * b is a intensity
  50560. */
  50561. texture: Nullable<BaseTexture>;
  50562. /** @hidden */
  50563. private _internalMarkAllSubMeshesAsTexturesDirty;
  50564. /** @hidden */
  50565. _markAllSubMeshesAsTexturesDirty(): void;
  50566. /**
  50567. * Instantiate a new istance of anisotropy configuration.
  50568. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50569. */
  50570. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50571. /**
  50572. * Specifies that the submesh is ready to be used.
  50573. * @param defines the list of "defines" to update.
  50574. * @param scene defines the scene the material belongs to.
  50575. * @returns - boolean indicating that the submesh is ready or not.
  50576. */
  50577. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50578. /**
  50579. * Checks to see if a texture is used in the material.
  50580. * @param defines the list of "defines" to update.
  50581. * @param mesh the mesh we are preparing the defines for.
  50582. * @param scene defines the scene the material belongs to.
  50583. */
  50584. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50585. /**
  50586. * Binds the material data.
  50587. * @param uniformBuffer defines the Uniform buffer to fill in.
  50588. * @param scene defines the scene the material belongs to.
  50589. * @param isFrozen defines wether the material is frozen or not.
  50590. */
  50591. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50592. /**
  50593. * Checks to see if a texture is used in the material.
  50594. * @param texture - Base texture to use.
  50595. * @returns - Boolean specifying if a texture is used in the material.
  50596. */
  50597. hasTexture(texture: BaseTexture): boolean;
  50598. /**
  50599. * Returns an array of the actively used textures.
  50600. * @param activeTextures Array of BaseTextures
  50601. */
  50602. getActiveTextures(activeTextures: BaseTexture[]): void;
  50603. /**
  50604. * Returns the animatable textures.
  50605. * @param animatables Array of animatable textures.
  50606. */
  50607. getAnimatables(animatables: IAnimatable[]): void;
  50608. /**
  50609. * Disposes the resources of the material.
  50610. * @param forceDisposeTextures - Forces the disposal of all textures.
  50611. */
  50612. dispose(forceDisposeTextures?: boolean): void;
  50613. /**
  50614. * Get the current class name of the texture useful for serialization or dynamic coding.
  50615. * @returns "PBRAnisotropicConfiguration"
  50616. */
  50617. getClassName(): string;
  50618. /**
  50619. * Add fallbacks to the effect fallbacks list.
  50620. * @param defines defines the Base texture to use.
  50621. * @param fallbacks defines the current fallback list.
  50622. * @param currentRank defines the current fallback rank.
  50623. * @returns the new fallback rank.
  50624. */
  50625. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50626. /**
  50627. * Add the required uniforms to the current list.
  50628. * @param uniforms defines the current uniform list.
  50629. */
  50630. static AddUniforms(uniforms: string[]): void;
  50631. /**
  50632. * Add the required uniforms to the current buffer.
  50633. * @param uniformBuffer defines the current uniform buffer.
  50634. */
  50635. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50636. /**
  50637. * Add the required samplers to the current list.
  50638. * @param samplers defines the current sampler list.
  50639. */
  50640. static AddSamplers(samplers: string[]): void;
  50641. /**
  50642. * Makes a duplicate of the current configuration into another one.
  50643. * @param anisotropicConfiguration define the config where to copy the info
  50644. */
  50645. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50646. /**
  50647. * Serializes this anisotropy configuration.
  50648. * @returns - An object with the serialized config.
  50649. */
  50650. serialize(): any;
  50651. /**
  50652. * Parses a anisotropy Configuration from a serialized object.
  50653. * @param source - Serialized object.
  50654. * @param scene Defines the scene we are parsing for
  50655. * @param rootUrl Defines the rootUrl to load from
  50656. */
  50657. parse(source: any, scene: Scene, rootUrl: string): void;
  50658. }
  50659. }
  50660. declare module BABYLON {
  50661. /**
  50662. * @hidden
  50663. */
  50664. export interface IMaterialBRDFDefines {
  50665. BRDF_V_HEIGHT_CORRELATED: boolean;
  50666. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50667. SPHERICAL_HARMONICS: boolean;
  50668. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50669. /** @hidden */
  50670. _areMiscDirty: boolean;
  50671. }
  50672. /**
  50673. * Define the code related to the BRDF parameters of the pbr material.
  50674. */
  50675. export class PBRBRDFConfiguration {
  50676. /**
  50677. * Default value used for the energy conservation.
  50678. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50679. */
  50680. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50681. /**
  50682. * Default value used for the Smith Visibility Height Correlated mode.
  50683. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50684. */
  50685. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50686. /**
  50687. * Default value used for the IBL diffuse part.
  50688. * This can help switching back to the polynomials mode globally which is a tiny bit
  50689. * less GPU intensive at the drawback of a lower quality.
  50690. */
  50691. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50692. /**
  50693. * Default value used for activating energy conservation for the specular workflow.
  50694. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50695. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50696. */
  50697. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50698. private _useEnergyConservation;
  50699. /**
  50700. * Defines if the material uses energy conservation.
  50701. */
  50702. useEnergyConservation: boolean;
  50703. private _useSmithVisibilityHeightCorrelated;
  50704. /**
  50705. * LEGACY Mode set to false
  50706. * Defines if the material uses height smith correlated visibility term.
  50707. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50708. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50709. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50710. * Not relying on height correlated will also disable energy conservation.
  50711. */
  50712. useSmithVisibilityHeightCorrelated: boolean;
  50713. private _useSphericalHarmonics;
  50714. /**
  50715. * LEGACY Mode set to false
  50716. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50717. * diffuse part of the IBL.
  50718. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50719. * to the ground truth.
  50720. */
  50721. useSphericalHarmonics: boolean;
  50722. private _useSpecularGlossinessInputEnergyConservation;
  50723. /**
  50724. * Defines if the material uses energy conservation, when the specular workflow is active.
  50725. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50726. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50727. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50728. */
  50729. useSpecularGlossinessInputEnergyConservation: boolean;
  50730. /** @hidden */
  50731. private _internalMarkAllSubMeshesAsMiscDirty;
  50732. /** @hidden */
  50733. _markAllSubMeshesAsMiscDirty(): void;
  50734. /**
  50735. * Instantiate a new istance of clear coat configuration.
  50736. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50737. */
  50738. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50739. /**
  50740. * Checks to see if a texture is used in the material.
  50741. * @param defines the list of "defines" to update.
  50742. */
  50743. prepareDefines(defines: IMaterialBRDFDefines): void;
  50744. /**
  50745. * Get the current class name of the texture useful for serialization or dynamic coding.
  50746. * @returns "PBRClearCoatConfiguration"
  50747. */
  50748. getClassName(): string;
  50749. /**
  50750. * Makes a duplicate of the current configuration into another one.
  50751. * @param brdfConfiguration define the config where to copy the info
  50752. */
  50753. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50754. /**
  50755. * Serializes this BRDF configuration.
  50756. * @returns - An object with the serialized config.
  50757. */
  50758. serialize(): any;
  50759. /**
  50760. * Parses a anisotropy Configuration from a serialized object.
  50761. * @param source - Serialized object.
  50762. * @param scene Defines the scene we are parsing for
  50763. * @param rootUrl Defines the rootUrl to load from
  50764. */
  50765. parse(source: any, scene: Scene, rootUrl: string): void;
  50766. }
  50767. }
  50768. declare module BABYLON {
  50769. /**
  50770. * @hidden
  50771. */
  50772. export interface IMaterialSheenDefines {
  50773. SHEEN: boolean;
  50774. SHEEN_TEXTURE: boolean;
  50775. SHEEN_TEXTUREDIRECTUV: number;
  50776. SHEEN_LINKWITHALBEDO: boolean;
  50777. SHEEN_ROUGHNESS: boolean;
  50778. SHEEN_ALBEDOSCALING: boolean;
  50779. /** @hidden */
  50780. _areTexturesDirty: boolean;
  50781. }
  50782. /**
  50783. * Define the code related to the Sheen parameters of the pbr material.
  50784. */
  50785. export class PBRSheenConfiguration {
  50786. private _isEnabled;
  50787. /**
  50788. * Defines if the material uses sheen.
  50789. */
  50790. isEnabled: boolean;
  50791. private _linkSheenWithAlbedo;
  50792. /**
  50793. * Defines if the sheen is linked to the sheen color.
  50794. */
  50795. linkSheenWithAlbedo: boolean;
  50796. /**
  50797. * Defines the sheen intensity.
  50798. */
  50799. intensity: number;
  50800. /**
  50801. * Defines the sheen color.
  50802. */
  50803. color: Color3;
  50804. private _texture;
  50805. /**
  50806. * Stores the sheen tint values in a texture.
  50807. * rgb is tint
  50808. * a is a intensity
  50809. */
  50810. texture: Nullable<BaseTexture>;
  50811. private _roughness;
  50812. /**
  50813. * Defines the sheen roughness.
  50814. * It is not taken into account if linkSheenWithAlbedo is true.
  50815. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50816. */
  50817. roughness: Nullable<number>;
  50818. private _albedoScaling;
  50819. /**
  50820. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50821. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50822. * making it easier to setup and tweak the effect
  50823. */
  50824. albedoScaling: boolean;
  50825. /** @hidden */
  50826. private _internalMarkAllSubMeshesAsTexturesDirty;
  50827. /** @hidden */
  50828. _markAllSubMeshesAsTexturesDirty(): void;
  50829. /**
  50830. * Instantiate a new istance of clear coat configuration.
  50831. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50832. */
  50833. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50834. /**
  50835. * Specifies that the submesh is ready to be used.
  50836. * @param defines the list of "defines" to update.
  50837. * @param scene defines the scene the material belongs to.
  50838. * @returns - boolean indicating that the submesh is ready or not.
  50839. */
  50840. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50841. /**
  50842. * Checks to see if a texture is used in the material.
  50843. * @param defines the list of "defines" to update.
  50844. * @param scene defines the scene the material belongs to.
  50845. */
  50846. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50847. /**
  50848. * Binds the material data.
  50849. * @param uniformBuffer defines the Uniform buffer to fill in.
  50850. * @param scene defines the scene the material belongs to.
  50851. * @param isFrozen defines wether the material is frozen or not.
  50852. */
  50853. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50854. /**
  50855. * Checks to see if a texture is used in the material.
  50856. * @param texture - Base texture to use.
  50857. * @returns - Boolean specifying if a texture is used in the material.
  50858. */
  50859. hasTexture(texture: BaseTexture): boolean;
  50860. /**
  50861. * Returns an array of the actively used textures.
  50862. * @param activeTextures Array of BaseTextures
  50863. */
  50864. getActiveTextures(activeTextures: BaseTexture[]): void;
  50865. /**
  50866. * Returns the animatable textures.
  50867. * @param animatables Array of animatable textures.
  50868. */
  50869. getAnimatables(animatables: IAnimatable[]): void;
  50870. /**
  50871. * Disposes the resources of the material.
  50872. * @param forceDisposeTextures - Forces the disposal of all textures.
  50873. */
  50874. dispose(forceDisposeTextures?: boolean): void;
  50875. /**
  50876. * Get the current class name of the texture useful for serialization or dynamic coding.
  50877. * @returns "PBRSheenConfiguration"
  50878. */
  50879. getClassName(): string;
  50880. /**
  50881. * Add fallbacks to the effect fallbacks list.
  50882. * @param defines defines the Base texture to use.
  50883. * @param fallbacks defines the current fallback list.
  50884. * @param currentRank defines the current fallback rank.
  50885. * @returns the new fallback rank.
  50886. */
  50887. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50888. /**
  50889. * Add the required uniforms to the current list.
  50890. * @param uniforms defines the current uniform list.
  50891. */
  50892. static AddUniforms(uniforms: string[]): void;
  50893. /**
  50894. * Add the required uniforms to the current buffer.
  50895. * @param uniformBuffer defines the current uniform buffer.
  50896. */
  50897. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50898. /**
  50899. * Add the required samplers to the current list.
  50900. * @param samplers defines the current sampler list.
  50901. */
  50902. static AddSamplers(samplers: string[]): void;
  50903. /**
  50904. * Makes a duplicate of the current configuration into another one.
  50905. * @param sheenConfiguration define the config where to copy the info
  50906. */
  50907. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50908. /**
  50909. * Serializes this BRDF configuration.
  50910. * @returns - An object with the serialized config.
  50911. */
  50912. serialize(): any;
  50913. /**
  50914. * Parses a anisotropy Configuration from a serialized object.
  50915. * @param source - Serialized object.
  50916. * @param scene Defines the scene we are parsing for
  50917. * @param rootUrl Defines the rootUrl to load from
  50918. */
  50919. parse(source: any, scene: Scene, rootUrl: string): void;
  50920. }
  50921. }
  50922. declare module BABYLON {
  50923. /**
  50924. * @hidden
  50925. */
  50926. export interface IMaterialSubSurfaceDefines {
  50927. SUBSURFACE: boolean;
  50928. SS_REFRACTION: boolean;
  50929. SS_TRANSLUCENCY: boolean;
  50930. SS_SCATERRING: boolean;
  50931. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50932. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50933. SS_REFRACTIONMAP_3D: boolean;
  50934. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50935. SS_LODINREFRACTIONALPHA: boolean;
  50936. SS_GAMMAREFRACTION: boolean;
  50937. SS_RGBDREFRACTION: boolean;
  50938. SS_LINEARSPECULARREFRACTION: boolean;
  50939. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50940. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50941. /** @hidden */
  50942. _areTexturesDirty: boolean;
  50943. }
  50944. /**
  50945. * Define the code related to the sub surface parameters of the pbr material.
  50946. */
  50947. export class PBRSubSurfaceConfiguration {
  50948. private _isRefractionEnabled;
  50949. /**
  50950. * Defines if the refraction is enabled in the material.
  50951. */
  50952. isRefractionEnabled: boolean;
  50953. private _isTranslucencyEnabled;
  50954. /**
  50955. * Defines if the translucency is enabled in the material.
  50956. */
  50957. isTranslucencyEnabled: boolean;
  50958. private _isScatteringEnabled;
  50959. /**
  50960. * Defines the refraction intensity of the material.
  50961. * The refraction when enabled replaces the Diffuse part of the material.
  50962. * The intensity helps transitionning between diffuse and refraction.
  50963. */
  50964. refractionIntensity: number;
  50965. /**
  50966. * Defines the translucency intensity of the material.
  50967. * When translucency has been enabled, this defines how much of the "translucency"
  50968. * is addded to the diffuse part of the material.
  50969. */
  50970. translucencyIntensity: number;
  50971. /**
  50972. * Defines the scattering intensity of the material.
  50973. * When scattering has been enabled, this defines how much of the "scattered light"
  50974. * is addded to the diffuse part of the material.
  50975. */
  50976. scatteringIntensity: number;
  50977. private _thicknessTexture;
  50978. /**
  50979. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50980. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50981. * 0 would mean minimumThickness
  50982. * 1 would mean maximumThickness
  50983. * The other channels might be use as a mask to vary the different effects intensity.
  50984. */
  50985. thicknessTexture: Nullable<BaseTexture>;
  50986. private _refractionTexture;
  50987. /**
  50988. * Defines the texture to use for refraction.
  50989. */
  50990. refractionTexture: Nullable<BaseTexture>;
  50991. private _indexOfRefraction;
  50992. /**
  50993. * Defines the index of refraction used in the material.
  50994. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50995. */
  50996. indexOfRefraction: number;
  50997. private _invertRefractionY;
  50998. /**
  50999. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51000. */
  51001. invertRefractionY: boolean;
  51002. private _linkRefractionWithTransparency;
  51003. /**
  51004. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51005. * Materials half opaque for instance using refraction could benefit from this control.
  51006. */
  51007. linkRefractionWithTransparency: boolean;
  51008. /**
  51009. * Defines the minimum thickness stored in the thickness map.
  51010. * If no thickness map is defined, this value will be used to simulate thickness.
  51011. */
  51012. minimumThickness: number;
  51013. /**
  51014. * Defines the maximum thickness stored in the thickness map.
  51015. */
  51016. maximumThickness: number;
  51017. /**
  51018. * Defines the volume tint of the material.
  51019. * This is used for both translucency and scattering.
  51020. */
  51021. tintColor: Color3;
  51022. /**
  51023. * Defines the distance at which the tint color should be found in the media.
  51024. * This is used for refraction only.
  51025. */
  51026. tintColorAtDistance: number;
  51027. /**
  51028. * Defines how far each channel transmit through the media.
  51029. * It is defined as a color to simplify it selection.
  51030. */
  51031. diffusionDistance: Color3;
  51032. private _useMaskFromThicknessTexture;
  51033. /**
  51034. * Stores the intensity of the different subsurface effects in the thickness texture.
  51035. * * the green channel is the translucency intensity.
  51036. * * the blue channel is the scattering intensity.
  51037. * * the alpha channel is the refraction intensity.
  51038. */
  51039. useMaskFromThicknessTexture: boolean;
  51040. /** @hidden */
  51041. private _internalMarkAllSubMeshesAsTexturesDirty;
  51042. /** @hidden */
  51043. _markAllSubMeshesAsTexturesDirty(): void;
  51044. /**
  51045. * Instantiate a new istance of sub surface configuration.
  51046. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51047. */
  51048. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51049. /**
  51050. * Gets wehter the submesh is ready to be used or not.
  51051. * @param defines the list of "defines" to update.
  51052. * @param scene defines the scene the material belongs to.
  51053. * @returns - boolean indicating that the submesh is ready or not.
  51054. */
  51055. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51056. /**
  51057. * Checks to see if a texture is used in the material.
  51058. * @param defines the list of "defines" to update.
  51059. * @param scene defines the scene to the material belongs to.
  51060. */
  51061. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51062. /**
  51063. * Binds the material data.
  51064. * @param uniformBuffer defines the Uniform buffer to fill in.
  51065. * @param scene defines the scene the material belongs to.
  51066. * @param engine defines the engine the material belongs to.
  51067. * @param isFrozen defines wether the material is frozen or not.
  51068. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51069. */
  51070. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51071. /**
  51072. * Unbinds the material from the mesh.
  51073. * @param activeEffect defines the effect that should be unbound from.
  51074. * @returns true if unbound, otherwise false
  51075. */
  51076. unbind(activeEffect: Effect): boolean;
  51077. /**
  51078. * Returns the texture used for refraction or null if none is used.
  51079. * @param scene defines the scene the material belongs to.
  51080. * @returns - Refraction texture if present. If no refraction texture and refraction
  51081. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51082. */
  51083. private _getRefractionTexture;
  51084. /**
  51085. * Returns true if alpha blending should be disabled.
  51086. */
  51087. get disableAlphaBlending(): boolean;
  51088. /**
  51089. * Fills the list of render target textures.
  51090. * @param renderTargets the list of render targets to update
  51091. */
  51092. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51093. /**
  51094. * Checks to see if a texture is used in the material.
  51095. * @param texture - Base texture to use.
  51096. * @returns - Boolean specifying if a texture is used in the material.
  51097. */
  51098. hasTexture(texture: BaseTexture): boolean;
  51099. /**
  51100. * Gets a boolean indicating that current material needs to register RTT
  51101. * @returns true if this uses a render target otherwise false.
  51102. */
  51103. hasRenderTargetTextures(): boolean;
  51104. /**
  51105. * Returns an array of the actively used textures.
  51106. * @param activeTextures Array of BaseTextures
  51107. */
  51108. getActiveTextures(activeTextures: BaseTexture[]): void;
  51109. /**
  51110. * Returns the animatable textures.
  51111. * @param animatables Array of animatable textures.
  51112. */
  51113. getAnimatables(animatables: IAnimatable[]): void;
  51114. /**
  51115. * Disposes the resources of the material.
  51116. * @param forceDisposeTextures - Forces the disposal of all textures.
  51117. */
  51118. dispose(forceDisposeTextures?: boolean): void;
  51119. /**
  51120. * Get the current class name of the texture useful for serialization or dynamic coding.
  51121. * @returns "PBRSubSurfaceConfiguration"
  51122. */
  51123. getClassName(): string;
  51124. /**
  51125. * Add fallbacks to the effect fallbacks list.
  51126. * @param defines defines the Base texture to use.
  51127. * @param fallbacks defines the current fallback list.
  51128. * @param currentRank defines the current fallback rank.
  51129. * @returns the new fallback rank.
  51130. */
  51131. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51132. /**
  51133. * Add the required uniforms to the current list.
  51134. * @param uniforms defines the current uniform list.
  51135. */
  51136. static AddUniforms(uniforms: string[]): void;
  51137. /**
  51138. * Add the required samplers to the current list.
  51139. * @param samplers defines the current sampler list.
  51140. */
  51141. static AddSamplers(samplers: string[]): void;
  51142. /**
  51143. * Add the required uniforms to the current buffer.
  51144. * @param uniformBuffer defines the current uniform buffer.
  51145. */
  51146. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51147. /**
  51148. * Makes a duplicate of the current configuration into another one.
  51149. * @param configuration define the config where to copy the info
  51150. */
  51151. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51152. /**
  51153. * Serializes this Sub Surface configuration.
  51154. * @returns - An object with the serialized config.
  51155. */
  51156. serialize(): any;
  51157. /**
  51158. * Parses a anisotropy Configuration from a serialized object.
  51159. * @param source - Serialized object.
  51160. * @param scene Defines the scene we are parsing for
  51161. * @param rootUrl Defines the rootUrl to load from
  51162. */
  51163. parse(source: any, scene: Scene, rootUrl: string): void;
  51164. }
  51165. }
  51166. declare module BABYLON {
  51167. /** @hidden */
  51168. export var pbrFragmentDeclaration: {
  51169. name: string;
  51170. shader: string;
  51171. };
  51172. }
  51173. declare module BABYLON {
  51174. /** @hidden */
  51175. export var pbrUboDeclaration: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module BABYLON {
  51181. /** @hidden */
  51182. export var pbrFragmentExtraDeclaration: {
  51183. name: string;
  51184. shader: string;
  51185. };
  51186. }
  51187. declare module BABYLON {
  51188. /** @hidden */
  51189. export var pbrFragmentSamplersDeclaration: {
  51190. name: string;
  51191. shader: string;
  51192. };
  51193. }
  51194. declare module BABYLON {
  51195. /** @hidden */
  51196. export var pbrHelperFunctions: {
  51197. name: string;
  51198. shader: string;
  51199. };
  51200. }
  51201. declare module BABYLON {
  51202. /** @hidden */
  51203. export var harmonicsFunctions: {
  51204. name: string;
  51205. shader: string;
  51206. };
  51207. }
  51208. declare module BABYLON {
  51209. /** @hidden */
  51210. export var pbrDirectLightingSetupFunctions: {
  51211. name: string;
  51212. shader: string;
  51213. };
  51214. }
  51215. declare module BABYLON {
  51216. /** @hidden */
  51217. export var pbrDirectLightingFalloffFunctions: {
  51218. name: string;
  51219. shader: string;
  51220. };
  51221. }
  51222. declare module BABYLON {
  51223. /** @hidden */
  51224. export var pbrBRDFFunctions: {
  51225. name: string;
  51226. shader: string;
  51227. };
  51228. }
  51229. declare module BABYLON {
  51230. /** @hidden */
  51231. export var pbrDirectLightingFunctions: {
  51232. name: string;
  51233. shader: string;
  51234. };
  51235. }
  51236. declare module BABYLON {
  51237. /** @hidden */
  51238. export var pbrIBLFunctions: {
  51239. name: string;
  51240. shader: string;
  51241. };
  51242. }
  51243. declare module BABYLON {
  51244. /** @hidden */
  51245. export var pbrBlockAlbedoOpacity: {
  51246. name: string;
  51247. shader: string;
  51248. };
  51249. }
  51250. declare module BABYLON {
  51251. /** @hidden */
  51252. export var pbrBlockReflectivity: {
  51253. name: string;
  51254. shader: string;
  51255. };
  51256. }
  51257. declare module BABYLON {
  51258. /** @hidden */
  51259. export var pbrBlockAmbientOcclusion: {
  51260. name: string;
  51261. shader: string;
  51262. };
  51263. }
  51264. declare module BABYLON {
  51265. /** @hidden */
  51266. export var pbrBlockAlphaFresnel: {
  51267. name: string;
  51268. shader: string;
  51269. };
  51270. }
  51271. declare module BABYLON {
  51272. /** @hidden */
  51273. export var pbrBlockAnisotropic: {
  51274. name: string;
  51275. shader: string;
  51276. };
  51277. }
  51278. declare module BABYLON {
  51279. /** @hidden */
  51280. export var pbrBlockReflection: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module BABYLON {
  51286. /** @hidden */
  51287. export var pbrBlockSheen: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module BABYLON {
  51293. /** @hidden */
  51294. export var pbrBlockClearcoat: {
  51295. name: string;
  51296. shader: string;
  51297. };
  51298. }
  51299. declare module BABYLON {
  51300. /** @hidden */
  51301. export var pbrBlockSubSurface: {
  51302. name: string;
  51303. shader: string;
  51304. };
  51305. }
  51306. declare module BABYLON {
  51307. /** @hidden */
  51308. export var pbrBlockNormalGeometric: {
  51309. name: string;
  51310. shader: string;
  51311. };
  51312. }
  51313. declare module BABYLON {
  51314. /** @hidden */
  51315. export var pbrBlockNormalFinal: {
  51316. name: string;
  51317. shader: string;
  51318. };
  51319. }
  51320. declare module BABYLON {
  51321. /** @hidden */
  51322. export var pbrBlockGeometryInfo: {
  51323. name: string;
  51324. shader: string;
  51325. };
  51326. }
  51327. declare module BABYLON {
  51328. /** @hidden */
  51329. export var pbrBlockReflectance0: {
  51330. name: string;
  51331. shader: string;
  51332. };
  51333. }
  51334. declare module BABYLON {
  51335. /** @hidden */
  51336. export var pbrBlockReflectance: {
  51337. name: string;
  51338. shader: string;
  51339. };
  51340. }
  51341. declare module BABYLON {
  51342. /** @hidden */
  51343. export var pbrBlockDirectLighting: {
  51344. name: string;
  51345. shader: string;
  51346. };
  51347. }
  51348. declare module BABYLON {
  51349. /** @hidden */
  51350. export var pbrBlockFinalLitComponents: {
  51351. name: string;
  51352. shader: string;
  51353. };
  51354. }
  51355. declare module BABYLON {
  51356. /** @hidden */
  51357. export var pbrBlockFinalUnlitComponents: {
  51358. name: string;
  51359. shader: string;
  51360. };
  51361. }
  51362. declare module BABYLON {
  51363. /** @hidden */
  51364. export var pbrBlockFinalColorComposition: {
  51365. name: string;
  51366. shader: string;
  51367. };
  51368. }
  51369. declare module BABYLON {
  51370. /** @hidden */
  51371. export var pbrBlockImageProcessing: {
  51372. name: string;
  51373. shader: string;
  51374. };
  51375. }
  51376. declare module BABYLON {
  51377. /** @hidden */
  51378. export var pbrDebug: {
  51379. name: string;
  51380. shader: string;
  51381. };
  51382. }
  51383. declare module BABYLON {
  51384. /** @hidden */
  51385. export var pbrPixelShader: {
  51386. name: string;
  51387. shader: string;
  51388. };
  51389. }
  51390. declare module BABYLON {
  51391. /** @hidden */
  51392. export var pbrVertexDeclaration: {
  51393. name: string;
  51394. shader: string;
  51395. };
  51396. }
  51397. declare module BABYLON {
  51398. /** @hidden */
  51399. export var pbrVertexShader: {
  51400. name: string;
  51401. shader: string;
  51402. };
  51403. }
  51404. declare module BABYLON {
  51405. /**
  51406. * Manages the defines for the PBR Material.
  51407. * @hidden
  51408. */
  51409. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51410. PBR: boolean;
  51411. MAINUV1: boolean;
  51412. MAINUV2: boolean;
  51413. UV1: boolean;
  51414. UV2: boolean;
  51415. ALBEDO: boolean;
  51416. GAMMAALBEDO: boolean;
  51417. ALBEDODIRECTUV: number;
  51418. VERTEXCOLOR: boolean;
  51419. AMBIENT: boolean;
  51420. AMBIENTDIRECTUV: number;
  51421. AMBIENTINGRAYSCALE: boolean;
  51422. OPACITY: boolean;
  51423. VERTEXALPHA: boolean;
  51424. OPACITYDIRECTUV: number;
  51425. OPACITYRGB: boolean;
  51426. ALPHATEST: boolean;
  51427. DEPTHPREPASS: boolean;
  51428. ALPHABLEND: boolean;
  51429. ALPHAFROMALBEDO: boolean;
  51430. ALPHATESTVALUE: string;
  51431. SPECULAROVERALPHA: boolean;
  51432. RADIANCEOVERALPHA: boolean;
  51433. ALPHAFRESNEL: boolean;
  51434. LINEARALPHAFRESNEL: boolean;
  51435. PREMULTIPLYALPHA: boolean;
  51436. EMISSIVE: boolean;
  51437. EMISSIVEDIRECTUV: number;
  51438. REFLECTIVITY: boolean;
  51439. REFLECTIVITYDIRECTUV: number;
  51440. SPECULARTERM: boolean;
  51441. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51442. MICROSURFACEAUTOMATIC: boolean;
  51443. LODBASEDMICROSFURACE: boolean;
  51444. MICROSURFACEMAP: boolean;
  51445. MICROSURFACEMAPDIRECTUV: number;
  51446. METALLICWORKFLOW: boolean;
  51447. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51448. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51449. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51450. AOSTOREINMETALMAPRED: boolean;
  51451. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51452. ENVIRONMENTBRDF: boolean;
  51453. ENVIRONMENTBRDF_RGBD: boolean;
  51454. NORMAL: boolean;
  51455. TANGENT: boolean;
  51456. BUMP: boolean;
  51457. BUMPDIRECTUV: number;
  51458. OBJECTSPACE_NORMALMAP: boolean;
  51459. PARALLAX: boolean;
  51460. PARALLAXOCCLUSION: boolean;
  51461. NORMALXYSCALE: boolean;
  51462. LIGHTMAP: boolean;
  51463. LIGHTMAPDIRECTUV: number;
  51464. USELIGHTMAPASSHADOWMAP: boolean;
  51465. GAMMALIGHTMAP: boolean;
  51466. RGBDLIGHTMAP: boolean;
  51467. REFLECTION: boolean;
  51468. REFLECTIONMAP_3D: boolean;
  51469. REFLECTIONMAP_SPHERICAL: boolean;
  51470. REFLECTIONMAP_PLANAR: boolean;
  51471. REFLECTIONMAP_CUBIC: boolean;
  51472. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51473. REFLECTIONMAP_PROJECTION: boolean;
  51474. REFLECTIONMAP_SKYBOX: boolean;
  51475. REFLECTIONMAP_EXPLICIT: boolean;
  51476. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51477. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51478. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51479. INVERTCUBICMAP: boolean;
  51480. USESPHERICALFROMREFLECTIONMAP: boolean;
  51481. USEIRRADIANCEMAP: boolean;
  51482. SPHERICAL_HARMONICS: boolean;
  51483. USESPHERICALINVERTEX: boolean;
  51484. REFLECTIONMAP_OPPOSITEZ: boolean;
  51485. LODINREFLECTIONALPHA: boolean;
  51486. GAMMAREFLECTION: boolean;
  51487. RGBDREFLECTION: boolean;
  51488. LINEARSPECULARREFLECTION: boolean;
  51489. RADIANCEOCCLUSION: boolean;
  51490. HORIZONOCCLUSION: boolean;
  51491. INSTANCES: boolean;
  51492. NUM_BONE_INFLUENCERS: number;
  51493. BonesPerMesh: number;
  51494. BONETEXTURE: boolean;
  51495. NONUNIFORMSCALING: boolean;
  51496. MORPHTARGETS: boolean;
  51497. MORPHTARGETS_NORMAL: boolean;
  51498. MORPHTARGETS_TANGENT: boolean;
  51499. MORPHTARGETS_UV: boolean;
  51500. NUM_MORPH_INFLUENCERS: number;
  51501. IMAGEPROCESSING: boolean;
  51502. VIGNETTE: boolean;
  51503. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51504. VIGNETTEBLENDMODEOPAQUE: boolean;
  51505. TONEMAPPING: boolean;
  51506. TONEMAPPING_ACES: boolean;
  51507. CONTRAST: boolean;
  51508. COLORCURVES: boolean;
  51509. COLORGRADING: boolean;
  51510. COLORGRADING3D: boolean;
  51511. SAMPLER3DGREENDEPTH: boolean;
  51512. SAMPLER3DBGRMAP: boolean;
  51513. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51514. EXPOSURE: boolean;
  51515. MULTIVIEW: boolean;
  51516. USEPHYSICALLIGHTFALLOFF: boolean;
  51517. USEGLTFLIGHTFALLOFF: boolean;
  51518. TWOSIDEDLIGHTING: boolean;
  51519. SHADOWFLOAT: boolean;
  51520. CLIPPLANE: boolean;
  51521. CLIPPLANE2: boolean;
  51522. CLIPPLANE3: boolean;
  51523. CLIPPLANE4: boolean;
  51524. CLIPPLANE5: boolean;
  51525. CLIPPLANE6: boolean;
  51526. POINTSIZE: boolean;
  51527. FOG: boolean;
  51528. LOGARITHMICDEPTH: boolean;
  51529. FORCENORMALFORWARD: boolean;
  51530. SPECULARAA: boolean;
  51531. CLEARCOAT: boolean;
  51532. CLEARCOAT_DEFAULTIOR: boolean;
  51533. CLEARCOAT_TEXTURE: boolean;
  51534. CLEARCOAT_TEXTUREDIRECTUV: number;
  51535. CLEARCOAT_BUMP: boolean;
  51536. CLEARCOAT_BUMPDIRECTUV: number;
  51537. CLEARCOAT_TINT: boolean;
  51538. CLEARCOAT_TINT_TEXTURE: boolean;
  51539. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51540. ANISOTROPIC: boolean;
  51541. ANISOTROPIC_TEXTURE: boolean;
  51542. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51543. BRDF_V_HEIGHT_CORRELATED: boolean;
  51544. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51545. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51546. SHEEN: boolean;
  51547. SHEEN_TEXTURE: boolean;
  51548. SHEEN_TEXTUREDIRECTUV: number;
  51549. SHEEN_LINKWITHALBEDO: boolean;
  51550. SHEEN_ROUGHNESS: boolean;
  51551. SHEEN_ALBEDOSCALING: boolean;
  51552. SUBSURFACE: boolean;
  51553. SS_REFRACTION: boolean;
  51554. SS_TRANSLUCENCY: boolean;
  51555. SS_SCATERRING: boolean;
  51556. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51557. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51558. SS_REFRACTIONMAP_3D: boolean;
  51559. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51560. SS_LODINREFRACTIONALPHA: boolean;
  51561. SS_GAMMAREFRACTION: boolean;
  51562. SS_RGBDREFRACTION: boolean;
  51563. SS_LINEARSPECULARREFRACTION: boolean;
  51564. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51565. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51566. UNLIT: boolean;
  51567. DEBUGMODE: number;
  51568. /**
  51569. * Initializes the PBR Material defines.
  51570. */
  51571. constructor();
  51572. /**
  51573. * Resets the PBR Material defines.
  51574. */
  51575. reset(): void;
  51576. }
  51577. /**
  51578. * The Physically based material base class of BJS.
  51579. *
  51580. * This offers the main features of a standard PBR material.
  51581. * For more information, please refer to the documentation :
  51582. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51583. */
  51584. export abstract class PBRBaseMaterial extends PushMaterial {
  51585. /**
  51586. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51587. */
  51588. static readonly PBRMATERIAL_OPAQUE: number;
  51589. /**
  51590. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51591. */
  51592. static readonly PBRMATERIAL_ALPHATEST: number;
  51593. /**
  51594. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51595. */
  51596. static readonly PBRMATERIAL_ALPHABLEND: number;
  51597. /**
  51598. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51599. * They are also discarded below the alpha cutoff threshold to improve performances.
  51600. */
  51601. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51602. /**
  51603. * Defines the default value of how much AO map is occluding the analytical lights
  51604. * (point spot...).
  51605. */
  51606. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51607. /**
  51608. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51609. */
  51610. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51611. /**
  51612. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51613. * to enhance interoperability with other engines.
  51614. */
  51615. static readonly LIGHTFALLOFF_GLTF: number;
  51616. /**
  51617. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51618. * to enhance interoperability with other materials.
  51619. */
  51620. static readonly LIGHTFALLOFF_STANDARD: number;
  51621. /**
  51622. * Intensity of the direct lights e.g. the four lights available in your scene.
  51623. * This impacts both the direct diffuse and specular highlights.
  51624. */
  51625. protected _directIntensity: number;
  51626. /**
  51627. * Intensity of the emissive part of the material.
  51628. * This helps controlling the emissive effect without modifying the emissive color.
  51629. */
  51630. protected _emissiveIntensity: number;
  51631. /**
  51632. * Intensity of the environment e.g. how much the environment will light the object
  51633. * either through harmonics for rough material or through the refelction for shiny ones.
  51634. */
  51635. protected _environmentIntensity: number;
  51636. /**
  51637. * This is a special control allowing the reduction of the specular highlights coming from the
  51638. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51639. */
  51640. protected _specularIntensity: number;
  51641. /**
  51642. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51643. */
  51644. private _lightingInfos;
  51645. /**
  51646. * Debug Control allowing disabling the bump map on this material.
  51647. */
  51648. protected _disableBumpMap: boolean;
  51649. /**
  51650. * AKA Diffuse Texture in standard nomenclature.
  51651. */
  51652. protected _albedoTexture: Nullable<BaseTexture>;
  51653. /**
  51654. * AKA Occlusion Texture in other nomenclature.
  51655. */
  51656. protected _ambientTexture: Nullable<BaseTexture>;
  51657. /**
  51658. * AKA Occlusion Texture Intensity in other nomenclature.
  51659. */
  51660. protected _ambientTextureStrength: number;
  51661. /**
  51662. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51663. * 1 means it completely occludes it
  51664. * 0 mean it has no impact
  51665. */
  51666. protected _ambientTextureImpactOnAnalyticalLights: number;
  51667. /**
  51668. * Stores the alpha values in a texture.
  51669. */
  51670. protected _opacityTexture: Nullable<BaseTexture>;
  51671. /**
  51672. * Stores the reflection values in a texture.
  51673. */
  51674. protected _reflectionTexture: Nullable<BaseTexture>;
  51675. /**
  51676. * Stores the emissive values in a texture.
  51677. */
  51678. protected _emissiveTexture: Nullable<BaseTexture>;
  51679. /**
  51680. * AKA Specular texture in other nomenclature.
  51681. */
  51682. protected _reflectivityTexture: Nullable<BaseTexture>;
  51683. /**
  51684. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51685. */
  51686. protected _metallicTexture: Nullable<BaseTexture>;
  51687. /**
  51688. * Specifies the metallic scalar of the metallic/roughness workflow.
  51689. * Can also be used to scale the metalness values of the metallic texture.
  51690. */
  51691. protected _metallic: Nullable<number>;
  51692. /**
  51693. * Specifies the roughness scalar of the metallic/roughness workflow.
  51694. * Can also be used to scale the roughness values of the metallic texture.
  51695. */
  51696. protected _roughness: Nullable<number>;
  51697. /**
  51698. * Specifies the an F0 factor to help configuring the material F0.
  51699. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51700. * to 0.5 the previously hard coded value stays the same.
  51701. * Can also be used to scale the F0 values of the metallic texture.
  51702. */
  51703. protected _metallicF0Factor: number;
  51704. /**
  51705. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51706. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51707. * your expectation as it multiplies with the texture data.
  51708. */
  51709. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51710. /**
  51711. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51712. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51713. */
  51714. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51715. /**
  51716. * Stores surface normal data used to displace a mesh in a texture.
  51717. */
  51718. protected _bumpTexture: Nullable<BaseTexture>;
  51719. /**
  51720. * Stores the pre-calculated light information of a mesh in a texture.
  51721. */
  51722. protected _lightmapTexture: Nullable<BaseTexture>;
  51723. /**
  51724. * The color of a material in ambient lighting.
  51725. */
  51726. protected _ambientColor: Color3;
  51727. /**
  51728. * AKA Diffuse Color in other nomenclature.
  51729. */
  51730. protected _albedoColor: Color3;
  51731. /**
  51732. * AKA Specular Color in other nomenclature.
  51733. */
  51734. protected _reflectivityColor: Color3;
  51735. /**
  51736. * The color applied when light is reflected from a material.
  51737. */
  51738. protected _reflectionColor: Color3;
  51739. /**
  51740. * The color applied when light is emitted from a material.
  51741. */
  51742. protected _emissiveColor: Color3;
  51743. /**
  51744. * AKA Glossiness in other nomenclature.
  51745. */
  51746. protected _microSurface: number;
  51747. /**
  51748. * Specifies that the material will use the light map as a show map.
  51749. */
  51750. protected _useLightmapAsShadowmap: boolean;
  51751. /**
  51752. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51753. * makes the reflect vector face the model (under horizon).
  51754. */
  51755. protected _useHorizonOcclusion: boolean;
  51756. /**
  51757. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51758. * too much the area relying on ambient texture to define their ambient occlusion.
  51759. */
  51760. protected _useRadianceOcclusion: boolean;
  51761. /**
  51762. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51763. */
  51764. protected _useAlphaFromAlbedoTexture: boolean;
  51765. /**
  51766. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51767. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51768. */
  51769. protected _useSpecularOverAlpha: boolean;
  51770. /**
  51771. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51772. */
  51773. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51774. /**
  51775. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51776. */
  51777. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51778. /**
  51779. * Specifies if the metallic texture contains the roughness information in its green channel.
  51780. */
  51781. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51782. /**
  51783. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51784. */
  51785. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51786. /**
  51787. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51788. */
  51789. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51790. /**
  51791. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51792. */
  51793. protected _useAmbientInGrayScale: boolean;
  51794. /**
  51795. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51796. * The material will try to infer what glossiness each pixel should be.
  51797. */
  51798. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51799. /**
  51800. * Defines the falloff type used in this material.
  51801. * It by default is Physical.
  51802. */
  51803. protected _lightFalloff: number;
  51804. /**
  51805. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51806. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51807. */
  51808. protected _useRadianceOverAlpha: boolean;
  51809. /**
  51810. * Allows using an object space normal map (instead of tangent space).
  51811. */
  51812. protected _useObjectSpaceNormalMap: boolean;
  51813. /**
  51814. * Allows using the bump map in parallax mode.
  51815. */
  51816. protected _useParallax: boolean;
  51817. /**
  51818. * Allows using the bump map in parallax occlusion mode.
  51819. */
  51820. protected _useParallaxOcclusion: boolean;
  51821. /**
  51822. * Controls the scale bias of the parallax mode.
  51823. */
  51824. protected _parallaxScaleBias: number;
  51825. /**
  51826. * If sets to true, disables all the lights affecting the material.
  51827. */
  51828. protected _disableLighting: boolean;
  51829. /**
  51830. * Number of Simultaneous lights allowed on the material.
  51831. */
  51832. protected _maxSimultaneousLights: number;
  51833. /**
  51834. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51835. */
  51836. protected _invertNormalMapX: boolean;
  51837. /**
  51838. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51839. */
  51840. protected _invertNormalMapY: boolean;
  51841. /**
  51842. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51843. */
  51844. protected _twoSidedLighting: boolean;
  51845. /**
  51846. * Defines the alpha limits in alpha test mode.
  51847. */
  51848. protected _alphaCutOff: number;
  51849. /**
  51850. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51851. */
  51852. protected _forceAlphaTest: boolean;
  51853. /**
  51854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51855. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51856. */
  51857. protected _useAlphaFresnel: boolean;
  51858. /**
  51859. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51860. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51861. */
  51862. protected _useLinearAlphaFresnel: boolean;
  51863. /**
  51864. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51865. * from cos thetav and roughness:
  51866. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51867. */
  51868. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51869. /**
  51870. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51871. */
  51872. protected _forceIrradianceInFragment: boolean;
  51873. /**
  51874. * Force normal to face away from face.
  51875. */
  51876. protected _forceNormalForward: boolean;
  51877. /**
  51878. * Enables specular anti aliasing in the PBR shader.
  51879. * It will both interacts on the Geometry for analytical and IBL lighting.
  51880. * It also prefilter the roughness map based on the bump values.
  51881. */
  51882. protected _enableSpecularAntiAliasing: boolean;
  51883. /**
  51884. * Default configuration related to image processing available in the PBR Material.
  51885. */
  51886. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51887. /**
  51888. * Keep track of the image processing observer to allow dispose and replace.
  51889. */
  51890. private _imageProcessingObserver;
  51891. /**
  51892. * Attaches a new image processing configuration to the PBR Material.
  51893. * @param configuration
  51894. */
  51895. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51896. /**
  51897. * Stores the available render targets.
  51898. */
  51899. private _renderTargets;
  51900. /**
  51901. * Sets the global ambient color for the material used in lighting calculations.
  51902. */
  51903. private _globalAmbientColor;
  51904. /**
  51905. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51906. */
  51907. private _useLogarithmicDepth;
  51908. /**
  51909. * If set to true, no lighting calculations will be applied.
  51910. */
  51911. private _unlit;
  51912. private _debugMode;
  51913. /**
  51914. * @hidden
  51915. * This is reserved for the inspector.
  51916. * Defines the material debug mode.
  51917. * It helps seeing only some components of the material while troubleshooting.
  51918. */
  51919. debugMode: number;
  51920. /**
  51921. * @hidden
  51922. * This is reserved for the inspector.
  51923. * Specify from where on screen the debug mode should start.
  51924. * The value goes from -1 (full screen) to 1 (not visible)
  51925. * It helps with side by side comparison against the final render
  51926. * This defaults to -1
  51927. */
  51928. private debugLimit;
  51929. /**
  51930. * @hidden
  51931. * This is reserved for the inspector.
  51932. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51933. * You can use the factor to better multiply the final value.
  51934. */
  51935. private debugFactor;
  51936. /**
  51937. * Defines the clear coat layer parameters for the material.
  51938. */
  51939. readonly clearCoat: PBRClearCoatConfiguration;
  51940. /**
  51941. * Defines the anisotropic parameters for the material.
  51942. */
  51943. readonly anisotropy: PBRAnisotropicConfiguration;
  51944. /**
  51945. * Defines the BRDF parameters for the material.
  51946. */
  51947. readonly brdf: PBRBRDFConfiguration;
  51948. /**
  51949. * Defines the Sheen parameters for the material.
  51950. */
  51951. readonly sheen: PBRSheenConfiguration;
  51952. /**
  51953. * Defines the SubSurface parameters for the material.
  51954. */
  51955. readonly subSurface: PBRSubSurfaceConfiguration;
  51956. /**
  51957. * Custom callback helping to override the default shader used in the material.
  51958. */
  51959. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51960. protected _rebuildInParallel: boolean;
  51961. /**
  51962. * Instantiates a new PBRMaterial instance.
  51963. *
  51964. * @param name The material name
  51965. * @param scene The scene the material will be use in.
  51966. */
  51967. constructor(name: string, scene: Scene);
  51968. /**
  51969. * Gets a boolean indicating that current material needs to register RTT
  51970. */
  51971. get hasRenderTargetTextures(): boolean;
  51972. /**
  51973. * Gets the name of the material class.
  51974. */
  51975. getClassName(): string;
  51976. /**
  51977. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51978. */
  51979. get useLogarithmicDepth(): boolean;
  51980. /**
  51981. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51982. */
  51983. set useLogarithmicDepth(value: boolean);
  51984. /**
  51985. * Returns true if alpha blending should be disabled.
  51986. */
  51987. protected get _disableAlphaBlending(): boolean;
  51988. /**
  51989. * Specifies whether or not this material should be rendered in alpha blend mode.
  51990. */
  51991. needAlphaBlending(): boolean;
  51992. /**
  51993. * Specifies whether or not this material should be rendered in alpha test mode.
  51994. */
  51995. needAlphaTesting(): boolean;
  51996. /**
  51997. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51998. */
  51999. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52000. /**
  52001. * Gets the texture used for the alpha test.
  52002. */
  52003. getAlphaTestTexture(): Nullable<BaseTexture>;
  52004. /**
  52005. * Specifies that the submesh is ready to be used.
  52006. * @param mesh - BJS mesh.
  52007. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52008. * @param useInstances - Specifies that instances should be used.
  52009. * @returns - boolean indicating that the submesh is ready or not.
  52010. */
  52011. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52012. /**
  52013. * Specifies if the material uses metallic roughness workflow.
  52014. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52015. */
  52016. isMetallicWorkflow(): boolean;
  52017. private _prepareEffect;
  52018. private _prepareDefines;
  52019. /**
  52020. * Force shader compilation
  52021. */
  52022. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52023. /**
  52024. * Initializes the uniform buffer layout for the shader.
  52025. */
  52026. buildUniformLayout(): void;
  52027. /**
  52028. * Unbinds the material from the mesh
  52029. */
  52030. unbind(): void;
  52031. /**
  52032. * Binds the submesh data.
  52033. * @param world - The world matrix.
  52034. * @param mesh - The BJS mesh.
  52035. * @param subMesh - A submesh of the BJS mesh.
  52036. */
  52037. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52038. /**
  52039. * Returns the animatable textures.
  52040. * @returns - Array of animatable textures.
  52041. */
  52042. getAnimatables(): IAnimatable[];
  52043. /**
  52044. * Returns the texture used for reflections.
  52045. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52046. */
  52047. private _getReflectionTexture;
  52048. /**
  52049. * Returns an array of the actively used textures.
  52050. * @returns - Array of BaseTextures
  52051. */
  52052. getActiveTextures(): BaseTexture[];
  52053. /**
  52054. * Checks to see if a texture is used in the material.
  52055. * @param texture - Base texture to use.
  52056. * @returns - Boolean specifying if a texture is used in the material.
  52057. */
  52058. hasTexture(texture: BaseTexture): boolean;
  52059. /**
  52060. * Disposes the resources of the material.
  52061. * @param forceDisposeEffect - Forces the disposal of effects.
  52062. * @param forceDisposeTextures - Forces the disposal of all textures.
  52063. */
  52064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52065. }
  52066. }
  52067. declare module BABYLON {
  52068. /**
  52069. * The Physically based material of BJS.
  52070. *
  52071. * This offers the main features of a standard PBR material.
  52072. * For more information, please refer to the documentation :
  52073. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52074. */
  52075. export class PBRMaterial extends PBRBaseMaterial {
  52076. /**
  52077. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52078. */
  52079. static readonly PBRMATERIAL_OPAQUE: number;
  52080. /**
  52081. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52082. */
  52083. static readonly PBRMATERIAL_ALPHATEST: number;
  52084. /**
  52085. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52086. */
  52087. static readonly PBRMATERIAL_ALPHABLEND: number;
  52088. /**
  52089. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52090. * They are also discarded below the alpha cutoff threshold to improve performances.
  52091. */
  52092. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52093. /**
  52094. * Defines the default value of how much AO map is occluding the analytical lights
  52095. * (point spot...).
  52096. */
  52097. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52098. /**
  52099. * Intensity of the direct lights e.g. the four lights available in your scene.
  52100. * This impacts both the direct diffuse and specular highlights.
  52101. */
  52102. directIntensity: number;
  52103. /**
  52104. * Intensity of the emissive part of the material.
  52105. * This helps controlling the emissive effect without modifying the emissive color.
  52106. */
  52107. emissiveIntensity: number;
  52108. /**
  52109. * Intensity of the environment e.g. how much the environment will light the object
  52110. * either through harmonics for rough material or through the refelction for shiny ones.
  52111. */
  52112. environmentIntensity: number;
  52113. /**
  52114. * This is a special control allowing the reduction of the specular highlights coming from the
  52115. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52116. */
  52117. specularIntensity: number;
  52118. /**
  52119. * Debug Control allowing disabling the bump map on this material.
  52120. */
  52121. disableBumpMap: boolean;
  52122. /**
  52123. * AKA Diffuse Texture in standard nomenclature.
  52124. */
  52125. albedoTexture: BaseTexture;
  52126. /**
  52127. * AKA Occlusion Texture in other nomenclature.
  52128. */
  52129. ambientTexture: BaseTexture;
  52130. /**
  52131. * AKA Occlusion Texture Intensity in other nomenclature.
  52132. */
  52133. ambientTextureStrength: number;
  52134. /**
  52135. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52136. * 1 means it completely occludes it
  52137. * 0 mean it has no impact
  52138. */
  52139. ambientTextureImpactOnAnalyticalLights: number;
  52140. /**
  52141. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52142. */
  52143. opacityTexture: BaseTexture;
  52144. /**
  52145. * Stores the reflection values in a texture.
  52146. */
  52147. reflectionTexture: Nullable<BaseTexture>;
  52148. /**
  52149. * Stores the emissive values in a texture.
  52150. */
  52151. emissiveTexture: BaseTexture;
  52152. /**
  52153. * AKA Specular texture in other nomenclature.
  52154. */
  52155. reflectivityTexture: BaseTexture;
  52156. /**
  52157. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52158. */
  52159. metallicTexture: BaseTexture;
  52160. /**
  52161. * Specifies the metallic scalar of the metallic/roughness workflow.
  52162. * Can also be used to scale the metalness values of the metallic texture.
  52163. */
  52164. metallic: Nullable<number>;
  52165. /**
  52166. * Specifies the roughness scalar of the metallic/roughness workflow.
  52167. * Can also be used to scale the roughness values of the metallic texture.
  52168. */
  52169. roughness: Nullable<number>;
  52170. /**
  52171. * Specifies the an F0 factor to help configuring the material F0.
  52172. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52173. * to 0.5 the previously hard coded value stays the same.
  52174. * Can also be used to scale the F0 values of the metallic texture.
  52175. */
  52176. metallicF0Factor: number;
  52177. /**
  52178. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52179. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52180. * your expectation as it multiplies with the texture data.
  52181. */
  52182. useMetallicF0FactorFromMetallicTexture: boolean;
  52183. /**
  52184. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52185. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52186. */
  52187. microSurfaceTexture: BaseTexture;
  52188. /**
  52189. * Stores surface normal data used to displace a mesh in a texture.
  52190. */
  52191. bumpTexture: BaseTexture;
  52192. /**
  52193. * Stores the pre-calculated light information of a mesh in a texture.
  52194. */
  52195. lightmapTexture: BaseTexture;
  52196. /**
  52197. * Stores the refracted light information in a texture.
  52198. */
  52199. get refractionTexture(): Nullable<BaseTexture>;
  52200. set refractionTexture(value: Nullable<BaseTexture>);
  52201. /**
  52202. * The color of a material in ambient lighting.
  52203. */
  52204. ambientColor: Color3;
  52205. /**
  52206. * AKA Diffuse Color in other nomenclature.
  52207. */
  52208. albedoColor: Color3;
  52209. /**
  52210. * AKA Specular Color in other nomenclature.
  52211. */
  52212. reflectivityColor: Color3;
  52213. /**
  52214. * The color reflected from the material.
  52215. */
  52216. reflectionColor: Color3;
  52217. /**
  52218. * The color emitted from the material.
  52219. */
  52220. emissiveColor: Color3;
  52221. /**
  52222. * AKA Glossiness in other nomenclature.
  52223. */
  52224. microSurface: number;
  52225. /**
  52226. * source material index of refraction (IOR)' / 'destination material IOR.
  52227. */
  52228. get indexOfRefraction(): number;
  52229. set indexOfRefraction(value: number);
  52230. /**
  52231. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52232. */
  52233. get invertRefractionY(): boolean;
  52234. set invertRefractionY(value: boolean);
  52235. /**
  52236. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52237. * Materials half opaque for instance using refraction could benefit from this control.
  52238. */
  52239. get linkRefractionWithTransparency(): boolean;
  52240. set linkRefractionWithTransparency(value: boolean);
  52241. /**
  52242. * If true, the light map contains occlusion information instead of lighting info.
  52243. */
  52244. useLightmapAsShadowmap: boolean;
  52245. /**
  52246. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52247. */
  52248. useAlphaFromAlbedoTexture: boolean;
  52249. /**
  52250. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52251. */
  52252. forceAlphaTest: boolean;
  52253. /**
  52254. * Defines the alpha limits in alpha test mode.
  52255. */
  52256. alphaCutOff: number;
  52257. /**
  52258. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52260. */
  52261. useSpecularOverAlpha: boolean;
  52262. /**
  52263. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52264. */
  52265. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52266. /**
  52267. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52268. */
  52269. useRoughnessFromMetallicTextureAlpha: boolean;
  52270. /**
  52271. * Specifies if the metallic texture contains the roughness information in its green channel.
  52272. */
  52273. useRoughnessFromMetallicTextureGreen: boolean;
  52274. /**
  52275. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52276. */
  52277. useMetallnessFromMetallicTextureBlue: boolean;
  52278. /**
  52279. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52280. */
  52281. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52282. /**
  52283. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52284. */
  52285. useAmbientInGrayScale: boolean;
  52286. /**
  52287. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52288. * The material will try to infer what glossiness each pixel should be.
  52289. */
  52290. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52291. /**
  52292. * BJS is using an harcoded light falloff based on a manually sets up range.
  52293. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52294. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52295. */
  52296. get usePhysicalLightFalloff(): boolean;
  52297. /**
  52298. * BJS is using an harcoded light falloff based on a manually sets up range.
  52299. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52300. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52301. */
  52302. set usePhysicalLightFalloff(value: boolean);
  52303. /**
  52304. * In order to support the falloff compatibility with gltf, a special mode has been added
  52305. * to reproduce the gltf light falloff.
  52306. */
  52307. get useGLTFLightFalloff(): boolean;
  52308. /**
  52309. * In order to support the falloff compatibility with gltf, a special mode has been added
  52310. * to reproduce the gltf light falloff.
  52311. */
  52312. set useGLTFLightFalloff(value: boolean);
  52313. /**
  52314. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52315. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52316. */
  52317. useRadianceOverAlpha: boolean;
  52318. /**
  52319. * Allows using an object space normal map (instead of tangent space).
  52320. */
  52321. useObjectSpaceNormalMap: boolean;
  52322. /**
  52323. * Allows using the bump map in parallax mode.
  52324. */
  52325. useParallax: boolean;
  52326. /**
  52327. * Allows using the bump map in parallax occlusion mode.
  52328. */
  52329. useParallaxOcclusion: boolean;
  52330. /**
  52331. * Controls the scale bias of the parallax mode.
  52332. */
  52333. parallaxScaleBias: number;
  52334. /**
  52335. * If sets to true, disables all the lights affecting the material.
  52336. */
  52337. disableLighting: boolean;
  52338. /**
  52339. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52340. */
  52341. forceIrradianceInFragment: boolean;
  52342. /**
  52343. * Number of Simultaneous lights allowed on the material.
  52344. */
  52345. maxSimultaneousLights: number;
  52346. /**
  52347. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52348. */
  52349. invertNormalMapX: boolean;
  52350. /**
  52351. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52352. */
  52353. invertNormalMapY: boolean;
  52354. /**
  52355. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52356. */
  52357. twoSidedLighting: boolean;
  52358. /**
  52359. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52360. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52361. */
  52362. useAlphaFresnel: boolean;
  52363. /**
  52364. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52365. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52366. */
  52367. useLinearAlphaFresnel: boolean;
  52368. /**
  52369. * Let user defines the brdf lookup texture used for IBL.
  52370. * A default 8bit version is embedded but you could point at :
  52371. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52372. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52373. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52374. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52375. */
  52376. environmentBRDFTexture: Nullable<BaseTexture>;
  52377. /**
  52378. * Force normal to face away from face.
  52379. */
  52380. forceNormalForward: boolean;
  52381. /**
  52382. * Enables specular anti aliasing in the PBR shader.
  52383. * It will both interacts on the Geometry for analytical and IBL lighting.
  52384. * It also prefilter the roughness map based on the bump values.
  52385. */
  52386. enableSpecularAntiAliasing: boolean;
  52387. /**
  52388. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52389. * makes the reflect vector face the model (under horizon).
  52390. */
  52391. useHorizonOcclusion: boolean;
  52392. /**
  52393. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52394. * too much the area relying on ambient texture to define their ambient occlusion.
  52395. */
  52396. useRadianceOcclusion: boolean;
  52397. /**
  52398. * If set to true, no lighting calculations will be applied.
  52399. */
  52400. unlit: boolean;
  52401. /**
  52402. * Gets the image processing configuration used either in this material.
  52403. */
  52404. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52405. /**
  52406. * Sets the Default image processing configuration used either in the this material.
  52407. *
  52408. * If sets to null, the scene one is in use.
  52409. */
  52410. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52411. /**
  52412. * Gets wether the color curves effect is enabled.
  52413. */
  52414. get cameraColorCurvesEnabled(): boolean;
  52415. /**
  52416. * Sets wether the color curves effect is enabled.
  52417. */
  52418. set cameraColorCurvesEnabled(value: boolean);
  52419. /**
  52420. * Gets wether the color grading effect is enabled.
  52421. */
  52422. get cameraColorGradingEnabled(): boolean;
  52423. /**
  52424. * Gets wether the color grading effect is enabled.
  52425. */
  52426. set cameraColorGradingEnabled(value: boolean);
  52427. /**
  52428. * Gets wether tonemapping is enabled or not.
  52429. */
  52430. get cameraToneMappingEnabled(): boolean;
  52431. /**
  52432. * Sets wether tonemapping is enabled or not
  52433. */
  52434. set cameraToneMappingEnabled(value: boolean);
  52435. /**
  52436. * The camera exposure used on this material.
  52437. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52438. * This corresponds to a photographic exposure.
  52439. */
  52440. get cameraExposure(): number;
  52441. /**
  52442. * The camera exposure used on this material.
  52443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52444. * This corresponds to a photographic exposure.
  52445. */
  52446. set cameraExposure(value: number);
  52447. /**
  52448. * Gets The camera contrast used on this material.
  52449. */
  52450. get cameraContrast(): number;
  52451. /**
  52452. * Sets The camera contrast used on this material.
  52453. */
  52454. set cameraContrast(value: number);
  52455. /**
  52456. * Gets the Color Grading 2D Lookup Texture.
  52457. */
  52458. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52459. /**
  52460. * Sets the Color Grading 2D Lookup Texture.
  52461. */
  52462. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52463. /**
  52464. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52465. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52466. * 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;
  52467. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52468. */
  52469. get cameraColorCurves(): Nullable<ColorCurves>;
  52470. /**
  52471. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52472. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52473. * 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;
  52474. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52475. */
  52476. set cameraColorCurves(value: Nullable<ColorCurves>);
  52477. /**
  52478. * Instantiates a new PBRMaterial instance.
  52479. *
  52480. * @param name The material name
  52481. * @param scene The scene the material will be use in.
  52482. */
  52483. constructor(name: string, scene: Scene);
  52484. /**
  52485. * Returns the name of this material class.
  52486. */
  52487. getClassName(): string;
  52488. /**
  52489. * Makes a duplicate of the current material.
  52490. * @param name - name to use for the new material.
  52491. */
  52492. clone(name: string): PBRMaterial;
  52493. /**
  52494. * Serializes this PBR Material.
  52495. * @returns - An object with the serialized material.
  52496. */
  52497. serialize(): any;
  52498. /**
  52499. * Parses a PBR Material from a serialized object.
  52500. * @param source - Serialized object.
  52501. * @param scene - BJS scene instance.
  52502. * @param rootUrl - url for the scene object
  52503. * @returns - PBRMaterial
  52504. */
  52505. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52506. }
  52507. }
  52508. declare module BABYLON {
  52509. /**
  52510. * Direct draw surface info
  52511. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52512. */
  52513. export interface DDSInfo {
  52514. /**
  52515. * Width of the texture
  52516. */
  52517. width: number;
  52518. /**
  52519. * Width of the texture
  52520. */
  52521. height: number;
  52522. /**
  52523. * Number of Mipmaps for the texture
  52524. * @see https://en.wikipedia.org/wiki/Mipmap
  52525. */
  52526. mipmapCount: number;
  52527. /**
  52528. * If the textures format is a known fourCC format
  52529. * @see https://www.fourcc.org/
  52530. */
  52531. isFourCC: boolean;
  52532. /**
  52533. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52534. */
  52535. isRGB: boolean;
  52536. /**
  52537. * If the texture is a lumincance format
  52538. */
  52539. isLuminance: boolean;
  52540. /**
  52541. * If this is a cube texture
  52542. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52543. */
  52544. isCube: boolean;
  52545. /**
  52546. * If the texture is a compressed format eg. FOURCC_DXT1
  52547. */
  52548. isCompressed: boolean;
  52549. /**
  52550. * The dxgiFormat of the texture
  52551. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52552. */
  52553. dxgiFormat: number;
  52554. /**
  52555. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52556. */
  52557. textureType: number;
  52558. /**
  52559. * Sphericle polynomial created for the dds texture
  52560. */
  52561. sphericalPolynomial?: SphericalPolynomial;
  52562. }
  52563. /**
  52564. * Class used to provide DDS decompression tools
  52565. */
  52566. export class DDSTools {
  52567. /**
  52568. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52569. */
  52570. static StoreLODInAlphaChannel: boolean;
  52571. /**
  52572. * Gets DDS information from an array buffer
  52573. * @param data defines the array buffer view to read data from
  52574. * @returns the DDS information
  52575. */
  52576. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52577. private static _FloatView;
  52578. private static _Int32View;
  52579. private static _ToHalfFloat;
  52580. private static _FromHalfFloat;
  52581. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52582. private static _GetHalfFloatRGBAArrayBuffer;
  52583. private static _GetFloatRGBAArrayBuffer;
  52584. private static _GetFloatAsUIntRGBAArrayBuffer;
  52585. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52586. private static _GetRGBAArrayBuffer;
  52587. private static _ExtractLongWordOrder;
  52588. private static _GetRGBArrayBuffer;
  52589. private static _GetLuminanceArrayBuffer;
  52590. /**
  52591. * Uploads DDS Levels to a Babylon Texture
  52592. * @hidden
  52593. */
  52594. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52595. }
  52596. interface ThinEngine {
  52597. /**
  52598. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52599. * @param rootUrl defines the url where the file to load is located
  52600. * @param scene defines the current scene
  52601. * @param lodScale defines scale to apply to the mip map selection
  52602. * @param lodOffset defines offset to apply to the mip map selection
  52603. * @param onLoad defines an optional callback raised when the texture is loaded
  52604. * @param onError defines an optional callback raised if there is an issue to load the texture
  52605. * @param format defines the format of the data
  52606. * @param forcedExtension defines the extension to use to pick the right loader
  52607. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52608. * @returns the cube texture as an InternalTexture
  52609. */
  52610. 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;
  52611. }
  52612. }
  52613. declare module BABYLON {
  52614. /**
  52615. * Implementation of the DDS Texture Loader.
  52616. * @hidden
  52617. */
  52618. export class _DDSTextureLoader implements IInternalTextureLoader {
  52619. /**
  52620. * Defines wether the loader supports cascade loading the different faces.
  52621. */
  52622. readonly supportCascades: boolean;
  52623. /**
  52624. * This returns if the loader support the current file information.
  52625. * @param extension defines the file extension of the file being loaded
  52626. * @returns true if the loader can load the specified file
  52627. */
  52628. canLoad(extension: string): boolean;
  52629. /**
  52630. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52631. * @param data contains the texture data
  52632. * @param texture defines the BabylonJS internal texture
  52633. * @param createPolynomials will be true if polynomials have been requested
  52634. * @param onLoad defines the callback to trigger once the texture is ready
  52635. * @param onError defines the callback to trigger in case of error
  52636. */
  52637. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52638. /**
  52639. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52640. * @param data contains the texture data
  52641. * @param texture defines the BabylonJS internal texture
  52642. * @param callback defines the method to call once ready to upload
  52643. */
  52644. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52645. }
  52646. }
  52647. declare module BABYLON {
  52648. /**
  52649. * Implementation of the ENV Texture Loader.
  52650. * @hidden
  52651. */
  52652. export class _ENVTextureLoader implements IInternalTextureLoader {
  52653. /**
  52654. * Defines wether the loader supports cascade loading the different faces.
  52655. */
  52656. readonly supportCascades: boolean;
  52657. /**
  52658. * This returns if the loader support the current file information.
  52659. * @param extension defines the file extension of the file being loaded
  52660. * @returns true if the loader can load the specified file
  52661. */
  52662. canLoad(extension: string): boolean;
  52663. /**
  52664. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52665. * @param data contains the texture data
  52666. * @param texture defines the BabylonJS internal texture
  52667. * @param createPolynomials will be true if polynomials have been requested
  52668. * @param onLoad defines the callback to trigger once the texture is ready
  52669. * @param onError defines the callback to trigger in case of error
  52670. */
  52671. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52672. /**
  52673. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52674. * @param data contains the texture data
  52675. * @param texture defines the BabylonJS internal texture
  52676. * @param callback defines the method to call once ready to upload
  52677. */
  52678. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52679. }
  52680. }
  52681. declare module BABYLON {
  52682. /**
  52683. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52684. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52685. */
  52686. export class KhronosTextureContainer {
  52687. /** contents of the KTX container file */
  52688. data: ArrayBufferView;
  52689. private static HEADER_LEN;
  52690. private static COMPRESSED_2D;
  52691. private static COMPRESSED_3D;
  52692. private static TEX_2D;
  52693. private static TEX_3D;
  52694. /**
  52695. * Gets the openGL type
  52696. */
  52697. glType: number;
  52698. /**
  52699. * Gets the openGL type size
  52700. */
  52701. glTypeSize: number;
  52702. /**
  52703. * Gets the openGL format
  52704. */
  52705. glFormat: number;
  52706. /**
  52707. * Gets the openGL internal format
  52708. */
  52709. glInternalFormat: number;
  52710. /**
  52711. * Gets the base internal format
  52712. */
  52713. glBaseInternalFormat: number;
  52714. /**
  52715. * Gets image width in pixel
  52716. */
  52717. pixelWidth: number;
  52718. /**
  52719. * Gets image height in pixel
  52720. */
  52721. pixelHeight: number;
  52722. /**
  52723. * Gets image depth in pixels
  52724. */
  52725. pixelDepth: number;
  52726. /**
  52727. * Gets the number of array elements
  52728. */
  52729. numberOfArrayElements: number;
  52730. /**
  52731. * Gets the number of faces
  52732. */
  52733. numberOfFaces: number;
  52734. /**
  52735. * Gets the number of mipmap levels
  52736. */
  52737. numberOfMipmapLevels: number;
  52738. /**
  52739. * Gets the bytes of key value data
  52740. */
  52741. bytesOfKeyValueData: number;
  52742. /**
  52743. * Gets the load type
  52744. */
  52745. loadType: number;
  52746. /**
  52747. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52748. */
  52749. isInvalid: boolean;
  52750. /**
  52751. * Creates a new KhronosTextureContainer
  52752. * @param data contents of the KTX container file
  52753. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52754. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52755. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52756. */
  52757. constructor(
  52758. /** contents of the KTX container file */
  52759. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52760. /**
  52761. * Uploads KTX content to a Babylon Texture.
  52762. * It is assumed that the texture has already been created & is currently bound
  52763. * @hidden
  52764. */
  52765. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52766. private _upload2DCompressedLevels;
  52767. /**
  52768. * Checks if the given data starts with a KTX file identifier.
  52769. * @param data the data to check
  52770. * @returns true if the data is a KTX file or false otherwise
  52771. */
  52772. static IsValid(data: ArrayBufferView): boolean;
  52773. }
  52774. }
  52775. declare module BABYLON {
  52776. /**
  52777. * Class for loading KTX2 files
  52778. * !!! Experimental Extension Subject to Changes !!!
  52779. * @hidden
  52780. */
  52781. export class KhronosTextureContainer2 {
  52782. private static _ModulePromise;
  52783. private static _TranscodeFormat;
  52784. constructor(engine: ThinEngine);
  52785. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52786. private _determineTranscodeFormat;
  52787. /**
  52788. * Checks if the given data starts with a KTX2 file identifier.
  52789. * @param data the data to check
  52790. * @returns true if the data is a KTX2 file or false otherwise
  52791. */
  52792. static IsValid(data: ArrayBufferView): boolean;
  52793. }
  52794. }
  52795. declare module BABYLON {
  52796. /**
  52797. * Implementation of the KTX Texture Loader.
  52798. * @hidden
  52799. */
  52800. export class _KTXTextureLoader implements IInternalTextureLoader {
  52801. /**
  52802. * Defines wether the loader supports cascade loading the different faces.
  52803. */
  52804. readonly supportCascades: boolean;
  52805. /**
  52806. * This returns if the loader support the current file information.
  52807. * @param extension defines the file extension of the file being loaded
  52808. * @returns true if the loader can load the specified file
  52809. */
  52810. canLoad(extension: string): boolean;
  52811. /**
  52812. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52813. * @param data contains the texture data
  52814. * @param texture defines the BabylonJS internal texture
  52815. * @param createPolynomials will be true if polynomials have been requested
  52816. * @param onLoad defines the callback to trigger once the texture is ready
  52817. * @param onError defines the callback to trigger in case of error
  52818. */
  52819. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52820. /**
  52821. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52822. * @param data contains the texture data
  52823. * @param texture defines the BabylonJS internal texture
  52824. * @param callback defines the method to call once ready to upload
  52825. */
  52826. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52827. }
  52828. }
  52829. declare module BABYLON {
  52830. /** @hidden */
  52831. export var _forceSceneHelpersToBundle: boolean;
  52832. interface Scene {
  52833. /**
  52834. * Creates a default light for the scene.
  52835. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52836. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52837. */
  52838. createDefaultLight(replace?: boolean): void;
  52839. /**
  52840. * Creates a default camera for the scene.
  52841. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52842. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52843. * @param replace has default false, when true replaces the active camera in the scene
  52844. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52845. */
  52846. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52847. /**
  52848. * Creates a default camera and a default light.
  52849. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52850. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52851. * @param replace has the default false, when true replaces the active camera/light in the scene
  52852. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52853. */
  52854. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52855. /**
  52856. * Creates a new sky box
  52857. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52858. * @param environmentTexture defines the texture to use as environment texture
  52859. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52860. * @param scale defines the overall scale of the skybox
  52861. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52862. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52863. * @returns a new mesh holding the sky box
  52864. */
  52865. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52866. /**
  52867. * Creates a new environment
  52868. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52869. * @param options defines the options you can use to configure the environment
  52870. * @returns the new EnvironmentHelper
  52871. */
  52872. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52873. /**
  52874. * Creates a new VREXperienceHelper
  52875. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52876. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52877. * @returns a new VREXperienceHelper
  52878. */
  52879. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52880. /**
  52881. * Creates a new WebXRDefaultExperience
  52882. * @see http://doc.babylonjs.com/how_to/webxr
  52883. * @param options experience options
  52884. * @returns a promise for a new WebXRDefaultExperience
  52885. */
  52886. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52887. }
  52888. }
  52889. declare module BABYLON {
  52890. /**
  52891. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52892. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52893. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52894. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52895. */
  52896. export class VideoDome extends TransformNode {
  52897. /**
  52898. * Define the video source as a Monoscopic panoramic 360 video.
  52899. */
  52900. static readonly MODE_MONOSCOPIC: number;
  52901. /**
  52902. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52903. */
  52904. static readonly MODE_TOPBOTTOM: number;
  52905. /**
  52906. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52907. */
  52908. static readonly MODE_SIDEBYSIDE: number;
  52909. private _halfDome;
  52910. private _useDirectMapping;
  52911. /**
  52912. * The video texture being displayed on the sphere
  52913. */
  52914. protected _videoTexture: VideoTexture;
  52915. /**
  52916. * Gets the video texture being displayed on the sphere
  52917. */
  52918. get videoTexture(): VideoTexture;
  52919. /**
  52920. * The skybox material
  52921. */
  52922. protected _material: BackgroundMaterial;
  52923. /**
  52924. * The surface used for the skybox
  52925. */
  52926. protected _mesh: Mesh;
  52927. /**
  52928. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52929. */
  52930. private _halfDomeMask;
  52931. /**
  52932. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52933. * Also see the options.resolution property.
  52934. */
  52935. get fovMultiplier(): number;
  52936. set fovMultiplier(value: number);
  52937. private _videoMode;
  52938. /**
  52939. * Gets or set the current video mode for the video. It can be:
  52940. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52941. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52942. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52943. */
  52944. get videoMode(): number;
  52945. set videoMode(value: number);
  52946. /**
  52947. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52948. *
  52949. */
  52950. get halfDome(): boolean;
  52951. /**
  52952. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52953. */
  52954. set halfDome(enabled: boolean);
  52955. /**
  52956. * Oberserver used in Stereoscopic VR Mode.
  52957. */
  52958. private _onBeforeCameraRenderObserver;
  52959. /**
  52960. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52961. * @param name Element's name, child elements will append suffixes for their own names.
  52962. * @param urlsOrVideo defines the url(s) or the video element to use
  52963. * @param options An object containing optional or exposed sub element properties
  52964. */
  52965. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52966. resolution?: number;
  52967. clickToPlay?: boolean;
  52968. autoPlay?: boolean;
  52969. loop?: boolean;
  52970. size?: number;
  52971. poster?: string;
  52972. faceForward?: boolean;
  52973. useDirectMapping?: boolean;
  52974. halfDomeMode?: boolean;
  52975. }, scene: Scene);
  52976. private _changeVideoMode;
  52977. /**
  52978. * Releases resources associated with this node.
  52979. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52980. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52981. */
  52982. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52983. }
  52984. }
  52985. declare module BABYLON {
  52986. /**
  52987. * This class can be used to get instrumentation data from a Babylon engine
  52988. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52989. */
  52990. export class EngineInstrumentation implements IDisposable {
  52991. /**
  52992. * Define the instrumented engine.
  52993. */
  52994. engine: Engine;
  52995. private _captureGPUFrameTime;
  52996. private _gpuFrameTimeToken;
  52997. private _gpuFrameTime;
  52998. private _captureShaderCompilationTime;
  52999. private _shaderCompilationTime;
  53000. private _onBeginFrameObserver;
  53001. private _onEndFrameObserver;
  53002. private _onBeforeShaderCompilationObserver;
  53003. private _onAfterShaderCompilationObserver;
  53004. /**
  53005. * Gets the perf counter used for GPU frame time
  53006. */
  53007. get gpuFrameTimeCounter(): PerfCounter;
  53008. /**
  53009. * Gets the GPU frame time capture status
  53010. */
  53011. get captureGPUFrameTime(): boolean;
  53012. /**
  53013. * Enable or disable the GPU frame time capture
  53014. */
  53015. set captureGPUFrameTime(value: boolean);
  53016. /**
  53017. * Gets the perf counter used for shader compilation time
  53018. */
  53019. get shaderCompilationTimeCounter(): PerfCounter;
  53020. /**
  53021. * Gets the shader compilation time capture status
  53022. */
  53023. get captureShaderCompilationTime(): boolean;
  53024. /**
  53025. * Enable or disable the shader compilation time capture
  53026. */
  53027. set captureShaderCompilationTime(value: boolean);
  53028. /**
  53029. * Instantiates a new engine instrumentation.
  53030. * This class can be used to get instrumentation data from a Babylon engine
  53031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53032. * @param engine Defines the engine to instrument
  53033. */
  53034. constructor(
  53035. /**
  53036. * Define the instrumented engine.
  53037. */
  53038. engine: Engine);
  53039. /**
  53040. * Dispose and release associated resources.
  53041. */
  53042. dispose(): void;
  53043. }
  53044. }
  53045. declare module BABYLON {
  53046. /**
  53047. * This class can be used to get instrumentation data from a Babylon engine
  53048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53049. */
  53050. export class SceneInstrumentation implements IDisposable {
  53051. /**
  53052. * Defines the scene to instrument
  53053. */
  53054. scene: Scene;
  53055. private _captureActiveMeshesEvaluationTime;
  53056. private _activeMeshesEvaluationTime;
  53057. private _captureRenderTargetsRenderTime;
  53058. private _renderTargetsRenderTime;
  53059. private _captureFrameTime;
  53060. private _frameTime;
  53061. private _captureRenderTime;
  53062. private _renderTime;
  53063. private _captureInterFrameTime;
  53064. private _interFrameTime;
  53065. private _captureParticlesRenderTime;
  53066. private _particlesRenderTime;
  53067. private _captureSpritesRenderTime;
  53068. private _spritesRenderTime;
  53069. private _capturePhysicsTime;
  53070. private _physicsTime;
  53071. private _captureAnimationsTime;
  53072. private _animationsTime;
  53073. private _captureCameraRenderTime;
  53074. private _cameraRenderTime;
  53075. private _onBeforeActiveMeshesEvaluationObserver;
  53076. private _onAfterActiveMeshesEvaluationObserver;
  53077. private _onBeforeRenderTargetsRenderObserver;
  53078. private _onAfterRenderTargetsRenderObserver;
  53079. private _onAfterRenderObserver;
  53080. private _onBeforeDrawPhaseObserver;
  53081. private _onAfterDrawPhaseObserver;
  53082. private _onBeforeAnimationsObserver;
  53083. private _onBeforeParticlesRenderingObserver;
  53084. private _onAfterParticlesRenderingObserver;
  53085. private _onBeforeSpritesRenderingObserver;
  53086. private _onAfterSpritesRenderingObserver;
  53087. private _onBeforePhysicsObserver;
  53088. private _onAfterPhysicsObserver;
  53089. private _onAfterAnimationsObserver;
  53090. private _onBeforeCameraRenderObserver;
  53091. private _onAfterCameraRenderObserver;
  53092. /**
  53093. * Gets the perf counter used for active meshes evaluation time
  53094. */
  53095. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53096. /**
  53097. * Gets the active meshes evaluation time capture status
  53098. */
  53099. get captureActiveMeshesEvaluationTime(): boolean;
  53100. /**
  53101. * Enable or disable the active meshes evaluation time capture
  53102. */
  53103. set captureActiveMeshesEvaluationTime(value: boolean);
  53104. /**
  53105. * Gets the perf counter used for render targets render time
  53106. */
  53107. get renderTargetsRenderTimeCounter(): PerfCounter;
  53108. /**
  53109. * Gets the render targets render time capture status
  53110. */
  53111. get captureRenderTargetsRenderTime(): boolean;
  53112. /**
  53113. * Enable or disable the render targets render time capture
  53114. */
  53115. set captureRenderTargetsRenderTime(value: boolean);
  53116. /**
  53117. * Gets the perf counter used for particles render time
  53118. */
  53119. get particlesRenderTimeCounter(): PerfCounter;
  53120. /**
  53121. * Gets the particles render time capture status
  53122. */
  53123. get captureParticlesRenderTime(): boolean;
  53124. /**
  53125. * Enable or disable the particles render time capture
  53126. */
  53127. set captureParticlesRenderTime(value: boolean);
  53128. /**
  53129. * Gets the perf counter used for sprites render time
  53130. */
  53131. get spritesRenderTimeCounter(): PerfCounter;
  53132. /**
  53133. * Gets the sprites render time capture status
  53134. */
  53135. get captureSpritesRenderTime(): boolean;
  53136. /**
  53137. * Enable or disable the sprites render time capture
  53138. */
  53139. set captureSpritesRenderTime(value: boolean);
  53140. /**
  53141. * Gets the perf counter used for physics time
  53142. */
  53143. get physicsTimeCounter(): PerfCounter;
  53144. /**
  53145. * Gets the physics time capture status
  53146. */
  53147. get capturePhysicsTime(): boolean;
  53148. /**
  53149. * Enable or disable the physics time capture
  53150. */
  53151. set capturePhysicsTime(value: boolean);
  53152. /**
  53153. * Gets the perf counter used for animations time
  53154. */
  53155. get animationsTimeCounter(): PerfCounter;
  53156. /**
  53157. * Gets the animations time capture status
  53158. */
  53159. get captureAnimationsTime(): boolean;
  53160. /**
  53161. * Enable or disable the animations time capture
  53162. */
  53163. set captureAnimationsTime(value: boolean);
  53164. /**
  53165. * Gets the perf counter used for frame time capture
  53166. */
  53167. get frameTimeCounter(): PerfCounter;
  53168. /**
  53169. * Gets the frame time capture status
  53170. */
  53171. get captureFrameTime(): boolean;
  53172. /**
  53173. * Enable or disable the frame time capture
  53174. */
  53175. set captureFrameTime(value: boolean);
  53176. /**
  53177. * Gets the perf counter used for inter-frames time capture
  53178. */
  53179. get interFrameTimeCounter(): PerfCounter;
  53180. /**
  53181. * Gets the inter-frames time capture status
  53182. */
  53183. get captureInterFrameTime(): boolean;
  53184. /**
  53185. * Enable or disable the inter-frames time capture
  53186. */
  53187. set captureInterFrameTime(value: boolean);
  53188. /**
  53189. * Gets the perf counter used for render time capture
  53190. */
  53191. get renderTimeCounter(): PerfCounter;
  53192. /**
  53193. * Gets the render time capture status
  53194. */
  53195. get captureRenderTime(): boolean;
  53196. /**
  53197. * Enable or disable the render time capture
  53198. */
  53199. set captureRenderTime(value: boolean);
  53200. /**
  53201. * Gets the perf counter used for camera render time capture
  53202. */
  53203. get cameraRenderTimeCounter(): PerfCounter;
  53204. /**
  53205. * Gets the camera render time capture status
  53206. */
  53207. get captureCameraRenderTime(): boolean;
  53208. /**
  53209. * Enable or disable the camera render time capture
  53210. */
  53211. set captureCameraRenderTime(value: boolean);
  53212. /**
  53213. * Gets the perf counter used for draw calls
  53214. */
  53215. get drawCallsCounter(): PerfCounter;
  53216. /**
  53217. * Instantiates a new scene instrumentation.
  53218. * This class can be used to get instrumentation data from a Babylon engine
  53219. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53220. * @param scene Defines the scene to instrument
  53221. */
  53222. constructor(
  53223. /**
  53224. * Defines the scene to instrument
  53225. */
  53226. scene: Scene);
  53227. /**
  53228. * Dispose and release associated resources.
  53229. */
  53230. dispose(): void;
  53231. }
  53232. }
  53233. declare module BABYLON {
  53234. /** @hidden */
  53235. export var glowMapGenerationPixelShader: {
  53236. name: string;
  53237. shader: string;
  53238. };
  53239. }
  53240. declare module BABYLON {
  53241. /** @hidden */
  53242. export var glowMapGenerationVertexShader: {
  53243. name: string;
  53244. shader: string;
  53245. };
  53246. }
  53247. declare module BABYLON {
  53248. /**
  53249. * Effect layer options. This helps customizing the behaviour
  53250. * of the effect layer.
  53251. */
  53252. export interface IEffectLayerOptions {
  53253. /**
  53254. * Multiplication factor apply to the canvas size to compute the render target size
  53255. * used to generated the objects (the smaller the faster).
  53256. */
  53257. mainTextureRatio: number;
  53258. /**
  53259. * Enforces a fixed size texture to ensure effect stability across devices.
  53260. */
  53261. mainTextureFixedSize?: number;
  53262. /**
  53263. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53264. */
  53265. alphaBlendingMode: number;
  53266. /**
  53267. * The camera attached to the layer.
  53268. */
  53269. camera: Nullable<Camera>;
  53270. /**
  53271. * The rendering group to draw the layer in.
  53272. */
  53273. renderingGroupId: number;
  53274. }
  53275. /**
  53276. * The effect layer Helps adding post process effect blended with the main pass.
  53277. *
  53278. * This can be for instance use to generate glow or higlight effects on the scene.
  53279. *
  53280. * The effect layer class can not be used directly and is intented to inherited from to be
  53281. * customized per effects.
  53282. */
  53283. export abstract class EffectLayer {
  53284. private _vertexBuffers;
  53285. private _indexBuffer;
  53286. private _cachedDefines;
  53287. private _effectLayerMapGenerationEffect;
  53288. private _effectLayerOptions;
  53289. private _mergeEffect;
  53290. protected _scene: Scene;
  53291. protected _engine: Engine;
  53292. protected _maxSize: number;
  53293. protected _mainTextureDesiredSize: ISize;
  53294. protected _mainTexture: RenderTargetTexture;
  53295. protected _shouldRender: boolean;
  53296. protected _postProcesses: PostProcess[];
  53297. protected _textures: BaseTexture[];
  53298. protected _emissiveTextureAndColor: {
  53299. texture: Nullable<BaseTexture>;
  53300. color: Color4;
  53301. };
  53302. /**
  53303. * The name of the layer
  53304. */
  53305. name: string;
  53306. /**
  53307. * The clear color of the texture used to generate the glow map.
  53308. */
  53309. neutralColor: Color4;
  53310. /**
  53311. * Specifies whether the highlight layer is enabled or not.
  53312. */
  53313. isEnabled: boolean;
  53314. /**
  53315. * Gets the camera attached to the layer.
  53316. */
  53317. get camera(): Nullable<Camera>;
  53318. /**
  53319. * Gets the rendering group id the layer should render in.
  53320. */
  53321. get renderingGroupId(): number;
  53322. set renderingGroupId(renderingGroupId: number);
  53323. /**
  53324. * An event triggered when the effect layer has been disposed.
  53325. */
  53326. onDisposeObservable: Observable<EffectLayer>;
  53327. /**
  53328. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53329. */
  53330. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53331. /**
  53332. * An event triggered when the generated texture is being merged in the scene.
  53333. */
  53334. onBeforeComposeObservable: Observable<EffectLayer>;
  53335. /**
  53336. * An event triggered when the mesh is rendered into the effect render target.
  53337. */
  53338. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53339. /**
  53340. * An event triggered after the mesh has been rendered into the effect render target.
  53341. */
  53342. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53343. /**
  53344. * An event triggered when the generated texture has been merged in the scene.
  53345. */
  53346. onAfterComposeObservable: Observable<EffectLayer>;
  53347. /**
  53348. * An event triggered when the efffect layer changes its size.
  53349. */
  53350. onSizeChangedObservable: Observable<EffectLayer>;
  53351. /** @hidden */
  53352. static _SceneComponentInitialization: (scene: Scene) => void;
  53353. /**
  53354. * Instantiates a new effect Layer and references it in the scene.
  53355. * @param name The name of the layer
  53356. * @param scene The scene to use the layer in
  53357. */
  53358. constructor(
  53359. /** The Friendly of the effect in the scene */
  53360. name: string, scene: Scene);
  53361. /**
  53362. * Get the effect name of the layer.
  53363. * @return The effect name
  53364. */
  53365. abstract getEffectName(): string;
  53366. /**
  53367. * Checks for the readiness of the element composing the layer.
  53368. * @param subMesh the mesh to check for
  53369. * @param useInstances specify whether or not to use instances to render the mesh
  53370. * @return true if ready otherwise, false
  53371. */
  53372. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53373. /**
  53374. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53375. * @returns true if the effect requires stencil during the main canvas render pass.
  53376. */
  53377. abstract needStencil(): boolean;
  53378. /**
  53379. * Create the merge effect. This is the shader use to blit the information back
  53380. * to the main canvas at the end of the scene rendering.
  53381. * @returns The effect containing the shader used to merge the effect on the main canvas
  53382. */
  53383. protected abstract _createMergeEffect(): Effect;
  53384. /**
  53385. * Creates the render target textures and post processes used in the effect layer.
  53386. */
  53387. protected abstract _createTextureAndPostProcesses(): void;
  53388. /**
  53389. * Implementation specific of rendering the generating effect on the main canvas.
  53390. * @param effect The effect used to render through
  53391. */
  53392. protected abstract _internalRender(effect: Effect): void;
  53393. /**
  53394. * Sets the required values for both the emissive texture and and the main color.
  53395. */
  53396. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53397. /**
  53398. * Free any resources and references associated to a mesh.
  53399. * Internal use
  53400. * @param mesh The mesh to free.
  53401. */
  53402. abstract _disposeMesh(mesh: Mesh): void;
  53403. /**
  53404. * Serializes this layer (Glow or Highlight for example)
  53405. * @returns a serialized layer object
  53406. */
  53407. abstract serialize?(): any;
  53408. /**
  53409. * Initializes the effect layer with the required options.
  53410. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53411. */
  53412. protected _init(options: Partial<IEffectLayerOptions>): void;
  53413. /**
  53414. * Generates the index buffer of the full screen quad blending to the main canvas.
  53415. */
  53416. private _generateIndexBuffer;
  53417. /**
  53418. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53419. */
  53420. private _generateVertexBuffer;
  53421. /**
  53422. * Sets the main texture desired size which is the closest power of two
  53423. * of the engine canvas size.
  53424. */
  53425. private _setMainTextureSize;
  53426. /**
  53427. * Creates the main texture for the effect layer.
  53428. */
  53429. protected _createMainTexture(): void;
  53430. /**
  53431. * Adds specific effects defines.
  53432. * @param defines The defines to add specifics to.
  53433. */
  53434. protected _addCustomEffectDefines(defines: string[]): void;
  53435. /**
  53436. * Checks for the readiness of the element composing the layer.
  53437. * @param subMesh the mesh to check for
  53438. * @param useInstances specify whether or not to use instances to render the mesh
  53439. * @param emissiveTexture the associated emissive texture used to generate the glow
  53440. * @return true if ready otherwise, false
  53441. */
  53442. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53443. /**
  53444. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53445. */
  53446. render(): void;
  53447. /**
  53448. * Determine if a given mesh will be used in the current effect.
  53449. * @param mesh mesh to test
  53450. * @returns true if the mesh will be used
  53451. */
  53452. hasMesh(mesh: AbstractMesh): boolean;
  53453. /**
  53454. * Returns true if the layer contains information to display, otherwise false.
  53455. * @returns true if the glow layer should be rendered
  53456. */
  53457. shouldRender(): boolean;
  53458. /**
  53459. * Returns true if the mesh should render, otherwise false.
  53460. * @param mesh The mesh to render
  53461. * @returns true if it should render otherwise false
  53462. */
  53463. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53464. /**
  53465. * Returns true if the mesh can be rendered, otherwise false.
  53466. * @param mesh The mesh to render
  53467. * @param material The material used on the mesh
  53468. * @returns true if it can be rendered otherwise false
  53469. */
  53470. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53471. /**
  53472. * Returns true if the mesh should render, otherwise false.
  53473. * @param mesh The mesh to render
  53474. * @returns true if it should render otherwise false
  53475. */
  53476. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53477. /**
  53478. * Renders the submesh passed in parameter to the generation map.
  53479. */
  53480. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53481. /**
  53482. * Defines whether the current material of the mesh should be use to render the effect.
  53483. * @param mesh defines the current mesh to render
  53484. */
  53485. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53486. /**
  53487. * Rebuild the required buffers.
  53488. * @hidden Internal use only.
  53489. */
  53490. _rebuild(): void;
  53491. /**
  53492. * Dispose only the render target textures and post process.
  53493. */
  53494. private _disposeTextureAndPostProcesses;
  53495. /**
  53496. * Dispose the highlight layer and free resources.
  53497. */
  53498. dispose(): void;
  53499. /**
  53500. * Gets the class name of the effect layer
  53501. * @returns the string with the class name of the effect layer
  53502. */
  53503. getClassName(): string;
  53504. /**
  53505. * Creates an effect layer from parsed effect layer data
  53506. * @param parsedEffectLayer defines effect layer data
  53507. * @param scene defines the current scene
  53508. * @param rootUrl defines the root URL containing the effect layer information
  53509. * @returns a parsed effect Layer
  53510. */
  53511. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53512. }
  53513. }
  53514. declare module BABYLON {
  53515. interface AbstractScene {
  53516. /**
  53517. * The list of effect layers (highlights/glow) added to the scene
  53518. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53519. * @see http://doc.babylonjs.com/how_to/glow_layer
  53520. */
  53521. effectLayers: Array<EffectLayer>;
  53522. /**
  53523. * Removes the given effect layer from this scene.
  53524. * @param toRemove defines the effect layer to remove
  53525. * @returns the index of the removed effect layer
  53526. */
  53527. removeEffectLayer(toRemove: EffectLayer): number;
  53528. /**
  53529. * Adds the given effect layer to this scene
  53530. * @param newEffectLayer defines the effect layer to add
  53531. */
  53532. addEffectLayer(newEffectLayer: EffectLayer): void;
  53533. }
  53534. /**
  53535. * Defines the layer scene component responsible to manage any effect layers
  53536. * in a given scene.
  53537. */
  53538. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53539. /**
  53540. * The component name helpfull to identify the component in the list of scene components.
  53541. */
  53542. readonly name: string;
  53543. /**
  53544. * The scene the component belongs to.
  53545. */
  53546. scene: Scene;
  53547. private _engine;
  53548. private _renderEffects;
  53549. private _needStencil;
  53550. private _previousStencilState;
  53551. /**
  53552. * Creates a new instance of the component for the given scene
  53553. * @param scene Defines the scene to register the component in
  53554. */
  53555. constructor(scene: Scene);
  53556. /**
  53557. * Registers the component in a given scene
  53558. */
  53559. register(): void;
  53560. /**
  53561. * Rebuilds the elements related to this component in case of
  53562. * context lost for instance.
  53563. */
  53564. rebuild(): void;
  53565. /**
  53566. * Serializes the component data to the specified json object
  53567. * @param serializationObject The object to serialize to
  53568. */
  53569. serialize(serializationObject: any): void;
  53570. /**
  53571. * Adds all the elements from the container to the scene
  53572. * @param container the container holding the elements
  53573. */
  53574. addFromContainer(container: AbstractScene): void;
  53575. /**
  53576. * Removes all the elements in the container from the scene
  53577. * @param container contains the elements to remove
  53578. * @param dispose if the removed element should be disposed (default: false)
  53579. */
  53580. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53581. /**
  53582. * Disposes the component and the associated ressources.
  53583. */
  53584. dispose(): void;
  53585. private _isReadyForMesh;
  53586. private _renderMainTexture;
  53587. private _setStencil;
  53588. private _setStencilBack;
  53589. private _draw;
  53590. private _drawCamera;
  53591. private _drawRenderingGroup;
  53592. }
  53593. }
  53594. declare module BABYLON {
  53595. /** @hidden */
  53596. export var glowMapMergePixelShader: {
  53597. name: string;
  53598. shader: string;
  53599. };
  53600. }
  53601. declare module BABYLON {
  53602. /** @hidden */
  53603. export var glowMapMergeVertexShader: {
  53604. name: string;
  53605. shader: string;
  53606. };
  53607. }
  53608. declare module BABYLON {
  53609. interface AbstractScene {
  53610. /**
  53611. * Return a the first highlight layer of the scene with a given name.
  53612. * @param name The name of the highlight layer to look for.
  53613. * @return The highlight layer if found otherwise null.
  53614. */
  53615. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53616. }
  53617. /**
  53618. * Glow layer options. This helps customizing the behaviour
  53619. * of the glow layer.
  53620. */
  53621. export interface IGlowLayerOptions {
  53622. /**
  53623. * Multiplication factor apply to the canvas size to compute the render target size
  53624. * used to generated the glowing objects (the smaller the faster).
  53625. */
  53626. mainTextureRatio: number;
  53627. /**
  53628. * Enforces a fixed size texture to ensure resize independant blur.
  53629. */
  53630. mainTextureFixedSize?: number;
  53631. /**
  53632. * How big is the kernel of the blur texture.
  53633. */
  53634. blurKernelSize: number;
  53635. /**
  53636. * The camera attached to the layer.
  53637. */
  53638. camera: Nullable<Camera>;
  53639. /**
  53640. * Enable MSAA by chosing the number of samples.
  53641. */
  53642. mainTextureSamples?: number;
  53643. /**
  53644. * The rendering group to draw the layer in.
  53645. */
  53646. renderingGroupId: number;
  53647. }
  53648. /**
  53649. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53650. *
  53651. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53652. *
  53653. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53654. */
  53655. export class GlowLayer extends EffectLayer {
  53656. /**
  53657. * Effect Name of the layer.
  53658. */
  53659. static readonly EffectName: string;
  53660. /**
  53661. * The default blur kernel size used for the glow.
  53662. */
  53663. static DefaultBlurKernelSize: number;
  53664. /**
  53665. * The default texture size ratio used for the glow.
  53666. */
  53667. static DefaultTextureRatio: number;
  53668. /**
  53669. * Sets the kernel size of the blur.
  53670. */
  53671. set blurKernelSize(value: number);
  53672. /**
  53673. * Gets the kernel size of the blur.
  53674. */
  53675. get blurKernelSize(): number;
  53676. /**
  53677. * Sets the glow intensity.
  53678. */
  53679. set intensity(value: number);
  53680. /**
  53681. * Gets the glow intensity.
  53682. */
  53683. get intensity(): number;
  53684. private _options;
  53685. private _intensity;
  53686. private _horizontalBlurPostprocess1;
  53687. private _verticalBlurPostprocess1;
  53688. private _horizontalBlurPostprocess2;
  53689. private _verticalBlurPostprocess2;
  53690. private _blurTexture1;
  53691. private _blurTexture2;
  53692. private _postProcesses1;
  53693. private _postProcesses2;
  53694. private _includedOnlyMeshes;
  53695. private _excludedMeshes;
  53696. private _meshesUsingTheirOwnMaterials;
  53697. /**
  53698. * Callback used to let the user override the color selection on a per mesh basis
  53699. */
  53700. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53701. /**
  53702. * Callback used to let the user override the texture selection on a per mesh basis
  53703. */
  53704. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53705. /**
  53706. * Instantiates a new glow Layer and references it to the scene.
  53707. * @param name The name of the layer
  53708. * @param scene The scene to use the layer in
  53709. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53710. */
  53711. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53712. /**
  53713. * Get the effect name of the layer.
  53714. * @return The effect name
  53715. */
  53716. getEffectName(): string;
  53717. /**
  53718. * Create the merge effect. This is the shader use to blit the information back
  53719. * to the main canvas at the end of the scene rendering.
  53720. */
  53721. protected _createMergeEffect(): Effect;
  53722. /**
  53723. * Creates the render target textures and post processes used in the glow layer.
  53724. */
  53725. protected _createTextureAndPostProcesses(): void;
  53726. /**
  53727. * Checks for the readiness of the element composing the layer.
  53728. * @param subMesh the mesh to check for
  53729. * @param useInstances specify wether or not to use instances to render the mesh
  53730. * @param emissiveTexture the associated emissive texture used to generate the glow
  53731. * @return true if ready otherwise, false
  53732. */
  53733. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53734. /**
  53735. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53736. */
  53737. needStencil(): boolean;
  53738. /**
  53739. * Returns true if the mesh can be rendered, otherwise false.
  53740. * @param mesh The mesh to render
  53741. * @param material The material used on the mesh
  53742. * @returns true if it can be rendered otherwise false
  53743. */
  53744. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53745. /**
  53746. * Implementation specific of rendering the generating effect on the main canvas.
  53747. * @param effect The effect used to render through
  53748. */
  53749. protected _internalRender(effect: Effect): void;
  53750. /**
  53751. * Sets the required values for both the emissive texture and and the main color.
  53752. */
  53753. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53754. /**
  53755. * Returns true if the mesh should render, otherwise false.
  53756. * @param mesh The mesh to render
  53757. * @returns true if it should render otherwise false
  53758. */
  53759. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53760. /**
  53761. * Adds specific effects defines.
  53762. * @param defines The defines to add specifics to.
  53763. */
  53764. protected _addCustomEffectDefines(defines: string[]): void;
  53765. /**
  53766. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53767. * @param mesh The mesh to exclude from the glow layer
  53768. */
  53769. addExcludedMesh(mesh: Mesh): void;
  53770. /**
  53771. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53772. * @param mesh The mesh to remove
  53773. */
  53774. removeExcludedMesh(mesh: Mesh): void;
  53775. /**
  53776. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53777. * @param mesh The mesh to include in the glow layer
  53778. */
  53779. addIncludedOnlyMesh(mesh: Mesh): void;
  53780. /**
  53781. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53782. * @param mesh The mesh to remove
  53783. */
  53784. removeIncludedOnlyMesh(mesh: Mesh): void;
  53785. /**
  53786. * Determine if a given mesh will be used in the glow layer
  53787. * @param mesh The mesh to test
  53788. * @returns true if the mesh will be highlighted by the current glow layer
  53789. */
  53790. hasMesh(mesh: AbstractMesh): boolean;
  53791. /**
  53792. * Defines whether the current material of the mesh should be use to render the effect.
  53793. * @param mesh defines the current mesh to render
  53794. */
  53795. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53796. /**
  53797. * Add a mesh to be rendered through its own material and not with emissive only.
  53798. * @param mesh The mesh for which we need to use its material
  53799. */
  53800. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53801. /**
  53802. * Remove a mesh from being rendered through its own material and not with emissive only.
  53803. * @param mesh The mesh for which we need to not use its material
  53804. */
  53805. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53806. /**
  53807. * Free any resources and references associated to a mesh.
  53808. * Internal use
  53809. * @param mesh The mesh to free.
  53810. * @hidden
  53811. */
  53812. _disposeMesh(mesh: Mesh): void;
  53813. /**
  53814. * Gets the class name of the effect layer
  53815. * @returns the string with the class name of the effect layer
  53816. */
  53817. getClassName(): string;
  53818. /**
  53819. * Serializes this glow layer
  53820. * @returns a serialized glow layer object
  53821. */
  53822. serialize(): any;
  53823. /**
  53824. * Creates a Glow Layer from parsed glow layer data
  53825. * @param parsedGlowLayer defines glow layer data
  53826. * @param scene defines the current scene
  53827. * @param rootUrl defines the root URL containing the glow layer information
  53828. * @returns a parsed Glow Layer
  53829. */
  53830. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53831. }
  53832. }
  53833. declare module BABYLON {
  53834. /** @hidden */
  53835. export var glowBlurPostProcessPixelShader: {
  53836. name: string;
  53837. shader: string;
  53838. };
  53839. }
  53840. declare module BABYLON {
  53841. interface AbstractScene {
  53842. /**
  53843. * Return a the first highlight layer of the scene with a given name.
  53844. * @param name The name of the highlight layer to look for.
  53845. * @return The highlight layer if found otherwise null.
  53846. */
  53847. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53848. }
  53849. /**
  53850. * Highlight layer options. This helps customizing the behaviour
  53851. * of the highlight layer.
  53852. */
  53853. export interface IHighlightLayerOptions {
  53854. /**
  53855. * Multiplication factor apply to the canvas size to compute the render target size
  53856. * used to generated the glowing objects (the smaller the faster).
  53857. */
  53858. mainTextureRatio: number;
  53859. /**
  53860. * Enforces a fixed size texture to ensure resize independant blur.
  53861. */
  53862. mainTextureFixedSize?: number;
  53863. /**
  53864. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53865. * of the picture to blur (the smaller the faster).
  53866. */
  53867. blurTextureSizeRatio: number;
  53868. /**
  53869. * How big in texel of the blur texture is the vertical blur.
  53870. */
  53871. blurVerticalSize: number;
  53872. /**
  53873. * How big in texel of the blur texture is the horizontal blur.
  53874. */
  53875. blurHorizontalSize: number;
  53876. /**
  53877. * Alpha blending mode used to apply the blur. Default is combine.
  53878. */
  53879. alphaBlendingMode: number;
  53880. /**
  53881. * The camera attached to the layer.
  53882. */
  53883. camera: Nullable<Camera>;
  53884. /**
  53885. * Should we display highlight as a solid stroke?
  53886. */
  53887. isStroke?: boolean;
  53888. /**
  53889. * The rendering group to draw the layer in.
  53890. */
  53891. renderingGroupId: number;
  53892. }
  53893. /**
  53894. * The highlight layer Helps adding a glow effect around a mesh.
  53895. *
  53896. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53897. * glowy meshes to your scene.
  53898. *
  53899. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53900. */
  53901. export class HighlightLayer extends EffectLayer {
  53902. name: string;
  53903. /**
  53904. * Effect Name of the highlight layer.
  53905. */
  53906. static readonly EffectName: string;
  53907. /**
  53908. * The neutral color used during the preparation of the glow effect.
  53909. * This is black by default as the blend operation is a blend operation.
  53910. */
  53911. static NeutralColor: Color4;
  53912. /**
  53913. * Stencil value used for glowing meshes.
  53914. */
  53915. static GlowingMeshStencilReference: number;
  53916. /**
  53917. * Stencil value used for the other meshes in the scene.
  53918. */
  53919. static NormalMeshStencilReference: number;
  53920. /**
  53921. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53922. */
  53923. innerGlow: boolean;
  53924. /**
  53925. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53926. */
  53927. outerGlow: boolean;
  53928. /**
  53929. * Specifies the horizontal size of the blur.
  53930. */
  53931. set blurHorizontalSize(value: number);
  53932. /**
  53933. * Specifies the vertical size of the blur.
  53934. */
  53935. set blurVerticalSize(value: number);
  53936. /**
  53937. * Gets the horizontal size of the blur.
  53938. */
  53939. get blurHorizontalSize(): number;
  53940. /**
  53941. * Gets the vertical size of the blur.
  53942. */
  53943. get blurVerticalSize(): number;
  53944. /**
  53945. * An event triggered when the highlight layer is being blurred.
  53946. */
  53947. onBeforeBlurObservable: Observable<HighlightLayer>;
  53948. /**
  53949. * An event triggered when the highlight layer has been blurred.
  53950. */
  53951. onAfterBlurObservable: Observable<HighlightLayer>;
  53952. private _instanceGlowingMeshStencilReference;
  53953. private _options;
  53954. private _downSamplePostprocess;
  53955. private _horizontalBlurPostprocess;
  53956. private _verticalBlurPostprocess;
  53957. private _blurTexture;
  53958. private _meshes;
  53959. private _excludedMeshes;
  53960. /**
  53961. * Instantiates a new highlight Layer and references it to the scene..
  53962. * @param name The name of the layer
  53963. * @param scene The scene to use the layer in
  53964. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53965. */
  53966. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53967. /**
  53968. * Get the effect name of the layer.
  53969. * @return The effect name
  53970. */
  53971. getEffectName(): string;
  53972. /**
  53973. * Create the merge effect. This is the shader use to blit the information back
  53974. * to the main canvas at the end of the scene rendering.
  53975. */
  53976. protected _createMergeEffect(): Effect;
  53977. /**
  53978. * Creates the render target textures and post processes used in the highlight layer.
  53979. */
  53980. protected _createTextureAndPostProcesses(): void;
  53981. /**
  53982. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53983. */
  53984. needStencil(): boolean;
  53985. /**
  53986. * Checks for the readiness of the element composing the layer.
  53987. * @param subMesh the mesh to check for
  53988. * @param useInstances specify wether or not to use instances to render the mesh
  53989. * @param emissiveTexture the associated emissive texture used to generate the glow
  53990. * @return true if ready otherwise, false
  53991. */
  53992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53993. /**
  53994. * Implementation specific of rendering the generating effect on the main canvas.
  53995. * @param effect The effect used to render through
  53996. */
  53997. protected _internalRender(effect: Effect): void;
  53998. /**
  53999. * Returns true if the layer contains information to display, otherwise false.
  54000. */
  54001. shouldRender(): boolean;
  54002. /**
  54003. * Returns true if the mesh should render, otherwise false.
  54004. * @param mesh The mesh to render
  54005. * @returns true if it should render otherwise false
  54006. */
  54007. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54008. /**
  54009. * Adds specific effects defines.
  54010. * @param defines The defines to add specifics to.
  54011. */
  54012. protected _addCustomEffectDefines(defines: string[]): void;
  54013. /**
  54014. * Sets the required values for both the emissive texture and and the main color.
  54015. */
  54016. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54017. /**
  54018. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54019. * @param mesh The mesh to exclude from the highlight layer
  54020. */
  54021. addExcludedMesh(mesh: Mesh): void;
  54022. /**
  54023. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54024. * @param mesh The mesh to highlight
  54025. */
  54026. removeExcludedMesh(mesh: Mesh): void;
  54027. /**
  54028. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54029. * @param mesh mesh to test
  54030. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54031. */
  54032. hasMesh(mesh: AbstractMesh): boolean;
  54033. /**
  54034. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54035. * @param mesh The mesh to highlight
  54036. * @param color The color of the highlight
  54037. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54038. */
  54039. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54040. /**
  54041. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54042. * @param mesh The mesh to highlight
  54043. */
  54044. removeMesh(mesh: Mesh): void;
  54045. /**
  54046. * Remove all the meshes currently referenced in the highlight layer
  54047. */
  54048. removeAllMeshes(): void;
  54049. /**
  54050. * Force the stencil to the normal expected value for none glowing parts
  54051. */
  54052. private _defaultStencilReference;
  54053. /**
  54054. * Free any resources and references associated to a mesh.
  54055. * Internal use
  54056. * @param mesh The mesh to free.
  54057. * @hidden
  54058. */
  54059. _disposeMesh(mesh: Mesh): void;
  54060. /**
  54061. * Dispose the highlight layer and free resources.
  54062. */
  54063. dispose(): void;
  54064. /**
  54065. * Gets the class name of the effect layer
  54066. * @returns the string with the class name of the effect layer
  54067. */
  54068. getClassName(): string;
  54069. /**
  54070. * Serializes this Highlight layer
  54071. * @returns a serialized Highlight layer object
  54072. */
  54073. serialize(): any;
  54074. /**
  54075. * Creates a Highlight layer from parsed Highlight layer data
  54076. * @param parsedHightlightLayer defines the Highlight layer data
  54077. * @param scene defines the current scene
  54078. * @param rootUrl defines the root URL containing the Highlight layer information
  54079. * @returns a parsed Highlight layer
  54080. */
  54081. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54082. }
  54083. }
  54084. declare module BABYLON {
  54085. interface AbstractScene {
  54086. /**
  54087. * The list of layers (background and foreground) of the scene
  54088. */
  54089. layers: Array<Layer>;
  54090. }
  54091. /**
  54092. * Defines the layer scene component responsible to manage any layers
  54093. * in a given scene.
  54094. */
  54095. export class LayerSceneComponent implements ISceneComponent {
  54096. /**
  54097. * The component name helpfull to identify the component in the list of scene components.
  54098. */
  54099. readonly name: string;
  54100. /**
  54101. * The scene the component belongs to.
  54102. */
  54103. scene: Scene;
  54104. private _engine;
  54105. /**
  54106. * Creates a new instance of the component for the given scene
  54107. * @param scene Defines the scene to register the component in
  54108. */
  54109. constructor(scene: Scene);
  54110. /**
  54111. * Registers the component in a given scene
  54112. */
  54113. register(): void;
  54114. /**
  54115. * Rebuilds the elements related to this component in case of
  54116. * context lost for instance.
  54117. */
  54118. rebuild(): void;
  54119. /**
  54120. * Disposes the component and the associated ressources.
  54121. */
  54122. dispose(): void;
  54123. private _draw;
  54124. private _drawCameraPredicate;
  54125. private _drawCameraBackground;
  54126. private _drawCameraForeground;
  54127. private _drawRenderTargetPredicate;
  54128. private _drawRenderTargetBackground;
  54129. private _drawRenderTargetForeground;
  54130. /**
  54131. * Adds all the elements from the container to the scene
  54132. * @param container the container holding the elements
  54133. */
  54134. addFromContainer(container: AbstractScene): void;
  54135. /**
  54136. * Removes all the elements in the container from the scene
  54137. * @param container contains the elements to remove
  54138. * @param dispose if the removed element should be disposed (default: false)
  54139. */
  54140. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54141. }
  54142. }
  54143. declare module BABYLON {
  54144. /** @hidden */
  54145. export var layerPixelShader: {
  54146. name: string;
  54147. shader: string;
  54148. };
  54149. }
  54150. declare module BABYLON {
  54151. /** @hidden */
  54152. export var layerVertexShader: {
  54153. name: string;
  54154. shader: string;
  54155. };
  54156. }
  54157. declare module BABYLON {
  54158. /**
  54159. * This represents a full screen 2d layer.
  54160. * This can be useful to display a picture in the background of your scene for instance.
  54161. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54162. */
  54163. export class Layer {
  54164. /**
  54165. * Define the name of the layer.
  54166. */
  54167. name: string;
  54168. /**
  54169. * Define the texture the layer should display.
  54170. */
  54171. texture: Nullable<Texture>;
  54172. /**
  54173. * Is the layer in background or foreground.
  54174. */
  54175. isBackground: boolean;
  54176. /**
  54177. * Define the color of the layer (instead of texture).
  54178. */
  54179. color: Color4;
  54180. /**
  54181. * Define the scale of the layer in order to zoom in out of the texture.
  54182. */
  54183. scale: Vector2;
  54184. /**
  54185. * Define an offset for the layer in order to shift the texture.
  54186. */
  54187. offset: Vector2;
  54188. /**
  54189. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54190. */
  54191. alphaBlendingMode: number;
  54192. /**
  54193. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54194. * Alpha test will not mix with the background color in case of transparency.
  54195. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54196. */
  54197. alphaTest: boolean;
  54198. /**
  54199. * Define a mask to restrict the layer to only some of the scene cameras.
  54200. */
  54201. layerMask: number;
  54202. /**
  54203. * Define the list of render target the layer is visible into.
  54204. */
  54205. renderTargetTextures: RenderTargetTexture[];
  54206. /**
  54207. * Define if the layer is only used in renderTarget or if it also
  54208. * renders in the main frame buffer of the canvas.
  54209. */
  54210. renderOnlyInRenderTargetTextures: boolean;
  54211. private _scene;
  54212. private _vertexBuffers;
  54213. private _indexBuffer;
  54214. private _effect;
  54215. private _previousDefines;
  54216. /**
  54217. * An event triggered when the layer is disposed.
  54218. */
  54219. onDisposeObservable: Observable<Layer>;
  54220. private _onDisposeObserver;
  54221. /**
  54222. * Back compatibility with callback before the onDisposeObservable existed.
  54223. * The set callback will be triggered when the layer has been disposed.
  54224. */
  54225. set onDispose(callback: () => void);
  54226. /**
  54227. * An event triggered before rendering the scene
  54228. */
  54229. onBeforeRenderObservable: Observable<Layer>;
  54230. private _onBeforeRenderObserver;
  54231. /**
  54232. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54233. * The set callback will be triggered just before rendering the layer.
  54234. */
  54235. set onBeforeRender(callback: () => void);
  54236. /**
  54237. * An event triggered after rendering the scene
  54238. */
  54239. onAfterRenderObservable: Observable<Layer>;
  54240. private _onAfterRenderObserver;
  54241. /**
  54242. * Back compatibility with callback before the onAfterRenderObservable existed.
  54243. * The set callback will be triggered just after rendering the layer.
  54244. */
  54245. set onAfterRender(callback: () => void);
  54246. /**
  54247. * Instantiates a new layer.
  54248. * This represents a full screen 2d layer.
  54249. * This can be useful to display a picture in the background of your scene for instance.
  54250. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54251. * @param name Define the name of the layer in the scene
  54252. * @param imgUrl Define the url of the texture to display in the layer
  54253. * @param scene Define the scene the layer belongs to
  54254. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54255. * @param color Defines a color for the layer
  54256. */
  54257. constructor(
  54258. /**
  54259. * Define the name of the layer.
  54260. */
  54261. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54262. private _createIndexBuffer;
  54263. /** @hidden */
  54264. _rebuild(): void;
  54265. /**
  54266. * Renders the layer in the scene.
  54267. */
  54268. render(): void;
  54269. /**
  54270. * Disposes and releases the associated ressources.
  54271. */
  54272. dispose(): void;
  54273. }
  54274. }
  54275. declare module BABYLON {
  54276. /** @hidden */
  54277. export var lensFlarePixelShader: {
  54278. name: string;
  54279. shader: string;
  54280. };
  54281. }
  54282. declare module BABYLON {
  54283. /** @hidden */
  54284. export var lensFlareVertexShader: {
  54285. name: string;
  54286. shader: string;
  54287. };
  54288. }
  54289. declare module BABYLON {
  54290. /**
  54291. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54292. * It is usually composed of several `lensFlare`.
  54293. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54294. */
  54295. export class LensFlareSystem {
  54296. /**
  54297. * Define the name of the lens flare system
  54298. */
  54299. name: string;
  54300. /**
  54301. * List of lens flares used in this system.
  54302. */
  54303. lensFlares: LensFlare[];
  54304. /**
  54305. * Define a limit from the border the lens flare can be visible.
  54306. */
  54307. borderLimit: number;
  54308. /**
  54309. * Define a viewport border we do not want to see the lens flare in.
  54310. */
  54311. viewportBorder: number;
  54312. /**
  54313. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54314. */
  54315. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54316. /**
  54317. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54318. */
  54319. layerMask: number;
  54320. /**
  54321. * Define the id of the lens flare system in the scene.
  54322. * (equal to name by default)
  54323. */
  54324. id: string;
  54325. private _scene;
  54326. private _emitter;
  54327. private _vertexBuffers;
  54328. private _indexBuffer;
  54329. private _effect;
  54330. private _positionX;
  54331. private _positionY;
  54332. private _isEnabled;
  54333. /** @hidden */
  54334. static _SceneComponentInitialization: (scene: Scene) => void;
  54335. /**
  54336. * Instantiates a lens flare system.
  54337. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54338. * It is usually composed of several `lensFlare`.
  54339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54340. * @param name Define the name of the lens flare system in the scene
  54341. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54342. * @param scene Define the scene the lens flare system belongs to
  54343. */
  54344. constructor(
  54345. /**
  54346. * Define the name of the lens flare system
  54347. */
  54348. name: string, emitter: any, scene: Scene);
  54349. /**
  54350. * Define if the lens flare system is enabled.
  54351. */
  54352. get isEnabled(): boolean;
  54353. set isEnabled(value: boolean);
  54354. /**
  54355. * Get the scene the effects belongs to.
  54356. * @returns the scene holding the lens flare system
  54357. */
  54358. getScene(): Scene;
  54359. /**
  54360. * Get the emitter of the lens flare system.
  54361. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54362. * @returns the emitter of the lens flare system
  54363. */
  54364. getEmitter(): any;
  54365. /**
  54366. * Set the emitter of the lens flare system.
  54367. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54368. * @param newEmitter Define the new emitter of the system
  54369. */
  54370. setEmitter(newEmitter: any): void;
  54371. /**
  54372. * Get the lens flare system emitter position.
  54373. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54374. * @returns the position
  54375. */
  54376. getEmitterPosition(): Vector3;
  54377. /**
  54378. * @hidden
  54379. */
  54380. computeEffectivePosition(globalViewport: Viewport): boolean;
  54381. /** @hidden */
  54382. _isVisible(): boolean;
  54383. /**
  54384. * @hidden
  54385. */
  54386. render(): boolean;
  54387. /**
  54388. * Dispose and release the lens flare with its associated resources.
  54389. */
  54390. dispose(): void;
  54391. /**
  54392. * Parse a lens flare system from a JSON repressentation
  54393. * @param parsedLensFlareSystem Define the JSON to parse
  54394. * @param scene Define the scene the parsed system should be instantiated in
  54395. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54396. * @returns the parsed system
  54397. */
  54398. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54399. /**
  54400. * Serialize the current Lens Flare System into a JSON representation.
  54401. * @returns the serialized JSON
  54402. */
  54403. serialize(): any;
  54404. }
  54405. }
  54406. declare module BABYLON {
  54407. /**
  54408. * This represents one of the lens effect in a `lensFlareSystem`.
  54409. * It controls one of the indiviual texture used in the effect.
  54410. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54411. */
  54412. export class LensFlare {
  54413. /**
  54414. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54415. */
  54416. size: number;
  54417. /**
  54418. * 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.
  54419. */
  54420. position: number;
  54421. /**
  54422. * Define the lens color.
  54423. */
  54424. color: Color3;
  54425. /**
  54426. * Define the lens texture.
  54427. */
  54428. texture: Nullable<Texture>;
  54429. /**
  54430. * Define the alpha mode to render this particular lens.
  54431. */
  54432. alphaMode: number;
  54433. private _system;
  54434. /**
  54435. * Creates a new Lens Flare.
  54436. * This represents one of the lens effect in a `lensFlareSystem`.
  54437. * It controls one of the indiviual texture used in the effect.
  54438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54439. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54440. * @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.
  54441. * @param color Define the lens color
  54442. * @param imgUrl Define the lens texture url
  54443. * @param system Define the `lensFlareSystem` this flare is part of
  54444. * @returns The newly created Lens Flare
  54445. */
  54446. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54447. /**
  54448. * Instantiates a new Lens Flare.
  54449. * This represents one of the lens effect in a `lensFlareSystem`.
  54450. * It controls one of the indiviual texture used in the effect.
  54451. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54452. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54453. * @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.
  54454. * @param color Define the lens color
  54455. * @param imgUrl Define the lens texture url
  54456. * @param system Define the `lensFlareSystem` this flare is part of
  54457. */
  54458. constructor(
  54459. /**
  54460. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54461. */
  54462. size: number,
  54463. /**
  54464. * 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.
  54465. */
  54466. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54467. /**
  54468. * Dispose and release the lens flare with its associated resources.
  54469. */
  54470. dispose(): void;
  54471. }
  54472. }
  54473. declare module BABYLON {
  54474. interface AbstractScene {
  54475. /**
  54476. * The list of lens flare system added to the scene
  54477. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54478. */
  54479. lensFlareSystems: Array<LensFlareSystem>;
  54480. /**
  54481. * Removes the given lens flare system from this scene.
  54482. * @param toRemove The lens flare system to remove
  54483. * @returns The index of the removed lens flare system
  54484. */
  54485. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54486. /**
  54487. * Adds the given lens flare system to this scene
  54488. * @param newLensFlareSystem The lens flare system to add
  54489. */
  54490. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54491. /**
  54492. * Gets a lens flare system using its name
  54493. * @param name defines the name to look for
  54494. * @returns the lens flare system or null if not found
  54495. */
  54496. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54497. /**
  54498. * Gets a lens flare system using its id
  54499. * @param id defines the id to look for
  54500. * @returns the lens flare system or null if not found
  54501. */
  54502. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54503. }
  54504. /**
  54505. * Defines the lens flare scene component responsible to manage any lens flares
  54506. * in a given scene.
  54507. */
  54508. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54509. /**
  54510. * The component name helpfull to identify the component in the list of scene components.
  54511. */
  54512. readonly name: string;
  54513. /**
  54514. * The scene the component belongs to.
  54515. */
  54516. scene: Scene;
  54517. /**
  54518. * Creates a new instance of the component for the given scene
  54519. * @param scene Defines the scene to register the component in
  54520. */
  54521. constructor(scene: Scene);
  54522. /**
  54523. * Registers the component in a given scene
  54524. */
  54525. register(): void;
  54526. /**
  54527. * Rebuilds the elements related to this component in case of
  54528. * context lost for instance.
  54529. */
  54530. rebuild(): void;
  54531. /**
  54532. * Adds all the elements from the container to the scene
  54533. * @param container the container holding the elements
  54534. */
  54535. addFromContainer(container: AbstractScene): void;
  54536. /**
  54537. * Removes all the elements in the container from the scene
  54538. * @param container contains the elements to remove
  54539. * @param dispose if the removed element should be disposed (default: false)
  54540. */
  54541. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54542. /**
  54543. * Serializes the component data to the specified json object
  54544. * @param serializationObject The object to serialize to
  54545. */
  54546. serialize(serializationObject: any): void;
  54547. /**
  54548. * Disposes the component and the associated ressources.
  54549. */
  54550. dispose(): void;
  54551. private _draw;
  54552. }
  54553. }
  54554. declare module BABYLON {
  54555. /** @hidden */
  54556. export var depthPixelShader: {
  54557. name: string;
  54558. shader: string;
  54559. };
  54560. }
  54561. declare module BABYLON {
  54562. /** @hidden */
  54563. export var depthVertexShader: {
  54564. name: string;
  54565. shader: string;
  54566. };
  54567. }
  54568. declare module BABYLON {
  54569. /**
  54570. * This represents a depth renderer in Babylon.
  54571. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54572. */
  54573. export class DepthRenderer {
  54574. private _scene;
  54575. private _depthMap;
  54576. private _effect;
  54577. private readonly _storeNonLinearDepth;
  54578. private readonly _clearColor;
  54579. /** Get if the depth renderer is using packed depth or not */
  54580. readonly isPacked: boolean;
  54581. private _cachedDefines;
  54582. private _camera;
  54583. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54584. enabled: boolean;
  54585. /**
  54586. * Specifiess that the depth renderer will only be used within
  54587. * the camera it is created for.
  54588. * This can help forcing its rendering during the camera processing.
  54589. */
  54590. useOnlyInActiveCamera: boolean;
  54591. /** @hidden */
  54592. static _SceneComponentInitialization: (scene: Scene) => void;
  54593. /**
  54594. * Instantiates a depth renderer
  54595. * @param scene The scene the renderer belongs to
  54596. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54597. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54598. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54599. */
  54600. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54601. /**
  54602. * Creates the depth rendering effect and checks if the effect is ready.
  54603. * @param subMesh The submesh to be used to render the depth map of
  54604. * @param useInstances If multiple world instances should be used
  54605. * @returns if the depth renderer is ready to render the depth map
  54606. */
  54607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54608. /**
  54609. * Gets the texture which the depth map will be written to.
  54610. * @returns The depth map texture
  54611. */
  54612. getDepthMap(): RenderTargetTexture;
  54613. /**
  54614. * Disposes of the depth renderer.
  54615. */
  54616. dispose(): void;
  54617. }
  54618. }
  54619. declare module BABYLON {
  54620. /** @hidden */
  54621. export var minmaxReduxPixelShader: {
  54622. name: string;
  54623. shader: string;
  54624. };
  54625. }
  54626. declare module BABYLON {
  54627. /**
  54628. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54629. * and maximum values from all values of the texture.
  54630. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54631. * The source values are read from the red channel of the texture.
  54632. */
  54633. export class MinMaxReducer {
  54634. /**
  54635. * Observable triggered when the computation has been performed
  54636. */
  54637. onAfterReductionPerformed: Observable<{
  54638. min: number;
  54639. max: number;
  54640. }>;
  54641. protected _camera: Camera;
  54642. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54643. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54644. protected _postProcessManager: PostProcessManager;
  54645. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54646. protected _forceFullscreenViewport: boolean;
  54647. /**
  54648. * Creates a min/max reducer
  54649. * @param camera The camera to use for the post processes
  54650. */
  54651. constructor(camera: Camera);
  54652. /**
  54653. * Gets the texture used to read the values from.
  54654. */
  54655. get sourceTexture(): Nullable<RenderTargetTexture>;
  54656. /**
  54657. * Sets the source texture to read the values from.
  54658. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54659. * because in such textures '1' value must not be taken into account to compute the maximum
  54660. * as this value is used to clear the texture.
  54661. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54662. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54663. * @param depthRedux Indicates if the texture is a depth texture or not
  54664. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54665. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54666. */
  54667. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54668. /**
  54669. * Defines the refresh rate of the computation.
  54670. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54671. */
  54672. get refreshRate(): number;
  54673. set refreshRate(value: number);
  54674. protected _activated: boolean;
  54675. /**
  54676. * Gets the activation status of the reducer
  54677. */
  54678. get activated(): boolean;
  54679. /**
  54680. * Activates the reduction computation.
  54681. * When activated, the observers registered in onAfterReductionPerformed are
  54682. * called after the compuation is performed
  54683. */
  54684. activate(): void;
  54685. /**
  54686. * Deactivates the reduction computation.
  54687. */
  54688. deactivate(): void;
  54689. /**
  54690. * Disposes the min/max reducer
  54691. * @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.
  54692. */
  54693. dispose(disposeAll?: boolean): void;
  54694. }
  54695. }
  54696. declare module BABYLON {
  54697. /**
  54698. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54699. */
  54700. export class DepthReducer extends MinMaxReducer {
  54701. private _depthRenderer;
  54702. private _depthRendererId;
  54703. /**
  54704. * Gets the depth renderer used for the computation.
  54705. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54706. */
  54707. get depthRenderer(): Nullable<DepthRenderer>;
  54708. /**
  54709. * Creates a depth reducer
  54710. * @param camera The camera used to render the depth texture
  54711. */
  54712. constructor(camera: Camera);
  54713. /**
  54714. * Sets the depth renderer to use to generate the depth map
  54715. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54716. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54717. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54718. */
  54719. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54720. /** @hidden */
  54721. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54722. /**
  54723. * Activates the reduction computation.
  54724. * When activated, the observers registered in onAfterReductionPerformed are
  54725. * called after the compuation is performed
  54726. */
  54727. activate(): void;
  54728. /**
  54729. * Deactivates the reduction computation.
  54730. */
  54731. deactivate(): void;
  54732. /**
  54733. * Disposes the depth reducer
  54734. * @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.
  54735. */
  54736. dispose(disposeAll?: boolean): void;
  54737. }
  54738. }
  54739. declare module BABYLON {
  54740. /**
  54741. * A CSM implementation allowing casting shadows on large scenes.
  54742. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54743. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54744. */
  54745. export class CascadedShadowGenerator extends ShadowGenerator {
  54746. private static readonly frustumCornersNDCSpace;
  54747. /**
  54748. * Name of the CSM class
  54749. */
  54750. static CLASSNAME: string;
  54751. /**
  54752. * Defines the default number of cascades used by the CSM.
  54753. */
  54754. static readonly DEFAULT_CASCADES_COUNT: number;
  54755. /**
  54756. * Defines the minimum number of cascades used by the CSM.
  54757. */
  54758. static readonly MIN_CASCADES_COUNT: number;
  54759. /**
  54760. * Defines the maximum number of cascades used by the CSM.
  54761. */
  54762. static readonly MAX_CASCADES_COUNT: number;
  54763. protected _validateFilter(filter: number): number;
  54764. /**
  54765. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54766. */
  54767. penumbraDarkness: number;
  54768. private _numCascades;
  54769. /**
  54770. * Gets or set the number of cascades used by the CSM.
  54771. */
  54772. get numCascades(): number;
  54773. set numCascades(value: number);
  54774. /**
  54775. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54776. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54777. */
  54778. stabilizeCascades: boolean;
  54779. private _freezeShadowCastersBoundingInfo;
  54780. private _freezeShadowCastersBoundingInfoObservable;
  54781. /**
  54782. * Enables or disables the shadow casters bounding info computation.
  54783. * If your shadow casters don't move, you can disable this feature.
  54784. * If it is enabled, the bounding box computation is done every frame.
  54785. */
  54786. get freezeShadowCastersBoundingInfo(): boolean;
  54787. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54788. private _scbiMin;
  54789. private _scbiMax;
  54790. protected _computeShadowCastersBoundingInfo(): void;
  54791. protected _shadowCastersBoundingInfo: BoundingInfo;
  54792. /**
  54793. * Gets or sets the shadow casters bounding info.
  54794. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54795. * so that the system won't overwrite the bounds you provide
  54796. */
  54797. get shadowCastersBoundingInfo(): BoundingInfo;
  54798. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54799. protected _breaksAreDirty: boolean;
  54800. protected _minDistance: number;
  54801. protected _maxDistance: number;
  54802. /**
  54803. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54804. *
  54805. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54806. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54807. * @param min minimal distance for the breaks (default to 0.)
  54808. * @param max maximal distance for the breaks (default to 1.)
  54809. */
  54810. setMinMaxDistance(min: number, max: number): void;
  54811. /** Gets the minimal distance used in the cascade break computation */
  54812. get minDistance(): number;
  54813. /** Gets the maximal distance used in the cascade break computation */
  54814. get maxDistance(): number;
  54815. /**
  54816. * Gets the class name of that object
  54817. * @returns "CascadedShadowGenerator"
  54818. */
  54819. getClassName(): string;
  54820. private _cascadeMinExtents;
  54821. private _cascadeMaxExtents;
  54822. /**
  54823. * Gets a cascade minimum extents
  54824. * @param cascadeIndex index of the cascade
  54825. * @returns the minimum cascade extents
  54826. */
  54827. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54828. /**
  54829. * Gets a cascade maximum extents
  54830. * @param cascadeIndex index of the cascade
  54831. * @returns the maximum cascade extents
  54832. */
  54833. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54834. private _cascades;
  54835. private _currentLayer;
  54836. private _viewSpaceFrustumsZ;
  54837. private _viewMatrices;
  54838. private _projectionMatrices;
  54839. private _transformMatrices;
  54840. private _transformMatricesAsArray;
  54841. private _frustumLengths;
  54842. private _lightSizeUVCorrection;
  54843. private _depthCorrection;
  54844. private _frustumCornersWorldSpace;
  54845. private _frustumCenter;
  54846. private _shadowCameraPos;
  54847. private _shadowMaxZ;
  54848. /**
  54849. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54850. * It defaults to camera.maxZ
  54851. */
  54852. get shadowMaxZ(): number;
  54853. /**
  54854. * Sets the shadow max z distance.
  54855. */
  54856. set shadowMaxZ(value: number);
  54857. protected _debug: boolean;
  54858. /**
  54859. * Gets or sets the debug flag.
  54860. * When enabled, the cascades are materialized by different colors on the screen.
  54861. */
  54862. get debug(): boolean;
  54863. set debug(dbg: boolean);
  54864. private _depthClamp;
  54865. /**
  54866. * Gets or sets the depth clamping value.
  54867. *
  54868. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54869. * to account for the shadow casters far away.
  54870. *
  54871. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54872. */
  54873. get depthClamp(): boolean;
  54874. set depthClamp(value: boolean);
  54875. private _cascadeBlendPercentage;
  54876. /**
  54877. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54878. * It defaults to 0.1 (10% blending).
  54879. */
  54880. get cascadeBlendPercentage(): number;
  54881. set cascadeBlendPercentage(value: number);
  54882. private _lambda;
  54883. /**
  54884. * Gets or set the lambda parameter.
  54885. * This parameter is used to split the camera frustum and create the cascades.
  54886. * 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.
  54887. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54888. */
  54889. get lambda(): number;
  54890. set lambda(value: number);
  54891. /**
  54892. * Gets the view matrix corresponding to a given cascade
  54893. * @param cascadeNum cascade to retrieve the view matrix from
  54894. * @returns the cascade view matrix
  54895. */
  54896. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54897. /**
  54898. * Gets the projection matrix corresponding to a given cascade
  54899. * @param cascadeNum cascade to retrieve the projection matrix from
  54900. * @returns the cascade projection matrix
  54901. */
  54902. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54903. /**
  54904. * Gets the transformation matrix corresponding to a given cascade
  54905. * @param cascadeNum cascade to retrieve the transformation matrix from
  54906. * @returns the cascade transformation matrix
  54907. */
  54908. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54909. private _depthRenderer;
  54910. /**
  54911. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54912. *
  54913. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54914. *
  54915. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54916. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54917. * @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
  54918. */
  54919. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54920. private _depthReducer;
  54921. private _autoCalcDepthBounds;
  54922. /**
  54923. * Gets or sets the autoCalcDepthBounds property.
  54924. *
  54925. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54926. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54927. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54928. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54929. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54930. */
  54931. get autoCalcDepthBounds(): boolean;
  54932. set autoCalcDepthBounds(value: boolean);
  54933. /**
  54934. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54935. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54936. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54937. * for setting the refresh rate on the renderer yourself!
  54938. */
  54939. get autoCalcDepthBoundsRefreshRate(): number;
  54940. set autoCalcDepthBoundsRefreshRate(value: number);
  54941. /**
  54942. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54943. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54944. * you change the camera near/far planes!
  54945. */
  54946. splitFrustum(): void;
  54947. private _splitFrustum;
  54948. private _computeMatrices;
  54949. private _computeFrustumInWorldSpace;
  54950. private _computeCascadeFrustum;
  54951. /**
  54952. * Support test.
  54953. */
  54954. static get IsSupported(): boolean;
  54955. /** @hidden */
  54956. static _SceneComponentInitialization: (scene: Scene) => void;
  54957. /**
  54958. * Creates a Cascaded Shadow Generator object.
  54959. * A ShadowGenerator is the required tool to use the shadows.
  54960. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54961. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54962. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54963. * @param light The directional light object generating the shadows.
  54964. * @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.
  54965. */
  54966. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54967. protected _initializeGenerator(): void;
  54968. protected _createTargetRenderTexture(): void;
  54969. protected _initializeShadowMap(): void;
  54970. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54971. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54972. /**
  54973. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54974. * @param defines Defines of the material we want to update
  54975. * @param lightIndex Index of the light in the enabled light list of the material
  54976. */
  54977. prepareDefines(defines: any, lightIndex: number): void;
  54978. /**
  54979. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54980. * defined in the generator but impacting the effect).
  54981. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54982. * @param effect The effect we are binfing the information for
  54983. */
  54984. bindShadowLight(lightIndex: string, effect: Effect): void;
  54985. /**
  54986. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54987. * (eq to view projection * shadow projection matrices)
  54988. * @returns The transform matrix used to create the shadow map
  54989. */
  54990. getTransformMatrix(): Matrix;
  54991. /**
  54992. * Disposes the ShadowGenerator.
  54993. * Returns nothing.
  54994. */
  54995. dispose(): void;
  54996. /**
  54997. * Serializes the shadow generator setup to a json object.
  54998. * @returns The serialized JSON object
  54999. */
  55000. serialize(): any;
  55001. /**
  55002. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55003. * @param parsedShadowGenerator The JSON object to parse
  55004. * @param scene The scene to create the shadow map for
  55005. * @returns The parsed shadow generator
  55006. */
  55007. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55008. }
  55009. }
  55010. declare module BABYLON {
  55011. /**
  55012. * Defines the shadow generator component responsible to manage any shadow generators
  55013. * in a given scene.
  55014. */
  55015. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55016. /**
  55017. * The component name helpfull to identify the component in the list of scene components.
  55018. */
  55019. readonly name: string;
  55020. /**
  55021. * The scene the component belongs to.
  55022. */
  55023. scene: Scene;
  55024. /**
  55025. * Creates a new instance of the component for the given scene
  55026. * @param scene Defines the scene to register the component in
  55027. */
  55028. constructor(scene: Scene);
  55029. /**
  55030. * Registers the component in a given scene
  55031. */
  55032. register(): void;
  55033. /**
  55034. * Rebuilds the elements related to this component in case of
  55035. * context lost for instance.
  55036. */
  55037. rebuild(): void;
  55038. /**
  55039. * Serializes the component data to the specified json object
  55040. * @param serializationObject The object to serialize to
  55041. */
  55042. serialize(serializationObject: any): void;
  55043. /**
  55044. * Adds all the elements from the container to the scene
  55045. * @param container the container holding the elements
  55046. */
  55047. addFromContainer(container: AbstractScene): void;
  55048. /**
  55049. * Removes all the elements in the container from the scene
  55050. * @param container contains the elements to remove
  55051. * @param dispose if the removed element should be disposed (default: false)
  55052. */
  55053. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55054. /**
  55055. * Rebuilds the elements related to this component in case of
  55056. * context lost for instance.
  55057. */
  55058. dispose(): void;
  55059. private _gatherRenderTargets;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * A point light is a light defined by an unique point in world space.
  55065. * The light is emitted in every direction from this point.
  55066. * A good example of a point light is a standard light bulb.
  55067. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55068. */
  55069. export class PointLight extends ShadowLight {
  55070. private _shadowAngle;
  55071. /**
  55072. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55073. * This specifies what angle the shadow will use to be created.
  55074. *
  55075. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55076. */
  55077. get shadowAngle(): number;
  55078. /**
  55079. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55080. * This specifies what angle the shadow will use to be created.
  55081. *
  55082. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55083. */
  55084. set shadowAngle(value: number);
  55085. /**
  55086. * Gets the direction if it has been set.
  55087. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55088. */
  55089. get direction(): Vector3;
  55090. /**
  55091. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55092. */
  55093. set direction(value: Vector3);
  55094. /**
  55095. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55096. * A PointLight emits the light in every direction.
  55097. * It can cast shadows.
  55098. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55099. * ```javascript
  55100. * var pointLight = new PointLight("pl", camera.position, scene);
  55101. * ```
  55102. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55103. * @param name The light friendly name
  55104. * @param position The position of the point light in the scene
  55105. * @param scene The scene the lights belongs to
  55106. */
  55107. constructor(name: string, position: Vector3, scene: Scene);
  55108. /**
  55109. * Returns the string "PointLight"
  55110. * @returns the class name
  55111. */
  55112. getClassName(): string;
  55113. /**
  55114. * Returns the integer 0.
  55115. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55116. */
  55117. getTypeID(): number;
  55118. /**
  55119. * Specifies wether or not the shadowmap should be a cube texture.
  55120. * @returns true if the shadowmap needs to be a cube texture.
  55121. */
  55122. needCube(): boolean;
  55123. /**
  55124. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55125. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55126. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55127. */
  55128. getShadowDirection(faceIndex?: number): Vector3;
  55129. /**
  55130. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55131. * - fov = PI / 2
  55132. * - aspect ratio : 1.0
  55133. * - z-near and far equal to the active camera minZ and maxZ.
  55134. * Returns the PointLight.
  55135. */
  55136. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55137. protected _buildUniformLayout(): void;
  55138. /**
  55139. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55140. * @param effect The effect to update
  55141. * @param lightIndex The index of the light in the effect to update
  55142. * @returns The point light
  55143. */
  55144. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55145. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55146. /**
  55147. * Prepares the list of defines specific to the light type.
  55148. * @param defines the list of defines
  55149. * @param lightIndex defines the index of the light for the effect
  55150. */
  55151. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55152. }
  55153. }
  55154. declare module BABYLON {
  55155. /**
  55156. * Header information of HDR texture files.
  55157. */
  55158. export interface HDRInfo {
  55159. /**
  55160. * The height of the texture in pixels.
  55161. */
  55162. height: number;
  55163. /**
  55164. * The width of the texture in pixels.
  55165. */
  55166. width: number;
  55167. /**
  55168. * The index of the beginning of the data in the binary file.
  55169. */
  55170. dataPosition: number;
  55171. }
  55172. /**
  55173. * This groups tools to convert HDR texture to native colors array.
  55174. */
  55175. export class HDRTools {
  55176. private static Ldexp;
  55177. private static Rgbe2float;
  55178. private static readStringLine;
  55179. /**
  55180. * Reads header information from an RGBE texture stored in a native array.
  55181. * More information on this format are available here:
  55182. * https://en.wikipedia.org/wiki/RGBE_image_format
  55183. *
  55184. * @param uint8array The binary file stored in native array.
  55185. * @return The header information.
  55186. */
  55187. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55188. /**
  55189. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55190. * This RGBE texture needs to store the information as a panorama.
  55191. *
  55192. * More information on this format are available here:
  55193. * https://en.wikipedia.org/wiki/RGBE_image_format
  55194. *
  55195. * @param buffer The binary file stored in an array buffer.
  55196. * @param size The expected size of the extracted cubemap.
  55197. * @return The Cube Map information.
  55198. */
  55199. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55200. /**
  55201. * Returns the pixels data extracted from an RGBE texture.
  55202. * This pixels will be stored left to right up to down in the R G B order in one array.
  55203. *
  55204. * More information on this format are available here:
  55205. * https://en.wikipedia.org/wiki/RGBE_image_format
  55206. *
  55207. * @param uint8array The binary file stored in an array buffer.
  55208. * @param hdrInfo The header information of the file.
  55209. * @return The pixels data in RGB right to left up to down order.
  55210. */
  55211. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55212. private static RGBE_ReadPixels_RLE;
  55213. }
  55214. }
  55215. declare module BABYLON {
  55216. /**
  55217. * This represents a texture coming from an HDR input.
  55218. *
  55219. * The only supported format is currently panorama picture stored in RGBE format.
  55220. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55221. */
  55222. export class HDRCubeTexture extends BaseTexture {
  55223. private static _facesMapping;
  55224. private _generateHarmonics;
  55225. private _noMipmap;
  55226. private _textureMatrix;
  55227. private _size;
  55228. private _onLoad;
  55229. private _onError;
  55230. /**
  55231. * The texture URL.
  55232. */
  55233. url: string;
  55234. /**
  55235. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55236. */
  55237. coordinatesMode: number;
  55238. protected _isBlocking: boolean;
  55239. /**
  55240. * Sets wether or not the texture is blocking during loading.
  55241. */
  55242. set isBlocking(value: boolean);
  55243. /**
  55244. * Gets wether or not the texture is blocking during loading.
  55245. */
  55246. get isBlocking(): boolean;
  55247. protected _rotationY: number;
  55248. /**
  55249. * Sets texture matrix rotation angle around Y axis in radians.
  55250. */
  55251. set rotationY(value: number);
  55252. /**
  55253. * Gets texture matrix rotation angle around Y axis radians.
  55254. */
  55255. get rotationY(): number;
  55256. /**
  55257. * Gets or sets the center of the bounding box associated with the cube texture
  55258. * It must define where the camera used to render the texture was set
  55259. */
  55260. boundingBoxPosition: Vector3;
  55261. private _boundingBoxSize;
  55262. /**
  55263. * Gets or sets the size of the bounding box associated with the cube texture
  55264. * When defined, the cubemap will switch to local mode
  55265. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55266. * @example https://www.babylonjs-playground.com/#RNASML
  55267. */
  55268. set boundingBoxSize(value: Vector3);
  55269. get boundingBoxSize(): Vector3;
  55270. /**
  55271. * Instantiates an HDRTexture from the following parameters.
  55272. *
  55273. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55274. * @param scene The scene the texture will be used in
  55275. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55276. * @param noMipmap Forces to not generate the mipmap if true
  55277. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55278. * @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)
  55279. * @param reserved Reserved flag for internal use.
  55280. */
  55281. 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>);
  55282. /**
  55283. * Get the current class name of the texture useful for serialization or dynamic coding.
  55284. * @returns "HDRCubeTexture"
  55285. */
  55286. getClassName(): string;
  55287. /**
  55288. * Occurs when the file is raw .hdr file.
  55289. */
  55290. private loadTexture;
  55291. clone(): HDRCubeTexture;
  55292. delayLoad(): void;
  55293. /**
  55294. * Get the texture reflection matrix used to rotate/transform the reflection.
  55295. * @returns the reflection matrix
  55296. */
  55297. getReflectionTextureMatrix(): Matrix;
  55298. /**
  55299. * Set the texture reflection matrix used to rotate/transform the reflection.
  55300. * @param value Define the reflection matrix to set
  55301. */
  55302. setReflectionTextureMatrix(value: Matrix): void;
  55303. /**
  55304. * Parses a JSON representation of an HDR Texture in order to create the texture
  55305. * @param parsedTexture Define the JSON representation
  55306. * @param scene Define the scene the texture should be created in
  55307. * @param rootUrl Define the root url in case we need to load relative dependencies
  55308. * @returns the newly created texture after parsing
  55309. */
  55310. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55311. serialize(): any;
  55312. }
  55313. }
  55314. declare module BABYLON {
  55315. /**
  55316. * Class used to control physics engine
  55317. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55318. */
  55319. export class PhysicsEngine implements IPhysicsEngine {
  55320. private _physicsPlugin;
  55321. /**
  55322. * Global value used to control the smallest number supported by the simulation
  55323. */
  55324. static Epsilon: number;
  55325. private _impostors;
  55326. private _joints;
  55327. private _subTimeStep;
  55328. /**
  55329. * Gets the gravity vector used by the simulation
  55330. */
  55331. gravity: Vector3;
  55332. /**
  55333. * Factory used to create the default physics plugin.
  55334. * @returns The default physics plugin
  55335. */
  55336. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55337. /**
  55338. * Creates a new Physics Engine
  55339. * @param gravity defines the gravity vector used by the simulation
  55340. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55341. */
  55342. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55343. /**
  55344. * Sets the gravity vector used by the simulation
  55345. * @param gravity defines the gravity vector to use
  55346. */
  55347. setGravity(gravity: Vector3): void;
  55348. /**
  55349. * Set the time step of the physics engine.
  55350. * Default is 1/60.
  55351. * To slow it down, enter 1/600 for example.
  55352. * To speed it up, 1/30
  55353. * @param newTimeStep defines the new timestep to apply to this world.
  55354. */
  55355. setTimeStep(newTimeStep?: number): void;
  55356. /**
  55357. * Get the time step of the physics engine.
  55358. * @returns the current time step
  55359. */
  55360. getTimeStep(): number;
  55361. /**
  55362. * Set the sub time step of the physics engine.
  55363. * Default is 0 meaning there is no sub steps
  55364. * To increase physics resolution precision, set a small value (like 1 ms)
  55365. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55366. */
  55367. setSubTimeStep(subTimeStep?: number): void;
  55368. /**
  55369. * Get the sub time step of the physics engine.
  55370. * @returns the current sub time step
  55371. */
  55372. getSubTimeStep(): number;
  55373. /**
  55374. * Release all resources
  55375. */
  55376. dispose(): void;
  55377. /**
  55378. * Gets the name of the current physics plugin
  55379. * @returns the name of the plugin
  55380. */
  55381. getPhysicsPluginName(): string;
  55382. /**
  55383. * Adding a new impostor for the impostor tracking.
  55384. * This will be done by the impostor itself.
  55385. * @param impostor the impostor to add
  55386. */
  55387. addImpostor(impostor: PhysicsImpostor): void;
  55388. /**
  55389. * Remove an impostor from the engine.
  55390. * This impostor and its mesh will not longer be updated by the physics engine.
  55391. * @param impostor the impostor to remove
  55392. */
  55393. removeImpostor(impostor: PhysicsImpostor): void;
  55394. /**
  55395. * Add a joint to the physics engine
  55396. * @param mainImpostor defines the main impostor to which the joint is added.
  55397. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55398. * @param joint defines the joint that will connect both impostors.
  55399. */
  55400. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55401. /**
  55402. * Removes a joint from the simulation
  55403. * @param mainImpostor defines the impostor used with the joint
  55404. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55405. * @param joint defines the joint to remove
  55406. */
  55407. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55408. /**
  55409. * Called by the scene. No need to call it.
  55410. * @param delta defines the timespam between frames
  55411. */
  55412. _step(delta: number): void;
  55413. /**
  55414. * Gets the current plugin used to run the simulation
  55415. * @returns current plugin
  55416. */
  55417. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55418. /**
  55419. * Gets the list of physic impostors
  55420. * @returns an array of PhysicsImpostor
  55421. */
  55422. getImpostors(): Array<PhysicsImpostor>;
  55423. /**
  55424. * Gets the impostor for a physics enabled object
  55425. * @param object defines the object impersonated by the impostor
  55426. * @returns the PhysicsImpostor or null if not found
  55427. */
  55428. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55429. /**
  55430. * Gets the impostor for a physics body object
  55431. * @param body defines physics body used by the impostor
  55432. * @returns the PhysicsImpostor or null if not found
  55433. */
  55434. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55435. /**
  55436. * Does a raycast in the physics world
  55437. * @param from when should the ray start?
  55438. * @param to when should the ray end?
  55439. * @returns PhysicsRaycastResult
  55440. */
  55441. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55442. }
  55443. }
  55444. declare module BABYLON {
  55445. /** @hidden */
  55446. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55447. private _useDeltaForWorldStep;
  55448. world: any;
  55449. name: string;
  55450. private _physicsMaterials;
  55451. private _fixedTimeStep;
  55452. private _cannonRaycastResult;
  55453. private _raycastResult;
  55454. private _physicsBodysToRemoveAfterStep;
  55455. BJSCANNON: any;
  55456. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55457. setGravity(gravity: Vector3): void;
  55458. setTimeStep(timeStep: number): void;
  55459. getTimeStep(): number;
  55460. executeStep(delta: number): void;
  55461. private _removeMarkedPhysicsBodiesFromWorld;
  55462. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55463. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55464. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55465. private _processChildMeshes;
  55466. removePhysicsBody(impostor: PhysicsImpostor): void;
  55467. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55468. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55469. private _addMaterial;
  55470. private _checkWithEpsilon;
  55471. private _createShape;
  55472. private _createHeightmap;
  55473. private _minus90X;
  55474. private _plus90X;
  55475. private _tmpPosition;
  55476. private _tmpDeltaPosition;
  55477. private _tmpUnityRotation;
  55478. private _updatePhysicsBodyTransformation;
  55479. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55480. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55481. isSupported(): boolean;
  55482. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55483. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55484. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55485. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55486. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55487. getBodyMass(impostor: PhysicsImpostor): number;
  55488. getBodyFriction(impostor: PhysicsImpostor): number;
  55489. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55490. getBodyRestitution(impostor: PhysicsImpostor): number;
  55491. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55492. sleepBody(impostor: PhysicsImpostor): void;
  55493. wakeUpBody(impostor: PhysicsImpostor): void;
  55494. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55495. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55496. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55497. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55498. getRadius(impostor: PhysicsImpostor): number;
  55499. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55500. dispose(): void;
  55501. private _extendNamespace;
  55502. /**
  55503. * Does a raycast in the physics world
  55504. * @param from when should the ray start?
  55505. * @param to when should the ray end?
  55506. * @returns PhysicsRaycastResult
  55507. */
  55508. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55509. }
  55510. }
  55511. declare module BABYLON {
  55512. /** @hidden */
  55513. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55514. world: any;
  55515. name: string;
  55516. BJSOIMO: any;
  55517. private _raycastResult;
  55518. constructor(iterations?: number, oimoInjection?: any);
  55519. setGravity(gravity: Vector3): void;
  55520. setTimeStep(timeStep: number): void;
  55521. getTimeStep(): number;
  55522. private _tmpImpostorsArray;
  55523. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55524. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55525. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55526. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55527. private _tmpPositionVector;
  55528. removePhysicsBody(impostor: PhysicsImpostor): void;
  55529. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55530. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55531. isSupported(): boolean;
  55532. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55533. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55534. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55535. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55536. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55537. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55538. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55539. getBodyMass(impostor: PhysicsImpostor): number;
  55540. getBodyFriction(impostor: PhysicsImpostor): number;
  55541. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55542. getBodyRestitution(impostor: PhysicsImpostor): number;
  55543. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55544. sleepBody(impostor: PhysicsImpostor): void;
  55545. wakeUpBody(impostor: PhysicsImpostor): void;
  55546. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55547. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55548. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55549. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55550. getRadius(impostor: PhysicsImpostor): number;
  55551. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55552. dispose(): void;
  55553. /**
  55554. * Does a raycast in the physics world
  55555. * @param from when should the ray start?
  55556. * @param to when should the ray end?
  55557. * @returns PhysicsRaycastResult
  55558. */
  55559. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55560. }
  55561. }
  55562. declare module BABYLON {
  55563. /**
  55564. * Class containing static functions to help procedurally build meshes
  55565. */
  55566. export class RibbonBuilder {
  55567. /**
  55568. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55569. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55570. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55571. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55572. * * 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
  55573. * * 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
  55574. * * 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
  55575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55576. * * 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
  55577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55578. * * 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
  55579. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55580. * * 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
  55581. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55583. * @param name defines the name of the mesh
  55584. * @param options defines the options used to create the mesh
  55585. * @param scene defines the hosting scene
  55586. * @returns the ribbon mesh
  55587. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55589. */
  55590. static CreateRibbon(name: string, options: {
  55591. pathArray: Vector3[][];
  55592. closeArray?: boolean;
  55593. closePath?: boolean;
  55594. offset?: number;
  55595. updatable?: boolean;
  55596. sideOrientation?: number;
  55597. frontUVs?: Vector4;
  55598. backUVs?: Vector4;
  55599. instance?: Mesh;
  55600. invertUV?: boolean;
  55601. uvs?: Vector2[];
  55602. colors?: Color4[];
  55603. }, scene?: Nullable<Scene>): Mesh;
  55604. }
  55605. }
  55606. declare module BABYLON {
  55607. /**
  55608. * Class containing static functions to help procedurally build meshes
  55609. */
  55610. export class ShapeBuilder {
  55611. /**
  55612. * 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.
  55613. * * 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.
  55614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55615. * * 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.
  55616. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55617. * * 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
  55618. * * 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
  55619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55621. * * 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
  55622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55624. * @param name defines the name of the mesh
  55625. * @param options defines the options used to create the mesh
  55626. * @param scene defines the hosting scene
  55627. * @returns the extruded shape mesh
  55628. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55630. */
  55631. static ExtrudeShape(name: string, options: {
  55632. shape: Vector3[];
  55633. path: Vector3[];
  55634. scale?: number;
  55635. rotation?: number;
  55636. cap?: number;
  55637. updatable?: boolean;
  55638. sideOrientation?: number;
  55639. frontUVs?: Vector4;
  55640. backUVs?: Vector4;
  55641. instance?: Mesh;
  55642. invertUV?: boolean;
  55643. }, scene?: Nullable<Scene>): Mesh;
  55644. /**
  55645. * Creates an custom extruded shape mesh.
  55646. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55647. * * 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.
  55648. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55649. * * 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
  55650. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55651. * * 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
  55652. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55653. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55654. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55655. * * 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
  55656. * * 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
  55657. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55659. * * 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
  55660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55662. * @param name defines the name of the mesh
  55663. * @param options defines the options used to create the mesh
  55664. * @param scene defines the hosting scene
  55665. * @returns the custom extruded shape mesh
  55666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55669. */
  55670. static ExtrudeShapeCustom(name: string, options: {
  55671. shape: Vector3[];
  55672. path: Vector3[];
  55673. scaleFunction?: any;
  55674. rotationFunction?: any;
  55675. ribbonCloseArray?: boolean;
  55676. ribbonClosePath?: boolean;
  55677. cap?: number;
  55678. updatable?: boolean;
  55679. sideOrientation?: number;
  55680. frontUVs?: Vector4;
  55681. backUVs?: Vector4;
  55682. instance?: Mesh;
  55683. invertUV?: boolean;
  55684. }, scene?: Nullable<Scene>): Mesh;
  55685. private static _ExtrudeShapeGeneric;
  55686. }
  55687. }
  55688. declare module BABYLON {
  55689. /**
  55690. * AmmoJS Physics plugin
  55691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55692. * @see https://github.com/kripken/ammo.js/
  55693. */
  55694. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55695. private _useDeltaForWorldStep;
  55696. /**
  55697. * Reference to the Ammo library
  55698. */
  55699. bjsAMMO: any;
  55700. /**
  55701. * Created ammoJS world which physics bodies are added to
  55702. */
  55703. world: any;
  55704. /**
  55705. * Name of the plugin
  55706. */
  55707. name: string;
  55708. private _timeStep;
  55709. private _fixedTimeStep;
  55710. private _maxSteps;
  55711. private _tmpQuaternion;
  55712. private _tmpAmmoTransform;
  55713. private _tmpAmmoQuaternion;
  55714. private _tmpAmmoConcreteContactResultCallback;
  55715. private _collisionConfiguration;
  55716. private _dispatcher;
  55717. private _overlappingPairCache;
  55718. private _solver;
  55719. private _softBodySolver;
  55720. private _tmpAmmoVectorA;
  55721. private _tmpAmmoVectorB;
  55722. private _tmpAmmoVectorC;
  55723. private _tmpAmmoVectorD;
  55724. private _tmpContactCallbackResult;
  55725. private _tmpAmmoVectorRCA;
  55726. private _tmpAmmoVectorRCB;
  55727. private _raycastResult;
  55728. private static readonly DISABLE_COLLISION_FLAG;
  55729. private static readonly KINEMATIC_FLAG;
  55730. private static readonly DISABLE_DEACTIVATION_FLAG;
  55731. /**
  55732. * Initializes the ammoJS plugin
  55733. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55734. * @param ammoInjection can be used to inject your own ammo reference
  55735. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55736. */
  55737. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55738. /**
  55739. * Sets the gravity of the physics world (m/(s^2))
  55740. * @param gravity Gravity to set
  55741. */
  55742. setGravity(gravity: Vector3): void;
  55743. /**
  55744. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55745. * @param timeStep timestep to use in seconds
  55746. */
  55747. setTimeStep(timeStep: number): void;
  55748. /**
  55749. * 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)
  55750. * @param fixedTimeStep fixedTimeStep to use in seconds
  55751. */
  55752. setFixedTimeStep(fixedTimeStep: number): void;
  55753. /**
  55754. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55755. * @param maxSteps the maximum number of steps by the physics engine per frame
  55756. */
  55757. setMaxSteps(maxSteps: number): void;
  55758. /**
  55759. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55760. * @returns the current timestep in seconds
  55761. */
  55762. getTimeStep(): number;
  55763. /**
  55764. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55765. */
  55766. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55767. private _isImpostorInContact;
  55768. private _isImpostorPairInContact;
  55769. private _stepSimulation;
  55770. /**
  55771. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55772. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55773. * After the step the babylon meshes are set to the position of the physics imposters
  55774. * @param delta amount of time to step forward
  55775. * @param impostors array of imposters to update before/after the step
  55776. */
  55777. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55778. /**
  55779. * Update babylon mesh to match physics world object
  55780. * @param impostor imposter to match
  55781. */
  55782. private _afterSoftStep;
  55783. /**
  55784. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55785. * @param impostor imposter to match
  55786. */
  55787. private _ropeStep;
  55788. /**
  55789. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55790. * @param impostor imposter to match
  55791. */
  55792. private _softbodyOrClothStep;
  55793. private _tmpMatrix;
  55794. /**
  55795. * Applies an impulse on the imposter
  55796. * @param impostor imposter to apply impulse to
  55797. * @param force amount of force to be applied to the imposter
  55798. * @param contactPoint the location to apply the impulse on the imposter
  55799. */
  55800. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55801. /**
  55802. * Applies a force on the imposter
  55803. * @param impostor imposter to apply force
  55804. * @param force amount of force to be applied to the imposter
  55805. * @param contactPoint the location to apply the force on the imposter
  55806. */
  55807. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55808. /**
  55809. * Creates a physics body using the plugin
  55810. * @param impostor the imposter to create the physics body on
  55811. */
  55812. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55813. /**
  55814. * Removes the physics body from the imposter and disposes of the body's memory
  55815. * @param impostor imposter to remove the physics body from
  55816. */
  55817. removePhysicsBody(impostor: PhysicsImpostor): void;
  55818. /**
  55819. * Generates a joint
  55820. * @param impostorJoint the imposter joint to create the joint with
  55821. */
  55822. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55823. /**
  55824. * Removes a joint
  55825. * @param impostorJoint the imposter joint to remove the joint from
  55826. */
  55827. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55828. private _addMeshVerts;
  55829. /**
  55830. * Initialise the soft body vertices to match its object's (mesh) vertices
  55831. * Softbody vertices (nodes) are in world space and to match this
  55832. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55833. * @param impostor to create the softbody for
  55834. */
  55835. private _softVertexData;
  55836. /**
  55837. * Create an impostor's soft body
  55838. * @param impostor to create the softbody for
  55839. */
  55840. private _createSoftbody;
  55841. /**
  55842. * Create cloth for an impostor
  55843. * @param impostor to create the softbody for
  55844. */
  55845. private _createCloth;
  55846. /**
  55847. * Create rope for an impostor
  55848. * @param impostor to create the softbody for
  55849. */
  55850. private _createRope;
  55851. /**
  55852. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55853. * @param impostor to create the custom physics shape for
  55854. */
  55855. private _createCustom;
  55856. private _addHullVerts;
  55857. private _createShape;
  55858. /**
  55859. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55860. * @param impostor imposter containing the physics body and babylon object
  55861. */
  55862. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55863. /**
  55864. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55865. * @param impostor imposter containing the physics body and babylon object
  55866. * @param newPosition new position
  55867. * @param newRotation new rotation
  55868. */
  55869. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55870. /**
  55871. * If this plugin is supported
  55872. * @returns true if its supported
  55873. */
  55874. isSupported(): boolean;
  55875. /**
  55876. * Sets the linear velocity of the physics body
  55877. * @param impostor imposter to set the velocity on
  55878. * @param velocity velocity to set
  55879. */
  55880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55881. /**
  55882. * Sets the angular velocity of the physics body
  55883. * @param impostor imposter to set the velocity on
  55884. * @param velocity velocity to set
  55885. */
  55886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55887. /**
  55888. * gets the linear velocity
  55889. * @param impostor imposter to get linear velocity from
  55890. * @returns linear velocity
  55891. */
  55892. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55893. /**
  55894. * gets the angular velocity
  55895. * @param impostor imposter to get angular velocity from
  55896. * @returns angular velocity
  55897. */
  55898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55899. /**
  55900. * Sets the mass of physics body
  55901. * @param impostor imposter to set the mass on
  55902. * @param mass mass to set
  55903. */
  55904. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55905. /**
  55906. * Gets the mass of the physics body
  55907. * @param impostor imposter to get the mass from
  55908. * @returns mass
  55909. */
  55910. getBodyMass(impostor: PhysicsImpostor): number;
  55911. /**
  55912. * Gets friction of the impostor
  55913. * @param impostor impostor to get friction from
  55914. * @returns friction value
  55915. */
  55916. getBodyFriction(impostor: PhysicsImpostor): number;
  55917. /**
  55918. * Sets friction of the impostor
  55919. * @param impostor impostor to set friction on
  55920. * @param friction friction value
  55921. */
  55922. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55923. /**
  55924. * Gets restitution of the impostor
  55925. * @param impostor impostor to get restitution from
  55926. * @returns restitution value
  55927. */
  55928. getBodyRestitution(impostor: PhysicsImpostor): number;
  55929. /**
  55930. * Sets resitution of the impostor
  55931. * @param impostor impostor to set resitution on
  55932. * @param restitution resitution value
  55933. */
  55934. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55935. /**
  55936. * Gets pressure inside the impostor
  55937. * @param impostor impostor to get pressure from
  55938. * @returns pressure value
  55939. */
  55940. getBodyPressure(impostor: PhysicsImpostor): number;
  55941. /**
  55942. * Sets pressure inside a soft body impostor
  55943. * Cloth and rope must remain 0 pressure
  55944. * @param impostor impostor to set pressure on
  55945. * @param pressure pressure value
  55946. */
  55947. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55948. /**
  55949. * Gets stiffness of the impostor
  55950. * @param impostor impostor to get stiffness from
  55951. * @returns pressure value
  55952. */
  55953. getBodyStiffness(impostor: PhysicsImpostor): number;
  55954. /**
  55955. * Sets stiffness of the impostor
  55956. * @param impostor impostor to set stiffness on
  55957. * @param stiffness stiffness value from 0 to 1
  55958. */
  55959. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55960. /**
  55961. * Gets velocityIterations of the impostor
  55962. * @param impostor impostor to get velocity iterations from
  55963. * @returns velocityIterations value
  55964. */
  55965. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55966. /**
  55967. * Sets velocityIterations of the impostor
  55968. * @param impostor impostor to set velocity iterations on
  55969. * @param velocityIterations velocityIterations value
  55970. */
  55971. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55972. /**
  55973. * Gets positionIterations of the impostor
  55974. * @param impostor impostor to get position iterations from
  55975. * @returns positionIterations value
  55976. */
  55977. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55978. /**
  55979. * Sets positionIterations of the impostor
  55980. * @param impostor impostor to set position on
  55981. * @param positionIterations positionIterations value
  55982. */
  55983. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55984. /**
  55985. * Append an anchor to a cloth object
  55986. * @param impostor is the cloth impostor to add anchor to
  55987. * @param otherImpostor is the rigid impostor to anchor to
  55988. * @param width ratio across width from 0 to 1
  55989. * @param height ratio up height from 0 to 1
  55990. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55991. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55992. */
  55993. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55994. /**
  55995. * Append an hook to a rope object
  55996. * @param impostor is the rope impostor to add hook to
  55997. * @param otherImpostor is the rigid impostor to hook to
  55998. * @param length ratio along the rope from 0 to 1
  55999. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56000. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56001. */
  56002. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56003. /**
  56004. * Sleeps the physics body and stops it from being active
  56005. * @param impostor impostor to sleep
  56006. */
  56007. sleepBody(impostor: PhysicsImpostor): void;
  56008. /**
  56009. * Activates the physics body
  56010. * @param impostor impostor to activate
  56011. */
  56012. wakeUpBody(impostor: PhysicsImpostor): void;
  56013. /**
  56014. * Updates the distance parameters of the joint
  56015. * @param joint joint to update
  56016. * @param maxDistance maximum distance of the joint
  56017. * @param minDistance minimum distance of the joint
  56018. */
  56019. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56020. /**
  56021. * Sets a motor on the joint
  56022. * @param joint joint to set motor on
  56023. * @param speed speed of the motor
  56024. * @param maxForce maximum force of the motor
  56025. * @param motorIndex index of the motor
  56026. */
  56027. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56028. /**
  56029. * Sets the motors limit
  56030. * @param joint joint to set limit on
  56031. * @param upperLimit upper limit
  56032. * @param lowerLimit lower limit
  56033. */
  56034. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56035. /**
  56036. * Syncs the position and rotation of a mesh with the impostor
  56037. * @param mesh mesh to sync
  56038. * @param impostor impostor to update the mesh with
  56039. */
  56040. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56041. /**
  56042. * Gets the radius of the impostor
  56043. * @param impostor impostor to get radius from
  56044. * @returns the radius
  56045. */
  56046. getRadius(impostor: PhysicsImpostor): number;
  56047. /**
  56048. * Gets the box size of the impostor
  56049. * @param impostor impostor to get box size from
  56050. * @param result the resulting box size
  56051. */
  56052. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56053. /**
  56054. * Disposes of the impostor
  56055. */
  56056. dispose(): void;
  56057. /**
  56058. * Does a raycast in the physics world
  56059. * @param from when should the ray start?
  56060. * @param to when should the ray end?
  56061. * @returns PhysicsRaycastResult
  56062. */
  56063. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56064. }
  56065. }
  56066. declare module BABYLON {
  56067. interface AbstractScene {
  56068. /**
  56069. * The list of reflection probes added to the scene
  56070. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56071. */
  56072. reflectionProbes: Array<ReflectionProbe>;
  56073. /**
  56074. * Removes the given reflection probe from this scene.
  56075. * @param toRemove The reflection probe to remove
  56076. * @returns The index of the removed reflection probe
  56077. */
  56078. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56079. /**
  56080. * Adds the given reflection probe to this scene.
  56081. * @param newReflectionProbe The reflection probe to add
  56082. */
  56083. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56084. }
  56085. /**
  56086. * Class used to generate realtime reflection / refraction cube textures
  56087. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56088. */
  56089. export class ReflectionProbe {
  56090. /** defines the name of the probe */
  56091. name: string;
  56092. private _scene;
  56093. private _renderTargetTexture;
  56094. private _projectionMatrix;
  56095. private _viewMatrix;
  56096. private _target;
  56097. private _add;
  56098. private _attachedMesh;
  56099. private _invertYAxis;
  56100. /** Gets or sets probe position (center of the cube map) */
  56101. position: Vector3;
  56102. /**
  56103. * Creates a new reflection probe
  56104. * @param name defines the name of the probe
  56105. * @param size defines the texture resolution (for each face)
  56106. * @param scene defines the hosting scene
  56107. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56108. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56109. */
  56110. constructor(
  56111. /** defines the name of the probe */
  56112. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56113. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56114. get samples(): number;
  56115. set samples(value: number);
  56116. /** Gets or sets the refresh rate to use (on every frame by default) */
  56117. get refreshRate(): number;
  56118. set refreshRate(value: number);
  56119. /**
  56120. * Gets the hosting scene
  56121. * @returns a Scene
  56122. */
  56123. getScene(): Scene;
  56124. /** Gets the internal CubeTexture used to render to */
  56125. get cubeTexture(): RenderTargetTexture;
  56126. /** Gets the list of meshes to render */
  56127. get renderList(): Nullable<AbstractMesh[]>;
  56128. /**
  56129. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56130. * @param mesh defines the mesh to attach to
  56131. */
  56132. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56133. /**
  56134. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56135. * @param renderingGroupId The rendering group id corresponding to its index
  56136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56137. */
  56138. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56139. /**
  56140. * Clean all associated resources
  56141. */
  56142. dispose(): void;
  56143. /**
  56144. * Converts the reflection probe information to a readable string for debug purpose.
  56145. * @param fullDetails Supports for multiple levels of logging within scene loading
  56146. * @returns the human readable reflection probe info
  56147. */
  56148. toString(fullDetails?: boolean): string;
  56149. /**
  56150. * Get the class name of the relfection probe.
  56151. * @returns "ReflectionProbe"
  56152. */
  56153. getClassName(): string;
  56154. /**
  56155. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56156. * @returns The JSON representation of the texture
  56157. */
  56158. serialize(): any;
  56159. /**
  56160. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56161. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56162. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56163. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56164. * @returns The parsed reflection probe if successful
  56165. */
  56166. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56167. }
  56168. }
  56169. declare module BABYLON {
  56170. /** @hidden */
  56171. export var _BabylonLoaderRegistered: boolean;
  56172. /**
  56173. * Helps setting up some configuration for the babylon file loader.
  56174. */
  56175. export class BabylonFileLoaderConfiguration {
  56176. /**
  56177. * The loader does not allow injecting custom physix engine into the plugins.
  56178. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56179. * So you could set this variable to your engine import to make it work.
  56180. */
  56181. static LoaderInjectedPhysicsEngine: any;
  56182. }
  56183. }
  56184. declare module BABYLON {
  56185. /**
  56186. * The Physically based simple base material of BJS.
  56187. *
  56188. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56189. * It is used as the base class for both the specGloss and metalRough conventions.
  56190. */
  56191. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56192. /**
  56193. * Number of Simultaneous lights allowed on the material.
  56194. */
  56195. maxSimultaneousLights: number;
  56196. /**
  56197. * If sets to true, disables all the lights affecting the material.
  56198. */
  56199. disableLighting: boolean;
  56200. /**
  56201. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56202. */
  56203. environmentTexture: BaseTexture;
  56204. /**
  56205. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56206. */
  56207. invertNormalMapX: boolean;
  56208. /**
  56209. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56210. */
  56211. invertNormalMapY: boolean;
  56212. /**
  56213. * Normal map used in the model.
  56214. */
  56215. normalTexture: BaseTexture;
  56216. /**
  56217. * Emissivie color used to self-illuminate the model.
  56218. */
  56219. emissiveColor: Color3;
  56220. /**
  56221. * Emissivie texture used to self-illuminate the model.
  56222. */
  56223. emissiveTexture: BaseTexture;
  56224. /**
  56225. * Occlusion Channel Strenght.
  56226. */
  56227. occlusionStrength: number;
  56228. /**
  56229. * Occlusion Texture of the material (adding extra occlusion effects).
  56230. */
  56231. occlusionTexture: BaseTexture;
  56232. /**
  56233. * Defines the alpha limits in alpha test mode.
  56234. */
  56235. alphaCutOff: number;
  56236. /**
  56237. * Gets the current double sided mode.
  56238. */
  56239. get doubleSided(): boolean;
  56240. /**
  56241. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56242. */
  56243. set doubleSided(value: boolean);
  56244. /**
  56245. * Stores the pre-calculated light information of a mesh in a texture.
  56246. */
  56247. lightmapTexture: BaseTexture;
  56248. /**
  56249. * If true, the light map contains occlusion information instead of lighting info.
  56250. */
  56251. useLightmapAsShadowmap: boolean;
  56252. /**
  56253. * Instantiates a new PBRMaterial instance.
  56254. *
  56255. * @param name The material name
  56256. * @param scene The scene the material will be use in.
  56257. */
  56258. constructor(name: string, scene: Scene);
  56259. getClassName(): string;
  56260. }
  56261. }
  56262. declare module BABYLON {
  56263. /**
  56264. * The PBR material of BJS following the metal roughness convention.
  56265. *
  56266. * This fits to the PBR convention in the GLTF definition:
  56267. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56268. */
  56269. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56270. /**
  56271. * The base color has two different interpretations depending on the value of metalness.
  56272. * When the material is a metal, the base color is the specific measured reflectance value
  56273. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56274. * of the material.
  56275. */
  56276. baseColor: Color3;
  56277. /**
  56278. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56279. * well as opacity information in the alpha channel.
  56280. */
  56281. baseTexture: BaseTexture;
  56282. /**
  56283. * Specifies the metallic scalar value of the material.
  56284. * Can also be used to scale the metalness values of the metallic texture.
  56285. */
  56286. metallic: number;
  56287. /**
  56288. * Specifies the roughness scalar value of the material.
  56289. * Can also be used to scale the roughness values of the metallic texture.
  56290. */
  56291. roughness: number;
  56292. /**
  56293. * Texture containing both the metallic value in the B channel and the
  56294. * roughness value in the G channel to keep better precision.
  56295. */
  56296. metallicRoughnessTexture: BaseTexture;
  56297. /**
  56298. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56299. *
  56300. * @param name The material name
  56301. * @param scene The scene the material will be use in.
  56302. */
  56303. constructor(name: string, scene: Scene);
  56304. /**
  56305. * Return the currrent class name of the material.
  56306. */
  56307. getClassName(): string;
  56308. /**
  56309. * Makes a duplicate of the current material.
  56310. * @param name - name to use for the new material.
  56311. */
  56312. clone(name: string): PBRMetallicRoughnessMaterial;
  56313. /**
  56314. * Serialize the material to a parsable JSON object.
  56315. */
  56316. serialize(): any;
  56317. /**
  56318. * Parses a JSON object correponding to the serialize function.
  56319. */
  56320. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56321. }
  56322. }
  56323. declare module BABYLON {
  56324. /**
  56325. * The PBR material of BJS following the specular glossiness convention.
  56326. *
  56327. * This fits to the PBR convention in the GLTF definition:
  56328. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56329. */
  56330. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56331. /**
  56332. * Specifies the diffuse color of the material.
  56333. */
  56334. diffuseColor: Color3;
  56335. /**
  56336. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56337. * channel.
  56338. */
  56339. diffuseTexture: BaseTexture;
  56340. /**
  56341. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56342. */
  56343. specularColor: Color3;
  56344. /**
  56345. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56346. */
  56347. glossiness: number;
  56348. /**
  56349. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56350. */
  56351. specularGlossinessTexture: BaseTexture;
  56352. /**
  56353. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56354. *
  56355. * @param name The material name
  56356. * @param scene The scene the material will be use in.
  56357. */
  56358. constructor(name: string, scene: Scene);
  56359. /**
  56360. * Return the currrent class name of the material.
  56361. */
  56362. getClassName(): string;
  56363. /**
  56364. * Makes a duplicate of the current material.
  56365. * @param name - name to use for the new material.
  56366. */
  56367. clone(name: string): PBRSpecularGlossinessMaterial;
  56368. /**
  56369. * Serialize the material to a parsable JSON object.
  56370. */
  56371. serialize(): any;
  56372. /**
  56373. * Parses a JSON object correponding to the serialize function.
  56374. */
  56375. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56376. }
  56377. }
  56378. declare module BABYLON {
  56379. /**
  56380. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56381. * It can help converting any input color in a desired output one. This can then be used to create effects
  56382. * from sepia, black and white to sixties or futuristic rendering...
  56383. *
  56384. * The only supported format is currently 3dl.
  56385. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56386. */
  56387. export class ColorGradingTexture extends BaseTexture {
  56388. /**
  56389. * The current texture matrix. (will always be identity in color grading texture)
  56390. */
  56391. private _textureMatrix;
  56392. /**
  56393. * The texture URL.
  56394. */
  56395. url: string;
  56396. /**
  56397. * Empty line regex stored for GC.
  56398. */
  56399. private static _noneEmptyLineRegex;
  56400. private _engine;
  56401. /**
  56402. * Instantiates a ColorGradingTexture from the following parameters.
  56403. *
  56404. * @param url The location of the color gradind data (currently only supporting 3dl)
  56405. * @param scene The scene the texture will be used in
  56406. */
  56407. constructor(url: string, scene: Scene);
  56408. /**
  56409. * Returns the texture matrix used in most of the material.
  56410. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56411. */
  56412. getTextureMatrix(): Matrix;
  56413. /**
  56414. * Occurs when the file being loaded is a .3dl LUT file.
  56415. */
  56416. private load3dlTexture;
  56417. /**
  56418. * Starts the loading process of the texture.
  56419. */
  56420. private loadTexture;
  56421. /**
  56422. * Clones the color gradind texture.
  56423. */
  56424. clone(): ColorGradingTexture;
  56425. /**
  56426. * Called during delayed load for textures.
  56427. */
  56428. delayLoad(): void;
  56429. /**
  56430. * Parses a color grading texture serialized by Babylon.
  56431. * @param parsedTexture The texture information being parsedTexture
  56432. * @param scene The scene to load the texture in
  56433. * @param rootUrl The root url of the data assets to load
  56434. * @return A color gradind texture
  56435. */
  56436. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56437. /**
  56438. * Serializes the LUT texture to json format.
  56439. */
  56440. serialize(): any;
  56441. }
  56442. }
  56443. declare module BABYLON {
  56444. /**
  56445. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56446. */
  56447. export class EquiRectangularCubeTexture extends BaseTexture {
  56448. /** The six faces of the cube. */
  56449. private static _FacesMapping;
  56450. private _noMipmap;
  56451. private _onLoad;
  56452. private _onError;
  56453. /** The size of the cubemap. */
  56454. private _size;
  56455. /** The buffer of the image. */
  56456. private _buffer;
  56457. /** The width of the input image. */
  56458. private _width;
  56459. /** The height of the input image. */
  56460. private _height;
  56461. /** The URL to the image. */
  56462. url: string;
  56463. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56464. coordinatesMode: number;
  56465. /**
  56466. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56467. * @param url The location of the image
  56468. * @param scene The scene the texture will be used in
  56469. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56470. * @param noMipmap Forces to not generate the mipmap if true
  56471. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56472. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56473. * @param onLoad — defines a callback called when texture is loaded
  56474. * @param onError — defines a callback called if there is an error
  56475. */
  56476. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56477. /**
  56478. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56479. */
  56480. private loadImage;
  56481. /**
  56482. * Convert the image buffer into a cubemap and create a CubeTexture.
  56483. */
  56484. private loadTexture;
  56485. /**
  56486. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56487. * @param buffer The ArrayBuffer that should be converted.
  56488. * @returns The buffer as Float32Array.
  56489. */
  56490. private getFloat32ArrayFromArrayBuffer;
  56491. /**
  56492. * Get the current class name of the texture useful for serialization or dynamic coding.
  56493. * @returns "EquiRectangularCubeTexture"
  56494. */
  56495. getClassName(): string;
  56496. /**
  56497. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56498. * @returns A clone of the current EquiRectangularCubeTexture.
  56499. */
  56500. clone(): EquiRectangularCubeTexture;
  56501. }
  56502. }
  56503. declare module BABYLON {
  56504. /**
  56505. * Based on jsTGALoader - Javascript loader for TGA file
  56506. * By Vincent Thibault
  56507. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56508. */
  56509. export class TGATools {
  56510. private static _TYPE_INDEXED;
  56511. private static _TYPE_RGB;
  56512. private static _TYPE_GREY;
  56513. private static _TYPE_RLE_INDEXED;
  56514. private static _TYPE_RLE_RGB;
  56515. private static _TYPE_RLE_GREY;
  56516. private static _ORIGIN_MASK;
  56517. private static _ORIGIN_SHIFT;
  56518. private static _ORIGIN_BL;
  56519. private static _ORIGIN_BR;
  56520. private static _ORIGIN_UL;
  56521. private static _ORIGIN_UR;
  56522. /**
  56523. * Gets the header of a TGA file
  56524. * @param data defines the TGA data
  56525. * @returns the header
  56526. */
  56527. static GetTGAHeader(data: Uint8Array): any;
  56528. /**
  56529. * Uploads TGA content to a Babylon Texture
  56530. * @hidden
  56531. */
  56532. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56533. /** @hidden */
  56534. 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;
  56535. /** @hidden */
  56536. 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;
  56537. /** @hidden */
  56538. 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;
  56539. /** @hidden */
  56540. 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;
  56541. /** @hidden */
  56542. 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;
  56543. /** @hidden */
  56544. 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;
  56545. }
  56546. }
  56547. declare module BABYLON {
  56548. /**
  56549. * Implementation of the TGA Texture Loader.
  56550. * @hidden
  56551. */
  56552. export class _TGATextureLoader implements IInternalTextureLoader {
  56553. /**
  56554. * Defines wether the loader supports cascade loading the different faces.
  56555. */
  56556. readonly supportCascades: boolean;
  56557. /**
  56558. * This returns if the loader support the current file information.
  56559. * @param extension defines the file extension of the file being loaded
  56560. * @returns true if the loader can load the specified file
  56561. */
  56562. canLoad(extension: string): boolean;
  56563. /**
  56564. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56565. * @param data contains the texture data
  56566. * @param texture defines the BabylonJS internal texture
  56567. * @param createPolynomials will be true if polynomials have been requested
  56568. * @param onLoad defines the callback to trigger once the texture is ready
  56569. * @param onError defines the callback to trigger in case of error
  56570. */
  56571. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56572. /**
  56573. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56574. * @param data contains the texture data
  56575. * @param texture defines the BabylonJS internal texture
  56576. * @param callback defines the method to call once ready to upload
  56577. */
  56578. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56579. }
  56580. }
  56581. declare module BABYLON {
  56582. /**
  56583. * Info about the .basis files
  56584. */
  56585. class BasisFileInfo {
  56586. /**
  56587. * If the file has alpha
  56588. */
  56589. hasAlpha: boolean;
  56590. /**
  56591. * Info about each image of the basis file
  56592. */
  56593. images: Array<{
  56594. levels: Array<{
  56595. width: number;
  56596. height: number;
  56597. transcodedPixels: ArrayBufferView;
  56598. }>;
  56599. }>;
  56600. }
  56601. /**
  56602. * Result of transcoding a basis file
  56603. */
  56604. class TranscodeResult {
  56605. /**
  56606. * Info about the .basis file
  56607. */
  56608. fileInfo: BasisFileInfo;
  56609. /**
  56610. * Format to use when loading the file
  56611. */
  56612. format: number;
  56613. }
  56614. /**
  56615. * Configuration options for the Basis transcoder
  56616. */
  56617. export class BasisTranscodeConfiguration {
  56618. /**
  56619. * Supported compression formats used to determine the supported output format of the transcoder
  56620. */
  56621. supportedCompressionFormats?: {
  56622. /**
  56623. * etc1 compression format
  56624. */
  56625. etc1?: boolean;
  56626. /**
  56627. * s3tc compression format
  56628. */
  56629. s3tc?: boolean;
  56630. /**
  56631. * pvrtc compression format
  56632. */
  56633. pvrtc?: boolean;
  56634. /**
  56635. * etc2 compression format
  56636. */
  56637. etc2?: boolean;
  56638. };
  56639. /**
  56640. * If mipmap levels should be loaded for transcoded images (Default: true)
  56641. */
  56642. loadMipmapLevels?: boolean;
  56643. /**
  56644. * Index of a single image to load (Default: all images)
  56645. */
  56646. loadSingleImage?: number;
  56647. }
  56648. /**
  56649. * Used to load .Basis files
  56650. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56651. */
  56652. export class BasisTools {
  56653. private static _IgnoreSupportedFormats;
  56654. /**
  56655. * URL to use when loading the basis transcoder
  56656. */
  56657. static JSModuleURL: string;
  56658. /**
  56659. * URL to use when loading the wasm module for the transcoder
  56660. */
  56661. static WasmModuleURL: string;
  56662. /**
  56663. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56664. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56665. * @returns internal format corresponding to the Basis format
  56666. */
  56667. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56668. private static _WorkerPromise;
  56669. private static _Worker;
  56670. private static _actionId;
  56671. private static _CreateWorkerAsync;
  56672. /**
  56673. * Transcodes a loaded image file to compressed pixel data
  56674. * @param data image data to transcode
  56675. * @param config configuration options for the transcoding
  56676. * @returns a promise resulting in the transcoded image
  56677. */
  56678. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56679. /**
  56680. * Loads a texture from the transcode result
  56681. * @param texture texture load to
  56682. * @param transcodeResult the result of transcoding the basis file to load from
  56683. */
  56684. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56685. }
  56686. }
  56687. declare module BABYLON {
  56688. /**
  56689. * Loader for .basis file format
  56690. */
  56691. export class _BasisTextureLoader implements IInternalTextureLoader {
  56692. /**
  56693. * Defines whether the loader supports cascade loading the different faces.
  56694. */
  56695. readonly supportCascades: boolean;
  56696. /**
  56697. * This returns if the loader support the current file information.
  56698. * @param extension defines the file extension of the file being loaded
  56699. * @returns true if the loader can load the specified file
  56700. */
  56701. canLoad(extension: string): boolean;
  56702. /**
  56703. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56704. * @param data contains the texture data
  56705. * @param texture defines the BabylonJS internal texture
  56706. * @param createPolynomials will be true if polynomials have been requested
  56707. * @param onLoad defines the callback to trigger once the texture is ready
  56708. * @param onError defines the callback to trigger in case of error
  56709. */
  56710. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56711. /**
  56712. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56713. * @param data contains the texture data
  56714. * @param texture defines the BabylonJS internal texture
  56715. * @param callback defines the method to call once ready to upload
  56716. */
  56717. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56718. }
  56719. }
  56720. declare module BABYLON {
  56721. /**
  56722. * 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.
  56723. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56724. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56725. */
  56726. export class CustomProceduralTexture extends ProceduralTexture {
  56727. private _animate;
  56728. private _time;
  56729. private _config;
  56730. private _texturePath;
  56731. /**
  56732. * Instantiates a new Custom Procedural Texture.
  56733. * 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.
  56734. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56735. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56736. * @param name Define the name of the texture
  56737. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56738. * @param size Define the size of the texture to create
  56739. * @param scene Define the scene the texture belongs to
  56740. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56741. * @param generateMipMaps Define if the texture should creates mip maps or not
  56742. */
  56743. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56744. private _loadJson;
  56745. /**
  56746. * Is the texture ready to be used ? (rendered at least once)
  56747. * @returns true if ready, otherwise, false.
  56748. */
  56749. isReady(): boolean;
  56750. /**
  56751. * Render the texture to its associated render target.
  56752. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56753. */
  56754. render(useCameraPostProcess?: boolean): void;
  56755. /**
  56756. * Update the list of dependant textures samplers in the shader.
  56757. */
  56758. updateTextures(): void;
  56759. /**
  56760. * Update the uniform values of the procedural texture in the shader.
  56761. */
  56762. updateShaderUniforms(): void;
  56763. /**
  56764. * Define if the texture animates or not.
  56765. */
  56766. get animate(): boolean;
  56767. set animate(value: boolean);
  56768. }
  56769. }
  56770. declare module BABYLON {
  56771. /** @hidden */
  56772. export var noisePixelShader: {
  56773. name: string;
  56774. shader: string;
  56775. };
  56776. }
  56777. declare module BABYLON {
  56778. /**
  56779. * Class used to generate noise procedural textures
  56780. */
  56781. export class NoiseProceduralTexture extends ProceduralTexture {
  56782. private _time;
  56783. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56784. brightness: number;
  56785. /** Defines the number of octaves to process */
  56786. octaves: number;
  56787. /** Defines the level of persistence (0.8 by default) */
  56788. persistence: number;
  56789. /** Gets or sets animation speed factor (default is 1) */
  56790. animationSpeedFactor: number;
  56791. /**
  56792. * Creates a new NoiseProceduralTexture
  56793. * @param name defines the name fo the texture
  56794. * @param size defines the size of the texture (default is 256)
  56795. * @param scene defines the hosting scene
  56796. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56797. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56798. */
  56799. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56800. private _updateShaderUniforms;
  56801. protected _getDefines(): string;
  56802. /** Generate the current state of the procedural texture */
  56803. render(useCameraPostProcess?: boolean): void;
  56804. /**
  56805. * Serializes this noise procedural texture
  56806. * @returns a serialized noise procedural texture object
  56807. */
  56808. serialize(): any;
  56809. /**
  56810. * Clone the texture.
  56811. * @returns the cloned texture
  56812. */
  56813. clone(): NoiseProceduralTexture;
  56814. /**
  56815. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56816. * @param parsedTexture defines parsed texture data
  56817. * @param scene defines the current scene
  56818. * @param rootUrl defines the root URL containing noise procedural texture information
  56819. * @returns a parsed NoiseProceduralTexture
  56820. */
  56821. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56822. }
  56823. }
  56824. declare module BABYLON {
  56825. /**
  56826. * Raw cube texture where the raw buffers are passed in
  56827. */
  56828. export class RawCubeTexture extends CubeTexture {
  56829. /**
  56830. * Creates a cube texture where the raw buffers are passed in.
  56831. * @param scene defines the scene the texture is attached to
  56832. * @param data defines the array of data to use to create each face
  56833. * @param size defines the size of the textures
  56834. * @param format defines the format of the data
  56835. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56836. * @param generateMipMaps defines if the engine should generate the mip levels
  56837. * @param invertY defines if data must be stored with Y axis inverted
  56838. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56839. * @param compression defines the compression used (null by default)
  56840. */
  56841. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56842. /**
  56843. * Updates the raw cube texture.
  56844. * @param data defines the data to store
  56845. * @param format defines the data format
  56846. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56847. * @param invertY defines if data must be stored with Y axis inverted
  56848. * @param compression defines the compression used (null by default)
  56849. * @param level defines which level of the texture to update
  56850. */
  56851. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56852. /**
  56853. * Updates a raw cube texture with RGBD encoded data.
  56854. * @param data defines the array of data [mipmap][face] to use to create each face
  56855. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56856. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56857. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56858. * @returns a promsie that resolves when the operation is complete
  56859. */
  56860. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56861. /**
  56862. * Clones the raw cube texture.
  56863. * @return a new cube texture
  56864. */
  56865. clone(): CubeTexture;
  56866. /** @hidden */
  56867. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56868. }
  56869. }
  56870. declare module BABYLON {
  56871. /**
  56872. * Class used to store 3D textures containing user data
  56873. */
  56874. export class RawTexture3D extends Texture {
  56875. /** Gets or sets the texture format to use */
  56876. format: number;
  56877. private _engine;
  56878. /**
  56879. * Create a new RawTexture3D
  56880. * @param data defines the data of the texture
  56881. * @param width defines the width of the texture
  56882. * @param height defines the height of the texture
  56883. * @param depth defines the depth of the texture
  56884. * @param format defines the texture format to use
  56885. * @param scene defines the hosting scene
  56886. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56887. * @param invertY defines if texture must be stored with Y axis inverted
  56888. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56889. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56890. */
  56891. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56892. /** Gets or sets the texture format to use */
  56893. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56894. /**
  56895. * Update the texture with new data
  56896. * @param data defines the data to store in the texture
  56897. */
  56898. update(data: ArrayBufferView): void;
  56899. }
  56900. }
  56901. declare module BABYLON {
  56902. /**
  56903. * Class used to store 2D array textures containing user data
  56904. */
  56905. export class RawTexture2DArray extends Texture {
  56906. /** Gets or sets the texture format to use */
  56907. format: number;
  56908. private _engine;
  56909. /**
  56910. * Create a new RawTexture2DArray
  56911. * @param data defines the data of the texture
  56912. * @param width defines the width of the texture
  56913. * @param height defines the height of the texture
  56914. * @param depth defines the number of layers of the texture
  56915. * @param format defines the texture format to use
  56916. * @param scene defines the hosting scene
  56917. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56918. * @param invertY defines if texture must be stored with Y axis inverted
  56919. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56920. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56921. */
  56922. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56923. /** Gets or sets the texture format to use */
  56924. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56925. /**
  56926. * Update the texture with new data
  56927. * @param data defines the data to store in the texture
  56928. */
  56929. update(data: ArrayBufferView): void;
  56930. }
  56931. }
  56932. declare module BABYLON {
  56933. /**
  56934. * Creates a refraction texture used by refraction channel of the standard material.
  56935. * It is like a mirror but to see through a material.
  56936. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56937. */
  56938. export class RefractionTexture extends RenderTargetTexture {
  56939. /**
  56940. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56941. * 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.
  56942. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56943. */
  56944. refractionPlane: Plane;
  56945. /**
  56946. * Define how deep under the surface we should see.
  56947. */
  56948. depth: number;
  56949. /**
  56950. * Creates a refraction texture used by refraction channel of the standard material.
  56951. * It is like a mirror but to see through a material.
  56952. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56953. * @param name Define the texture name
  56954. * @param size Define the size of the underlying texture
  56955. * @param scene Define the scene the refraction belongs to
  56956. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56957. */
  56958. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56959. /**
  56960. * Clone the refraction texture.
  56961. * @returns the cloned texture
  56962. */
  56963. clone(): RefractionTexture;
  56964. /**
  56965. * Serialize the texture to a JSON representation you could use in Parse later on
  56966. * @returns the serialized JSON representation
  56967. */
  56968. serialize(): any;
  56969. }
  56970. }
  56971. declare module BABYLON {
  56972. /**
  56973. * Defines the options related to the creation of an HtmlElementTexture
  56974. */
  56975. export interface IHtmlElementTextureOptions {
  56976. /**
  56977. * Defines wether mip maps should be created or not.
  56978. */
  56979. generateMipMaps?: boolean;
  56980. /**
  56981. * Defines the sampling mode of the texture.
  56982. */
  56983. samplingMode?: number;
  56984. /**
  56985. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56986. */
  56987. engine: Nullable<ThinEngine>;
  56988. /**
  56989. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56990. */
  56991. scene: Nullable<Scene>;
  56992. }
  56993. /**
  56994. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56995. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56996. * is automatically managed.
  56997. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56998. * in your application.
  56999. *
  57000. * As the update is not automatic, you need to call them manually.
  57001. */
  57002. export class HtmlElementTexture extends BaseTexture {
  57003. /**
  57004. * The texture URL.
  57005. */
  57006. element: HTMLVideoElement | HTMLCanvasElement;
  57007. private static readonly DefaultOptions;
  57008. private _textureMatrix;
  57009. private _engine;
  57010. private _isVideo;
  57011. private _generateMipMaps;
  57012. private _samplingMode;
  57013. /**
  57014. * Instantiates a HtmlElementTexture from the following parameters.
  57015. *
  57016. * @param name Defines the name of the texture
  57017. * @param element Defines the video or canvas the texture is filled with
  57018. * @param options Defines the other none mandatory texture creation options
  57019. */
  57020. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57021. private _createInternalTexture;
  57022. /**
  57023. * Returns the texture matrix used in most of the material.
  57024. */
  57025. getTextureMatrix(): Matrix;
  57026. /**
  57027. * Updates the content of the texture.
  57028. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57029. */
  57030. update(invertY?: Nullable<boolean>): void;
  57031. }
  57032. }
  57033. declare module BABYLON {
  57034. /**
  57035. * Defines the basic options interface of a TexturePacker Frame
  57036. */
  57037. export interface ITexturePackerFrame {
  57038. /**
  57039. * The frame ID
  57040. */
  57041. id: number;
  57042. /**
  57043. * The frames Scale
  57044. */
  57045. scale: Vector2;
  57046. /**
  57047. * The Frames offset
  57048. */
  57049. offset: Vector2;
  57050. }
  57051. /**
  57052. * This is a support class for frame Data on texture packer sets.
  57053. */
  57054. export class TexturePackerFrame implements ITexturePackerFrame {
  57055. /**
  57056. * The frame ID
  57057. */
  57058. id: number;
  57059. /**
  57060. * The frames Scale
  57061. */
  57062. scale: Vector2;
  57063. /**
  57064. * The Frames offset
  57065. */
  57066. offset: Vector2;
  57067. /**
  57068. * Initializes a texture package frame.
  57069. * @param id The numerical frame identifier
  57070. * @param scale Scalar Vector2 for UV frame
  57071. * @param offset Vector2 for the frame position in UV units.
  57072. * @returns TexturePackerFrame
  57073. */
  57074. constructor(id: number, scale: Vector2, offset: Vector2);
  57075. }
  57076. }
  57077. declare module BABYLON {
  57078. /**
  57079. * Defines the basic options interface of a TexturePacker
  57080. */
  57081. export interface ITexturePackerOptions {
  57082. /**
  57083. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57084. */
  57085. map?: string[];
  57086. /**
  57087. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57088. */
  57089. uvsIn?: string;
  57090. /**
  57091. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57092. */
  57093. uvsOut?: string;
  57094. /**
  57095. * number representing the layout style. Defaults to LAYOUT_STRIP
  57096. */
  57097. layout?: number;
  57098. /**
  57099. * number of columns if using custom column count layout(2). This defaults to 4.
  57100. */
  57101. colnum?: number;
  57102. /**
  57103. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57104. */
  57105. updateInputMeshes?: boolean;
  57106. /**
  57107. * boolean flag to dispose all the source textures. Defaults to true.
  57108. */
  57109. disposeSources?: boolean;
  57110. /**
  57111. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57112. */
  57113. fillBlanks?: boolean;
  57114. /**
  57115. * string value representing the context fill style color. Defaults to 'black'.
  57116. */
  57117. customFillColor?: string;
  57118. /**
  57119. * Width and Height Value of each Frame in the TexturePacker Sets
  57120. */
  57121. frameSize?: number;
  57122. /**
  57123. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57124. */
  57125. paddingRatio?: number;
  57126. /**
  57127. * Number that declares the fill method for the padding gutter.
  57128. */
  57129. paddingMode?: number;
  57130. /**
  57131. * If in SUBUV_COLOR padding mode what color to use.
  57132. */
  57133. paddingColor?: Color3 | Color4;
  57134. }
  57135. /**
  57136. * Defines the basic interface of a TexturePacker JSON File
  57137. */
  57138. export interface ITexturePackerJSON {
  57139. /**
  57140. * The frame ID
  57141. */
  57142. name: string;
  57143. /**
  57144. * The base64 channel data
  57145. */
  57146. sets: any;
  57147. /**
  57148. * The options of the Packer
  57149. */
  57150. options: ITexturePackerOptions;
  57151. /**
  57152. * The frame data of the Packer
  57153. */
  57154. frames: Array<number>;
  57155. }
  57156. /**
  57157. * This is a support class that generates a series of packed texture sets.
  57158. * @see https://doc.babylonjs.com/babylon101/materials
  57159. */
  57160. export class TexturePacker {
  57161. /** Packer Layout Constant 0 */
  57162. static readonly LAYOUT_STRIP: number;
  57163. /** Packer Layout Constant 1 */
  57164. static readonly LAYOUT_POWER2: number;
  57165. /** Packer Layout Constant 2 */
  57166. static readonly LAYOUT_COLNUM: number;
  57167. /** Packer Layout Constant 0 */
  57168. static readonly SUBUV_WRAP: number;
  57169. /** Packer Layout Constant 1 */
  57170. static readonly SUBUV_EXTEND: number;
  57171. /** Packer Layout Constant 2 */
  57172. static readonly SUBUV_COLOR: number;
  57173. /** The Name of the Texture Package */
  57174. name: string;
  57175. /** The scene scope of the TexturePacker */
  57176. scene: Scene;
  57177. /** The Meshes to target */
  57178. meshes: AbstractMesh[];
  57179. /** Arguments passed with the Constructor */
  57180. options: ITexturePackerOptions;
  57181. /** The promise that is started upon initialization */
  57182. promise: Nullable<Promise<TexturePacker | string>>;
  57183. /** The Container object for the channel sets that are generated */
  57184. sets: object;
  57185. /** The Container array for the frames that are generated */
  57186. frames: TexturePackerFrame[];
  57187. /** The expected number of textures the system is parsing. */
  57188. private _expecting;
  57189. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57190. private _paddingValue;
  57191. /**
  57192. * Initializes a texture package series from an array of meshes or a single mesh.
  57193. * @param name The name of the package
  57194. * @param meshes The target meshes to compose the package from
  57195. * @param options The arguments that texture packer should follow while building.
  57196. * @param scene The scene which the textures are scoped to.
  57197. * @returns TexturePacker
  57198. */
  57199. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57200. /**
  57201. * Starts the package process
  57202. * @param resolve The promises resolution function
  57203. * @returns TexturePacker
  57204. */
  57205. private _createFrames;
  57206. /**
  57207. * Calculates the Size of the Channel Sets
  57208. * @returns Vector2
  57209. */
  57210. private _calculateSize;
  57211. /**
  57212. * Calculates the UV data for the frames.
  57213. * @param baseSize the base frameSize
  57214. * @param padding the base frame padding
  57215. * @param dtSize size of the Dynamic Texture for that channel
  57216. * @param dtUnits is 1/dtSize
  57217. * @param update flag to update the input meshes
  57218. */
  57219. private _calculateMeshUVFrames;
  57220. /**
  57221. * Calculates the frames Offset.
  57222. * @param index of the frame
  57223. * @returns Vector2
  57224. */
  57225. private _getFrameOffset;
  57226. /**
  57227. * Updates a Mesh to the frame data
  57228. * @param mesh that is the target
  57229. * @param frameID or the frame index
  57230. */
  57231. private _updateMeshUV;
  57232. /**
  57233. * Updates a Meshes materials to use the texture packer channels
  57234. * @param m is the mesh to target
  57235. * @param force all channels on the packer to be set.
  57236. */
  57237. private _updateTextureReferences;
  57238. /**
  57239. * Public method to set a Mesh to a frame
  57240. * @param m that is the target
  57241. * @param frameID or the frame index
  57242. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57243. */
  57244. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57245. /**
  57246. * Starts the async promise to compile the texture packer.
  57247. * @returns Promise<void>
  57248. */
  57249. processAsync(): Promise<void>;
  57250. /**
  57251. * Disposes all textures associated with this packer
  57252. */
  57253. dispose(): void;
  57254. /**
  57255. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57256. * @param imageType is the image type to use.
  57257. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57258. */
  57259. download(imageType?: string, quality?: number): void;
  57260. /**
  57261. * Public method to load a texturePacker JSON file.
  57262. * @param data of the JSON file in string format.
  57263. */
  57264. updateFromJSON(data: string): void;
  57265. }
  57266. }
  57267. declare module BABYLON {
  57268. /**
  57269. * Enum used to define the target of a block
  57270. */
  57271. export enum NodeMaterialBlockTargets {
  57272. /** Vertex shader */
  57273. Vertex = 1,
  57274. /** Fragment shader */
  57275. Fragment = 2,
  57276. /** Neutral */
  57277. Neutral = 4,
  57278. /** Vertex and Fragment */
  57279. VertexAndFragment = 3
  57280. }
  57281. }
  57282. declare module BABYLON {
  57283. /**
  57284. * Defines the kind of connection point for node based material
  57285. */
  57286. export enum NodeMaterialBlockConnectionPointTypes {
  57287. /** Float */
  57288. Float = 1,
  57289. /** Int */
  57290. Int = 2,
  57291. /** Vector2 */
  57292. Vector2 = 4,
  57293. /** Vector3 */
  57294. Vector3 = 8,
  57295. /** Vector4 */
  57296. Vector4 = 16,
  57297. /** Color3 */
  57298. Color3 = 32,
  57299. /** Color4 */
  57300. Color4 = 64,
  57301. /** Matrix */
  57302. Matrix = 128,
  57303. /** Detect type based on connection */
  57304. AutoDetect = 1024,
  57305. /** Output type that will be defined by input type */
  57306. BasedOnInput = 2048
  57307. }
  57308. }
  57309. declare module BABYLON {
  57310. /**
  57311. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57312. */
  57313. export enum NodeMaterialBlockConnectionPointMode {
  57314. /** Value is an uniform */
  57315. Uniform = 0,
  57316. /** Value is a mesh attribute */
  57317. Attribute = 1,
  57318. /** Value is a varying between vertex and fragment shaders */
  57319. Varying = 2,
  57320. /** Mode is undefined */
  57321. Undefined = 3
  57322. }
  57323. }
  57324. declare module BABYLON {
  57325. /**
  57326. * Enum used to define system values e.g. values automatically provided by the system
  57327. */
  57328. export enum NodeMaterialSystemValues {
  57329. /** World */
  57330. World = 1,
  57331. /** View */
  57332. View = 2,
  57333. /** Projection */
  57334. Projection = 3,
  57335. /** ViewProjection */
  57336. ViewProjection = 4,
  57337. /** WorldView */
  57338. WorldView = 5,
  57339. /** WorldViewProjection */
  57340. WorldViewProjection = 6,
  57341. /** CameraPosition */
  57342. CameraPosition = 7,
  57343. /** Fog Color */
  57344. FogColor = 8,
  57345. /** Delta time */
  57346. DeltaTime = 9
  57347. }
  57348. }
  57349. declare module BABYLON {
  57350. /**
  57351. * Root class for all node material optimizers
  57352. */
  57353. export class NodeMaterialOptimizer {
  57354. /**
  57355. * Function used to optimize a NodeMaterial graph
  57356. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57357. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57358. */
  57359. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57360. }
  57361. }
  57362. declare module BABYLON {
  57363. /**
  57364. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57365. */
  57366. export class TransformBlock extends NodeMaterialBlock {
  57367. /**
  57368. * Defines the value to use to complement W value to transform it to a Vector4
  57369. */
  57370. complementW: number;
  57371. /**
  57372. * Defines the value to use to complement z value to transform it to a Vector4
  57373. */
  57374. complementZ: number;
  57375. /**
  57376. * Creates a new TransformBlock
  57377. * @param name defines the block name
  57378. */
  57379. constructor(name: string);
  57380. /**
  57381. * Gets the current class name
  57382. * @returns the class name
  57383. */
  57384. getClassName(): string;
  57385. /**
  57386. * Gets the vector input
  57387. */
  57388. get vector(): NodeMaterialConnectionPoint;
  57389. /**
  57390. * Gets the output component
  57391. */
  57392. get output(): NodeMaterialConnectionPoint;
  57393. /**
  57394. * Gets the xyz output component
  57395. */
  57396. get xyz(): NodeMaterialConnectionPoint;
  57397. /**
  57398. * Gets the matrix transform input
  57399. */
  57400. get transform(): NodeMaterialConnectionPoint;
  57401. protected _buildBlock(state: NodeMaterialBuildState): this;
  57402. serialize(): any;
  57403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57404. protected _dumpPropertiesCode(): string;
  57405. }
  57406. }
  57407. declare module BABYLON {
  57408. /**
  57409. * Block used to output the vertex position
  57410. */
  57411. export class VertexOutputBlock extends NodeMaterialBlock {
  57412. /**
  57413. * Creates a new VertexOutputBlock
  57414. * @param name defines the block name
  57415. */
  57416. constructor(name: string);
  57417. /**
  57418. * Gets the current class name
  57419. * @returns the class name
  57420. */
  57421. getClassName(): string;
  57422. /**
  57423. * Gets the vector input component
  57424. */
  57425. get vector(): NodeMaterialConnectionPoint;
  57426. protected _buildBlock(state: NodeMaterialBuildState): this;
  57427. }
  57428. }
  57429. declare module BABYLON {
  57430. /**
  57431. * Block used to output the final color
  57432. */
  57433. export class FragmentOutputBlock extends NodeMaterialBlock {
  57434. /**
  57435. * Create a new FragmentOutputBlock
  57436. * @param name defines the block name
  57437. */
  57438. constructor(name: string);
  57439. /**
  57440. * Gets the current class name
  57441. * @returns the class name
  57442. */
  57443. getClassName(): string;
  57444. /**
  57445. * Gets the rgba input component
  57446. */
  57447. get rgba(): NodeMaterialConnectionPoint;
  57448. /**
  57449. * Gets the rgb input component
  57450. */
  57451. get rgb(): NodeMaterialConnectionPoint;
  57452. /**
  57453. * Gets the a input component
  57454. */
  57455. get a(): NodeMaterialConnectionPoint;
  57456. protected _buildBlock(state: NodeMaterialBuildState): this;
  57457. }
  57458. }
  57459. declare module BABYLON {
  57460. /**
  57461. * Block used to read a reflection texture from a sampler
  57462. */
  57463. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57464. private _define3DName;
  57465. private _defineCubicName;
  57466. private _defineExplicitName;
  57467. private _defineProjectionName;
  57468. private _defineLocalCubicName;
  57469. private _defineSphericalName;
  57470. private _definePlanarName;
  57471. private _defineEquirectangularName;
  57472. private _defineMirroredEquirectangularFixedName;
  57473. private _defineEquirectangularFixedName;
  57474. private _defineSkyboxName;
  57475. private _cubeSamplerName;
  57476. private _2DSamplerName;
  57477. private _positionUVWName;
  57478. private _directionWName;
  57479. private _reflectionCoordsName;
  57480. private _reflection2DCoordsName;
  57481. private _reflectionColorName;
  57482. private _reflectionMatrixName;
  57483. /**
  57484. * Gets or sets the texture associated with the node
  57485. */
  57486. texture: Nullable<BaseTexture>;
  57487. /**
  57488. * Create a new TextureBlock
  57489. * @param name defines the block name
  57490. */
  57491. constructor(name: string);
  57492. /**
  57493. * Gets the current class name
  57494. * @returns the class name
  57495. */
  57496. getClassName(): string;
  57497. /**
  57498. * Gets the world position input component
  57499. */
  57500. get position(): NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the world position input component
  57503. */
  57504. get worldPosition(): NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the world normal input component
  57507. */
  57508. get worldNormal(): NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the world input component
  57511. */
  57512. get world(): NodeMaterialConnectionPoint;
  57513. /**
  57514. * Gets the camera (or eye) position component
  57515. */
  57516. get cameraPosition(): NodeMaterialConnectionPoint;
  57517. /**
  57518. * Gets the view input component
  57519. */
  57520. get view(): NodeMaterialConnectionPoint;
  57521. /**
  57522. * Gets the rgb output component
  57523. */
  57524. get rgb(): NodeMaterialConnectionPoint;
  57525. /**
  57526. * Gets the r output component
  57527. */
  57528. get r(): NodeMaterialConnectionPoint;
  57529. /**
  57530. * Gets the g output component
  57531. */
  57532. get g(): NodeMaterialConnectionPoint;
  57533. /**
  57534. * Gets the b output component
  57535. */
  57536. get b(): NodeMaterialConnectionPoint;
  57537. autoConfigure(material: NodeMaterial): void;
  57538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57539. isReady(): boolean;
  57540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57541. private _injectVertexCode;
  57542. private _writeOutput;
  57543. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57544. protected _dumpPropertiesCode(): string;
  57545. serialize(): any;
  57546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57547. }
  57548. }
  57549. declare module BABYLON {
  57550. /**
  57551. * Interface used to configure the node material editor
  57552. */
  57553. export interface INodeMaterialEditorOptions {
  57554. /** Define the URl to load node editor script */
  57555. editorURL?: string;
  57556. }
  57557. /** @hidden */
  57558. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57559. NORMAL: boolean;
  57560. TANGENT: boolean;
  57561. UV1: boolean;
  57562. /** BONES */
  57563. NUM_BONE_INFLUENCERS: number;
  57564. BonesPerMesh: number;
  57565. BONETEXTURE: boolean;
  57566. /** MORPH TARGETS */
  57567. MORPHTARGETS: boolean;
  57568. MORPHTARGETS_NORMAL: boolean;
  57569. MORPHTARGETS_TANGENT: boolean;
  57570. MORPHTARGETS_UV: boolean;
  57571. NUM_MORPH_INFLUENCERS: number;
  57572. /** IMAGE PROCESSING */
  57573. IMAGEPROCESSING: boolean;
  57574. VIGNETTE: boolean;
  57575. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57576. VIGNETTEBLENDMODEOPAQUE: boolean;
  57577. TONEMAPPING: boolean;
  57578. TONEMAPPING_ACES: boolean;
  57579. CONTRAST: boolean;
  57580. EXPOSURE: boolean;
  57581. COLORCURVES: boolean;
  57582. COLORGRADING: boolean;
  57583. COLORGRADING3D: boolean;
  57584. SAMPLER3DGREENDEPTH: boolean;
  57585. SAMPLER3DBGRMAP: boolean;
  57586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57587. /** MISC. */
  57588. BUMPDIRECTUV: number;
  57589. constructor();
  57590. setValue(name: string, value: boolean): void;
  57591. }
  57592. /**
  57593. * Class used to configure NodeMaterial
  57594. */
  57595. export interface INodeMaterialOptions {
  57596. /**
  57597. * Defines if blocks should emit comments
  57598. */
  57599. emitComments: boolean;
  57600. }
  57601. /**
  57602. * Class used to create a node based material built by assembling shader blocks
  57603. */
  57604. export class NodeMaterial extends PushMaterial {
  57605. private static _BuildIdGenerator;
  57606. private _options;
  57607. private _vertexCompilationState;
  57608. private _fragmentCompilationState;
  57609. private _sharedData;
  57610. private _buildId;
  57611. private _buildWasSuccessful;
  57612. private _cachedWorldViewMatrix;
  57613. private _cachedWorldViewProjectionMatrix;
  57614. private _optimizers;
  57615. private _animationFrame;
  57616. /** Define the Url to load node editor script */
  57617. static EditorURL: string;
  57618. /** Define the Url to load snippets */
  57619. static SnippetUrl: string;
  57620. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57621. static IgnoreTexturesAtLoadTime: boolean;
  57622. private BJSNODEMATERIALEDITOR;
  57623. /** Get the inspector from bundle or global */
  57624. private _getGlobalNodeMaterialEditor;
  57625. /**
  57626. * Snippet ID if the material was created from the snippet server
  57627. */
  57628. snippetId: string;
  57629. /**
  57630. * Gets or sets data used by visual editor
  57631. * @see https://nme.babylonjs.com
  57632. */
  57633. editorData: any;
  57634. /**
  57635. * 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)
  57636. */
  57637. ignoreAlpha: boolean;
  57638. /**
  57639. * Defines the maximum number of lights that can be used in the material
  57640. */
  57641. maxSimultaneousLights: number;
  57642. /**
  57643. * Observable raised when the material is built
  57644. */
  57645. onBuildObservable: Observable<NodeMaterial>;
  57646. /**
  57647. * Gets or sets the root nodes of the material vertex shader
  57648. */
  57649. _vertexOutputNodes: NodeMaterialBlock[];
  57650. /**
  57651. * Gets or sets the root nodes of the material fragment (pixel) shader
  57652. */
  57653. _fragmentOutputNodes: NodeMaterialBlock[];
  57654. /** Gets or sets options to control the node material overall behavior */
  57655. get options(): INodeMaterialOptions;
  57656. set options(options: INodeMaterialOptions);
  57657. /**
  57658. * Default configuration related to image processing available in the standard Material.
  57659. */
  57660. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57661. /**
  57662. * Gets the image processing configuration used either in this material.
  57663. */
  57664. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57665. /**
  57666. * Sets the Default image processing configuration used either in the this material.
  57667. *
  57668. * If sets to null, the scene one is in use.
  57669. */
  57670. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57671. /**
  57672. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57673. */
  57674. attachedBlocks: NodeMaterialBlock[];
  57675. /**
  57676. * Create a new node based material
  57677. * @param name defines the material name
  57678. * @param scene defines the hosting scene
  57679. * @param options defines creation option
  57680. */
  57681. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57682. /**
  57683. * Gets the current class name of the material e.g. "NodeMaterial"
  57684. * @returns the class name
  57685. */
  57686. getClassName(): string;
  57687. /**
  57688. * Keep track of the image processing observer to allow dispose and replace.
  57689. */
  57690. private _imageProcessingObserver;
  57691. /**
  57692. * Attaches a new image processing configuration to the Standard Material.
  57693. * @param configuration
  57694. */
  57695. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57696. /**
  57697. * Get a block by its name
  57698. * @param name defines the name of the block to retrieve
  57699. * @returns the required block or null if not found
  57700. */
  57701. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57702. /**
  57703. * Get a block by its name
  57704. * @param predicate defines the predicate used to find the good candidate
  57705. * @returns the required block or null if not found
  57706. */
  57707. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57708. /**
  57709. * Get an input block by its name
  57710. * @param predicate defines the predicate used to find the good candidate
  57711. * @returns the required input block or null if not found
  57712. */
  57713. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57714. /**
  57715. * Gets the list of input blocks attached to this material
  57716. * @returns an array of InputBlocks
  57717. */
  57718. getInputBlocks(): InputBlock[];
  57719. /**
  57720. * Adds a new optimizer to the list of optimizers
  57721. * @param optimizer defines the optimizers to add
  57722. * @returns the current material
  57723. */
  57724. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57725. /**
  57726. * Remove an optimizer from the list of optimizers
  57727. * @param optimizer defines the optimizers to remove
  57728. * @returns the current material
  57729. */
  57730. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57731. /**
  57732. * Add a new block to the list of output nodes
  57733. * @param node defines the node to add
  57734. * @returns the current material
  57735. */
  57736. addOutputNode(node: NodeMaterialBlock): this;
  57737. /**
  57738. * Remove a block from the list of root nodes
  57739. * @param node defines the node to remove
  57740. * @returns the current material
  57741. */
  57742. removeOutputNode(node: NodeMaterialBlock): this;
  57743. private _addVertexOutputNode;
  57744. private _removeVertexOutputNode;
  57745. private _addFragmentOutputNode;
  57746. private _removeFragmentOutputNode;
  57747. /**
  57748. * Specifies if the material will require alpha blending
  57749. * @returns a boolean specifying if alpha blending is needed
  57750. */
  57751. needAlphaBlending(): boolean;
  57752. /**
  57753. * Specifies if this material should be rendered in alpha test mode
  57754. * @returns a boolean specifying if an alpha test is needed.
  57755. */
  57756. needAlphaTesting(): boolean;
  57757. private _initializeBlock;
  57758. private _resetDualBlocks;
  57759. /**
  57760. * Remove a block from the current node material
  57761. * @param block defines the block to remove
  57762. */
  57763. removeBlock(block: NodeMaterialBlock): void;
  57764. /**
  57765. * Build the material and generates the inner effect
  57766. * @param verbose defines if the build should log activity
  57767. */
  57768. build(verbose?: boolean): void;
  57769. /**
  57770. * Runs an otpimization phase to try to improve the shader code
  57771. */
  57772. optimize(): void;
  57773. private _prepareDefinesForAttributes;
  57774. /**
  57775. * Get if the submesh is ready to be used and all its information available.
  57776. * Child classes can use it to update shaders
  57777. * @param mesh defines the mesh to check
  57778. * @param subMesh defines which submesh to check
  57779. * @param useInstances specifies that instances should be used
  57780. * @returns a boolean indicating that the submesh is ready or not
  57781. */
  57782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57783. /**
  57784. * Get a string representing the shaders built by the current node graph
  57785. */
  57786. get compiledShaders(): string;
  57787. /**
  57788. * Binds the world matrix to the material
  57789. * @param world defines the world transformation matrix
  57790. */
  57791. bindOnlyWorldMatrix(world: Matrix): void;
  57792. /**
  57793. * Binds the submesh to this material by preparing the effect and shader to draw
  57794. * @param world defines the world transformation matrix
  57795. * @param mesh defines the mesh containing the submesh
  57796. * @param subMesh defines the submesh to bind the material to
  57797. */
  57798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57799. /**
  57800. * Gets the active textures from the material
  57801. * @returns an array of textures
  57802. */
  57803. getActiveTextures(): BaseTexture[];
  57804. /**
  57805. * Gets the list of texture blocks
  57806. * @returns an array of texture blocks
  57807. */
  57808. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57809. /**
  57810. * Specifies if the material uses a texture
  57811. * @param texture defines the texture to check against the material
  57812. * @returns a boolean specifying if the material uses the texture
  57813. */
  57814. hasTexture(texture: BaseTexture): boolean;
  57815. /**
  57816. * Disposes the material
  57817. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57818. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57819. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57820. */
  57821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57822. /** Creates the node editor window. */
  57823. private _createNodeEditor;
  57824. /**
  57825. * Launch the node material editor
  57826. * @param config Define the configuration of the editor
  57827. * @return a promise fulfilled when the node editor is visible
  57828. */
  57829. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57830. /**
  57831. * Clear the current material
  57832. */
  57833. clear(): void;
  57834. /**
  57835. * Clear the current material and set it to a default state
  57836. */
  57837. setToDefault(): void;
  57838. /**
  57839. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57840. * @param url defines the url to load from
  57841. * @returns a promise that will fullfil when the material is fully loaded
  57842. */
  57843. loadAsync(url: string): Promise<void>;
  57844. private _gatherBlocks;
  57845. /**
  57846. * Generate a string containing the code declaration required to create an equivalent of this material
  57847. * @returns a string
  57848. */
  57849. generateCode(): string;
  57850. /**
  57851. * Serializes this material in a JSON representation
  57852. * @returns the serialized material object
  57853. */
  57854. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57855. private _restoreConnections;
  57856. /**
  57857. * Clear the current graph and load a new one from a serialization object
  57858. * @param source defines the JSON representation of the material
  57859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57860. */
  57861. loadFromSerialization(source: any, rootUrl?: string): void;
  57862. /**
  57863. * Makes a duplicate of the current material.
  57864. * @param name - name to use for the new material.
  57865. */
  57866. clone(name: string): NodeMaterial;
  57867. /**
  57868. * Creates a node material from parsed material data
  57869. * @param source defines the JSON representation of the material
  57870. * @param scene defines the hosting scene
  57871. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57872. * @returns a new node material
  57873. */
  57874. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57875. /**
  57876. * Creates a node material from a snippet saved in a remote file
  57877. * @param name defines the name of the material to create
  57878. * @param url defines the url to load from
  57879. * @param scene defines the hosting scene
  57880. * @returns a promise that will resolve to the new node material
  57881. */
  57882. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57883. /**
  57884. * Creates a node material from a snippet saved by the node material editor
  57885. * @param snippetId defines the snippet to load
  57886. * @param scene defines the hosting scene
  57887. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57888. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57889. * @returns a promise that will resolve to the new node material
  57890. */
  57891. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57892. /**
  57893. * Creates a new node material set to default basic configuration
  57894. * @param name defines the name of the material
  57895. * @param scene defines the hosting scene
  57896. * @returns a new NodeMaterial
  57897. */
  57898. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57899. }
  57900. }
  57901. declare module BABYLON {
  57902. /**
  57903. * Block used to read a texture from a sampler
  57904. */
  57905. export class TextureBlock extends NodeMaterialBlock {
  57906. private _defineName;
  57907. private _linearDefineName;
  57908. private _tempTextureRead;
  57909. private _samplerName;
  57910. private _transformedUVName;
  57911. private _textureTransformName;
  57912. private _textureInfoName;
  57913. private _mainUVName;
  57914. private _mainUVDefineName;
  57915. /**
  57916. * Gets or sets the texture associated with the node
  57917. */
  57918. texture: Nullable<Texture>;
  57919. /**
  57920. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57921. */
  57922. convertToGammaSpace: boolean;
  57923. /**
  57924. * Create a new TextureBlock
  57925. * @param name defines the block name
  57926. */
  57927. constructor(name: string);
  57928. /**
  57929. * Gets the current class name
  57930. * @returns the class name
  57931. */
  57932. getClassName(): string;
  57933. /**
  57934. * Gets the uv input component
  57935. */
  57936. get uv(): NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the rgba output component
  57939. */
  57940. get rgba(): NodeMaterialConnectionPoint;
  57941. /**
  57942. * Gets the rgb output component
  57943. */
  57944. get rgb(): NodeMaterialConnectionPoint;
  57945. /**
  57946. * Gets the r output component
  57947. */
  57948. get r(): NodeMaterialConnectionPoint;
  57949. /**
  57950. * Gets the g output component
  57951. */
  57952. get g(): NodeMaterialConnectionPoint;
  57953. /**
  57954. * Gets the b output component
  57955. */
  57956. get b(): NodeMaterialConnectionPoint;
  57957. /**
  57958. * Gets the a output component
  57959. */
  57960. get a(): NodeMaterialConnectionPoint;
  57961. get target(): NodeMaterialBlockTargets;
  57962. autoConfigure(material: NodeMaterial): void;
  57963. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57965. isReady(): boolean;
  57966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57967. private get _isMixed();
  57968. private _injectVertexCode;
  57969. private _writeTextureRead;
  57970. private _writeOutput;
  57971. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57972. protected _dumpPropertiesCode(): string;
  57973. serialize(): any;
  57974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57975. }
  57976. }
  57977. declare module BABYLON {
  57978. /**
  57979. * Class used to store shared data between 2 NodeMaterialBuildState
  57980. */
  57981. export class NodeMaterialBuildStateSharedData {
  57982. /**
  57983. * Gets the list of emitted varyings
  57984. */
  57985. temps: string[];
  57986. /**
  57987. * Gets the list of emitted varyings
  57988. */
  57989. varyings: string[];
  57990. /**
  57991. * Gets the varying declaration string
  57992. */
  57993. varyingDeclaration: string;
  57994. /**
  57995. * Input blocks
  57996. */
  57997. inputBlocks: InputBlock[];
  57998. /**
  57999. * Input blocks
  58000. */
  58001. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58002. /**
  58003. * Bindable blocks (Blocks that need to set data to the effect)
  58004. */
  58005. bindableBlocks: NodeMaterialBlock[];
  58006. /**
  58007. * List of blocks that can provide a compilation fallback
  58008. */
  58009. blocksWithFallbacks: NodeMaterialBlock[];
  58010. /**
  58011. * List of blocks that can provide a define update
  58012. */
  58013. blocksWithDefines: NodeMaterialBlock[];
  58014. /**
  58015. * List of blocks that can provide a repeatable content
  58016. */
  58017. repeatableContentBlocks: NodeMaterialBlock[];
  58018. /**
  58019. * List of blocks that can provide a dynamic list of uniforms
  58020. */
  58021. dynamicUniformBlocks: NodeMaterialBlock[];
  58022. /**
  58023. * List of blocks that can block the isReady function for the material
  58024. */
  58025. blockingBlocks: NodeMaterialBlock[];
  58026. /**
  58027. * Gets the list of animated inputs
  58028. */
  58029. animatedInputs: InputBlock[];
  58030. /**
  58031. * Build Id used to avoid multiple recompilations
  58032. */
  58033. buildId: number;
  58034. /** List of emitted variables */
  58035. variableNames: {
  58036. [key: string]: number;
  58037. };
  58038. /** List of emitted defines */
  58039. defineNames: {
  58040. [key: string]: number;
  58041. };
  58042. /** Should emit comments? */
  58043. emitComments: boolean;
  58044. /** Emit build activity */
  58045. verbose: boolean;
  58046. /** Gets or sets the hosting scene */
  58047. scene: Scene;
  58048. /**
  58049. * Gets the compilation hints emitted at compilation time
  58050. */
  58051. hints: {
  58052. needWorldViewMatrix: boolean;
  58053. needWorldViewProjectionMatrix: boolean;
  58054. needAlphaBlending: boolean;
  58055. needAlphaTesting: boolean;
  58056. };
  58057. /**
  58058. * List of compilation checks
  58059. */
  58060. checks: {
  58061. emitVertex: boolean;
  58062. emitFragment: boolean;
  58063. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58064. };
  58065. /** Creates a new shared data */
  58066. constructor();
  58067. /**
  58068. * Emits console errors and exceptions if there is a failing check
  58069. */
  58070. emitErrors(): void;
  58071. }
  58072. }
  58073. declare module BABYLON {
  58074. /**
  58075. * Class used to store node based material build state
  58076. */
  58077. export class NodeMaterialBuildState {
  58078. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58079. supportUniformBuffers: boolean;
  58080. /**
  58081. * Gets the list of emitted attributes
  58082. */
  58083. attributes: string[];
  58084. /**
  58085. * Gets the list of emitted uniforms
  58086. */
  58087. uniforms: string[];
  58088. /**
  58089. * Gets the list of emitted constants
  58090. */
  58091. constants: string[];
  58092. /**
  58093. * Gets the list of emitted samplers
  58094. */
  58095. samplers: string[];
  58096. /**
  58097. * Gets the list of emitted functions
  58098. */
  58099. functions: {
  58100. [key: string]: string;
  58101. };
  58102. /**
  58103. * Gets the list of emitted extensions
  58104. */
  58105. extensions: {
  58106. [key: string]: string;
  58107. };
  58108. /**
  58109. * Gets the target of the compilation state
  58110. */
  58111. target: NodeMaterialBlockTargets;
  58112. /**
  58113. * Gets the list of emitted counters
  58114. */
  58115. counters: {
  58116. [key: string]: number;
  58117. };
  58118. /**
  58119. * Shared data between multiple NodeMaterialBuildState instances
  58120. */
  58121. sharedData: NodeMaterialBuildStateSharedData;
  58122. /** @hidden */
  58123. _vertexState: NodeMaterialBuildState;
  58124. /** @hidden */
  58125. _attributeDeclaration: string;
  58126. /** @hidden */
  58127. _uniformDeclaration: string;
  58128. /** @hidden */
  58129. _constantDeclaration: string;
  58130. /** @hidden */
  58131. _samplerDeclaration: string;
  58132. /** @hidden */
  58133. _varyingTransfer: string;
  58134. private _repeatableContentAnchorIndex;
  58135. /** @hidden */
  58136. _builtCompilationString: string;
  58137. /**
  58138. * Gets the emitted compilation strings
  58139. */
  58140. compilationString: string;
  58141. /**
  58142. * Finalize the compilation strings
  58143. * @param state defines the current compilation state
  58144. */
  58145. finalize(state: NodeMaterialBuildState): void;
  58146. /** @hidden */
  58147. get _repeatableContentAnchor(): string;
  58148. /** @hidden */
  58149. _getFreeVariableName(prefix: string): string;
  58150. /** @hidden */
  58151. _getFreeDefineName(prefix: string): string;
  58152. /** @hidden */
  58153. _excludeVariableName(name: string): void;
  58154. /** @hidden */
  58155. _emit2DSampler(name: string): void;
  58156. /** @hidden */
  58157. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58158. /** @hidden */
  58159. _emitExtension(name: string, extension: string): void;
  58160. /** @hidden */
  58161. _emitFunction(name: string, code: string, comments: string): void;
  58162. /** @hidden */
  58163. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58164. replaceStrings?: {
  58165. search: RegExp;
  58166. replace: string;
  58167. }[];
  58168. repeatKey?: string;
  58169. }): string;
  58170. /** @hidden */
  58171. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58172. repeatKey?: string;
  58173. removeAttributes?: boolean;
  58174. removeUniforms?: boolean;
  58175. removeVaryings?: boolean;
  58176. removeIfDef?: boolean;
  58177. replaceStrings?: {
  58178. search: RegExp;
  58179. replace: string;
  58180. }[];
  58181. }, storeKey?: string): void;
  58182. /** @hidden */
  58183. _registerTempVariable(name: string): boolean;
  58184. /** @hidden */
  58185. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58186. /** @hidden */
  58187. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58188. /** @hidden */
  58189. _emitFloat(value: number): string;
  58190. }
  58191. }
  58192. declare module BABYLON {
  58193. /**
  58194. * Defines a block that can be used inside a node based material
  58195. */
  58196. export class NodeMaterialBlock {
  58197. private _buildId;
  58198. private _buildTarget;
  58199. private _target;
  58200. private _isFinalMerger;
  58201. private _isInput;
  58202. protected _isUnique: boolean;
  58203. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58204. inputsAreExclusive: boolean;
  58205. /** @hidden */
  58206. _codeVariableName: string;
  58207. /** @hidden */
  58208. _inputs: NodeMaterialConnectionPoint[];
  58209. /** @hidden */
  58210. _outputs: NodeMaterialConnectionPoint[];
  58211. /** @hidden */
  58212. _preparationId: number;
  58213. /**
  58214. * Gets or sets the name of the block
  58215. */
  58216. name: string;
  58217. /**
  58218. * Gets or sets the unique id of the node
  58219. */
  58220. uniqueId: number;
  58221. /**
  58222. * Gets or sets the comments associated with this block
  58223. */
  58224. comments: string;
  58225. /**
  58226. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58227. */
  58228. get isUnique(): boolean;
  58229. /**
  58230. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58231. */
  58232. get isFinalMerger(): boolean;
  58233. /**
  58234. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58235. */
  58236. get isInput(): boolean;
  58237. /**
  58238. * Gets or sets the build Id
  58239. */
  58240. get buildId(): number;
  58241. set buildId(value: number);
  58242. /**
  58243. * Gets or sets the target of the block
  58244. */
  58245. get target(): NodeMaterialBlockTargets;
  58246. set target(value: NodeMaterialBlockTargets);
  58247. /**
  58248. * Gets the list of input points
  58249. */
  58250. get inputs(): NodeMaterialConnectionPoint[];
  58251. /** Gets the list of output points */
  58252. get outputs(): NodeMaterialConnectionPoint[];
  58253. /**
  58254. * Find an input by its name
  58255. * @param name defines the name of the input to look for
  58256. * @returns the input or null if not found
  58257. */
  58258. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58259. /**
  58260. * Find an output by its name
  58261. * @param name defines the name of the outputto look for
  58262. * @returns the output or null if not found
  58263. */
  58264. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58265. /**
  58266. * Creates a new NodeMaterialBlock
  58267. * @param name defines the block name
  58268. * @param target defines the target of that block (Vertex by default)
  58269. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58270. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58271. */
  58272. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58273. /**
  58274. * Initialize the block and prepare the context for build
  58275. * @param state defines the state that will be used for the build
  58276. */
  58277. initialize(state: NodeMaterialBuildState): void;
  58278. /**
  58279. * Bind data to effect. Will only be called for blocks with isBindable === true
  58280. * @param effect defines the effect to bind data to
  58281. * @param nodeMaterial defines the hosting NodeMaterial
  58282. * @param mesh defines the mesh that will be rendered
  58283. */
  58284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58285. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58286. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58287. protected _writeFloat(value: number): string;
  58288. /**
  58289. * Gets the current class name e.g. "NodeMaterialBlock"
  58290. * @returns the class name
  58291. */
  58292. getClassName(): string;
  58293. /**
  58294. * Register a new input. Must be called inside a block constructor
  58295. * @param name defines the connection point name
  58296. * @param type defines the connection point type
  58297. * @param isOptional defines a boolean indicating that this input can be omitted
  58298. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58299. * @returns the current block
  58300. */
  58301. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58302. /**
  58303. * Register a new output. Must be called inside a block constructor
  58304. * @param name defines the connection point name
  58305. * @param type defines the connection point type
  58306. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58307. * @returns the current block
  58308. */
  58309. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58310. /**
  58311. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58312. * @param forOutput defines an optional connection point to check compatibility with
  58313. * @returns the first available input or null
  58314. */
  58315. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58316. /**
  58317. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58318. * @param forBlock defines an optional block to check compatibility with
  58319. * @returns the first available input or null
  58320. */
  58321. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58322. /**
  58323. * Gets the sibling of the given output
  58324. * @param current defines the current output
  58325. * @returns the next output in the list or null
  58326. */
  58327. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58328. /**
  58329. * Connect current block with another block
  58330. * @param other defines the block to connect with
  58331. * @param options define the various options to help pick the right connections
  58332. * @returns the current block
  58333. */
  58334. connectTo(other: NodeMaterialBlock, options?: {
  58335. input?: string;
  58336. output?: string;
  58337. outputSwizzle?: string;
  58338. }): this | undefined;
  58339. protected _buildBlock(state: NodeMaterialBuildState): void;
  58340. /**
  58341. * Add uniforms, samplers and uniform buffers at compilation time
  58342. * @param state defines the state to update
  58343. * @param nodeMaterial defines the node material requesting the update
  58344. * @param defines defines the material defines to update
  58345. * @param uniformBuffers defines the list of uniform buffer names
  58346. */
  58347. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58348. /**
  58349. * Add potential fallbacks if shader compilation fails
  58350. * @param mesh defines the mesh to be rendered
  58351. * @param fallbacks defines the current prioritized list of fallbacks
  58352. */
  58353. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58354. /**
  58355. * Initialize defines for shader compilation
  58356. * @param mesh defines the mesh to be rendered
  58357. * @param nodeMaterial defines the node material requesting the update
  58358. * @param defines defines the material defines to update
  58359. * @param useInstances specifies that instances should be used
  58360. */
  58361. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58362. /**
  58363. * Update defines for shader compilation
  58364. * @param mesh defines the mesh to be rendered
  58365. * @param nodeMaterial defines the node material requesting the update
  58366. * @param defines defines the material defines to update
  58367. * @param useInstances specifies that instances should be used
  58368. */
  58369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58370. /**
  58371. * Lets the block try to connect some inputs automatically
  58372. * @param material defines the hosting NodeMaterial
  58373. */
  58374. autoConfigure(material: NodeMaterial): void;
  58375. /**
  58376. * Function called when a block is declared as repeatable content generator
  58377. * @param vertexShaderState defines the current compilation state for the vertex shader
  58378. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58379. * @param mesh defines the mesh to be rendered
  58380. * @param defines defines the material defines to update
  58381. */
  58382. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58383. /**
  58384. * Checks if the block is ready
  58385. * @param mesh defines the mesh to be rendered
  58386. * @param nodeMaterial defines the node material requesting the update
  58387. * @param defines defines the material defines to update
  58388. * @param useInstances specifies that instances should be used
  58389. * @returns true if the block is ready
  58390. */
  58391. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58392. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58393. private _processBuild;
  58394. /**
  58395. * Compile the current node and generate the shader code
  58396. * @param state defines the current compilation state (uniforms, samplers, current string)
  58397. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58398. * @returns true if already built
  58399. */
  58400. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58401. protected _inputRename(name: string): string;
  58402. protected _outputRename(name: string): string;
  58403. protected _dumpPropertiesCode(): string;
  58404. /** @hidden */
  58405. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58406. /** @hidden */
  58407. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58408. /**
  58409. * Clone the current block to a new identical block
  58410. * @param scene defines the hosting scene
  58411. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58412. * @returns a copy of the current block
  58413. */
  58414. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58415. /**
  58416. * Serializes this block in a JSON representation
  58417. * @returns the serialized block object
  58418. */
  58419. serialize(): any;
  58420. /** @hidden */
  58421. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58422. /**
  58423. * Release resources
  58424. */
  58425. dispose(): void;
  58426. }
  58427. }
  58428. declare module BABYLON {
  58429. /**
  58430. * Enum defining the type of animations supported by InputBlock
  58431. */
  58432. export enum AnimatedInputBlockTypes {
  58433. /** No animation */
  58434. None = 0,
  58435. /** Time based animation. Will only work for floats */
  58436. Time = 1
  58437. }
  58438. }
  58439. declare module BABYLON {
  58440. /**
  58441. * Block used to expose an input value
  58442. */
  58443. export class InputBlock extends NodeMaterialBlock {
  58444. private _mode;
  58445. private _associatedVariableName;
  58446. private _storedValue;
  58447. private _valueCallback;
  58448. private _type;
  58449. private _animationType;
  58450. /** Gets or set a value used to limit the range of float values */
  58451. min: number;
  58452. /** Gets or set a value used to limit the range of float values */
  58453. max: number;
  58454. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58455. isBoolean: boolean;
  58456. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58457. matrixMode: number;
  58458. /** @hidden */
  58459. _systemValue: Nullable<NodeMaterialSystemValues>;
  58460. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58461. visibleInInspector: boolean;
  58462. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58463. isConstant: boolean;
  58464. /** Gets or sets the group to use to display this block in the Inspector */
  58465. groupInInspector: string;
  58466. /** Gets an observable raised when the value is changed */
  58467. onValueChangedObservable: Observable<InputBlock>;
  58468. /**
  58469. * Gets or sets the connection point type (default is float)
  58470. */
  58471. get type(): NodeMaterialBlockConnectionPointTypes;
  58472. /**
  58473. * Creates a new InputBlock
  58474. * @param name defines the block name
  58475. * @param target defines the target of that block (Vertex by default)
  58476. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58477. */
  58478. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58479. /**
  58480. * Gets the output component
  58481. */
  58482. get output(): NodeMaterialConnectionPoint;
  58483. /**
  58484. * Set the source of this connection point to a vertex attribute
  58485. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58486. * @returns the current connection point
  58487. */
  58488. setAsAttribute(attributeName?: string): InputBlock;
  58489. /**
  58490. * Set the source of this connection point to a system value
  58491. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58492. * @returns the current connection point
  58493. */
  58494. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58495. /**
  58496. * Gets or sets the value of that point.
  58497. * Please note that this value will be ignored if valueCallback is defined
  58498. */
  58499. get value(): any;
  58500. set value(value: any);
  58501. /**
  58502. * Gets or sets a callback used to get the value of that point.
  58503. * Please note that setting this value will force the connection point to ignore the value property
  58504. */
  58505. get valueCallback(): () => any;
  58506. set valueCallback(value: () => any);
  58507. /**
  58508. * Gets or sets the associated variable name in the shader
  58509. */
  58510. get associatedVariableName(): string;
  58511. set associatedVariableName(value: string);
  58512. /** Gets or sets the type of animation applied to the input */
  58513. get animationType(): AnimatedInputBlockTypes;
  58514. set animationType(value: AnimatedInputBlockTypes);
  58515. /**
  58516. * Gets a boolean indicating that this connection point not defined yet
  58517. */
  58518. get isUndefined(): boolean;
  58519. /**
  58520. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58521. * In this case the connection point name must be the name of the uniform to use.
  58522. * Can only be set on inputs
  58523. */
  58524. get isUniform(): boolean;
  58525. set isUniform(value: boolean);
  58526. /**
  58527. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58528. * In this case the connection point name must be the name of the attribute to use
  58529. * Can only be set on inputs
  58530. */
  58531. get isAttribute(): boolean;
  58532. set isAttribute(value: boolean);
  58533. /**
  58534. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58535. * Can only be set on exit points
  58536. */
  58537. get isVarying(): boolean;
  58538. set isVarying(value: boolean);
  58539. /**
  58540. * Gets a boolean indicating that the current connection point is a system value
  58541. */
  58542. get isSystemValue(): boolean;
  58543. /**
  58544. * Gets or sets the current well known value or null if not defined as a system value
  58545. */
  58546. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58547. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58548. /**
  58549. * Gets the current class name
  58550. * @returns the class name
  58551. */
  58552. getClassName(): string;
  58553. /**
  58554. * Animate the input if animationType !== None
  58555. * @param scene defines the rendering scene
  58556. */
  58557. animate(scene: Scene): void;
  58558. private _emitDefine;
  58559. initialize(state: NodeMaterialBuildState): void;
  58560. /**
  58561. * Set the input block to its default value (based on its type)
  58562. */
  58563. setDefaultValue(): void;
  58564. private _emitConstant;
  58565. private _emit;
  58566. /** @hidden */
  58567. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58568. /** @hidden */
  58569. _transmit(effect: Effect, scene: Scene): void;
  58570. protected _buildBlock(state: NodeMaterialBuildState): void;
  58571. protected _dumpPropertiesCode(): string;
  58572. dispose(): void;
  58573. serialize(): any;
  58574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58575. }
  58576. }
  58577. declare module BABYLON {
  58578. /**
  58579. * Enum used to define the compatibility state between two connection points
  58580. */
  58581. export enum NodeMaterialConnectionPointCompatibilityStates {
  58582. /** Points are compatibles */
  58583. Compatible = 0,
  58584. /** Points are incompatible because of their types */
  58585. TypeIncompatible = 1,
  58586. /** Points are incompatible because of their targets (vertex vs fragment) */
  58587. TargetIncompatible = 2
  58588. }
  58589. /**
  58590. * Defines the direction of a connection point
  58591. */
  58592. export enum NodeMaterialConnectionPointDirection {
  58593. /** Input */
  58594. Input = 0,
  58595. /** Output */
  58596. Output = 1
  58597. }
  58598. /**
  58599. * Defines a connection point for a block
  58600. */
  58601. export class NodeMaterialConnectionPoint {
  58602. /** @hidden */
  58603. _ownerBlock: NodeMaterialBlock;
  58604. /** @hidden */
  58605. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58606. private _endpoints;
  58607. private _associatedVariableName;
  58608. private _direction;
  58609. /** @hidden */
  58610. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58611. /** @hidden */
  58612. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58613. private _type;
  58614. /** @hidden */
  58615. _enforceAssociatedVariableName: boolean;
  58616. /** Gets the direction of the point */
  58617. get direction(): NodeMaterialConnectionPointDirection;
  58618. /**
  58619. * Gets or sets the additional types supported by this connection point
  58620. */
  58621. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58622. /**
  58623. * Gets or sets the additional types excluded by this connection point
  58624. */
  58625. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58626. /**
  58627. * Observable triggered when this point is connected
  58628. */
  58629. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58630. /**
  58631. * Gets or sets the associated variable name in the shader
  58632. */
  58633. get associatedVariableName(): string;
  58634. set associatedVariableName(value: string);
  58635. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58636. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58637. /**
  58638. * Gets or sets the connection point type (default is float)
  58639. */
  58640. get type(): NodeMaterialBlockConnectionPointTypes;
  58641. set type(value: NodeMaterialBlockConnectionPointTypes);
  58642. /**
  58643. * Gets or sets the connection point name
  58644. */
  58645. name: string;
  58646. /**
  58647. * Gets or sets a boolean indicating that this connection point can be omitted
  58648. */
  58649. isOptional: boolean;
  58650. /**
  58651. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58652. */
  58653. define: string;
  58654. /** @hidden */
  58655. _prioritizeVertex: boolean;
  58656. private _target;
  58657. /** Gets or sets the target of that connection point */
  58658. get target(): NodeMaterialBlockTargets;
  58659. set target(value: NodeMaterialBlockTargets);
  58660. /**
  58661. * Gets a boolean indicating that the current point is connected
  58662. */
  58663. get isConnected(): boolean;
  58664. /**
  58665. * Gets a boolean indicating that the current point is connected to an input block
  58666. */
  58667. get isConnectedToInputBlock(): boolean;
  58668. /**
  58669. * Gets a the connected input block (if any)
  58670. */
  58671. get connectInputBlock(): Nullable<InputBlock>;
  58672. /** Get the other side of the connection (if any) */
  58673. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58674. /** Get the block that owns this connection point */
  58675. get ownerBlock(): NodeMaterialBlock;
  58676. /** Get the block connected on the other side of this connection (if any) */
  58677. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58678. /** Get the block connected on the endpoints of this connection (if any) */
  58679. get connectedBlocks(): Array<NodeMaterialBlock>;
  58680. /** Gets the list of connected endpoints */
  58681. get endpoints(): NodeMaterialConnectionPoint[];
  58682. /** Gets a boolean indicating if that output point is connected to at least one input */
  58683. get hasEndpoints(): boolean;
  58684. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58685. get isConnectedInVertexShader(): boolean;
  58686. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58687. get isConnectedInFragmentShader(): boolean;
  58688. /**
  58689. * Creates a new connection point
  58690. * @param name defines the connection point name
  58691. * @param ownerBlock defines the block hosting this connection point
  58692. * @param direction defines the direction of the connection point
  58693. */
  58694. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58695. /**
  58696. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58697. * @returns the class name
  58698. */
  58699. getClassName(): string;
  58700. /**
  58701. * Gets a boolean indicating if the current point can be connected to another point
  58702. * @param connectionPoint defines the other connection point
  58703. * @returns a boolean
  58704. */
  58705. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58706. /**
  58707. * Gets a number indicating if the current point can be connected to another point
  58708. * @param connectionPoint defines the other connection point
  58709. * @returns a number defining the compatibility state
  58710. */
  58711. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58712. /**
  58713. * Connect this point to another connection point
  58714. * @param connectionPoint defines the other connection point
  58715. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58716. * @returns the current connection point
  58717. */
  58718. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58719. /**
  58720. * Disconnect this point from one of his endpoint
  58721. * @param endpoint defines the other connection point
  58722. * @returns the current connection point
  58723. */
  58724. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58725. /**
  58726. * Serializes this point in a JSON representation
  58727. * @returns the serialized point object
  58728. */
  58729. serialize(): any;
  58730. /**
  58731. * Release resources
  58732. */
  58733. dispose(): void;
  58734. }
  58735. }
  58736. declare module BABYLON {
  58737. /**
  58738. * Block used to add support for vertex skinning (bones)
  58739. */
  58740. export class BonesBlock extends NodeMaterialBlock {
  58741. /**
  58742. * Creates a new BonesBlock
  58743. * @param name defines the block name
  58744. */
  58745. constructor(name: string);
  58746. /**
  58747. * Initialize the block and prepare the context for build
  58748. * @param state defines the state that will be used for the build
  58749. */
  58750. initialize(state: NodeMaterialBuildState): void;
  58751. /**
  58752. * Gets the current class name
  58753. * @returns the class name
  58754. */
  58755. getClassName(): string;
  58756. /**
  58757. * Gets the matrix indices input component
  58758. */
  58759. get matricesIndices(): NodeMaterialConnectionPoint;
  58760. /**
  58761. * Gets the matrix weights input component
  58762. */
  58763. get matricesWeights(): NodeMaterialConnectionPoint;
  58764. /**
  58765. * Gets the extra matrix indices input component
  58766. */
  58767. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58768. /**
  58769. * Gets the extra matrix weights input component
  58770. */
  58771. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58772. /**
  58773. * Gets the world input component
  58774. */
  58775. get world(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the output component
  58778. */
  58779. get output(): NodeMaterialConnectionPoint;
  58780. autoConfigure(material: NodeMaterial): void;
  58781. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58784. protected _buildBlock(state: NodeMaterialBuildState): this;
  58785. }
  58786. }
  58787. declare module BABYLON {
  58788. /**
  58789. * Block used to add support for instances
  58790. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58791. */
  58792. export class InstancesBlock extends NodeMaterialBlock {
  58793. /**
  58794. * Creates a new InstancesBlock
  58795. * @param name defines the block name
  58796. */
  58797. constructor(name: string);
  58798. /**
  58799. * Gets the current class name
  58800. * @returns the class name
  58801. */
  58802. getClassName(): string;
  58803. /**
  58804. * Gets the first world row input component
  58805. */
  58806. get world0(): NodeMaterialConnectionPoint;
  58807. /**
  58808. * Gets the second world row input component
  58809. */
  58810. get world1(): NodeMaterialConnectionPoint;
  58811. /**
  58812. * Gets the third world row input component
  58813. */
  58814. get world2(): NodeMaterialConnectionPoint;
  58815. /**
  58816. * Gets the forth world row input component
  58817. */
  58818. get world3(): NodeMaterialConnectionPoint;
  58819. /**
  58820. * Gets the world input component
  58821. */
  58822. get world(): NodeMaterialConnectionPoint;
  58823. /**
  58824. * Gets the output component
  58825. */
  58826. get output(): NodeMaterialConnectionPoint;
  58827. /**
  58828. * Gets the isntanceID component
  58829. */
  58830. get instanceID(): NodeMaterialConnectionPoint;
  58831. autoConfigure(material: NodeMaterial): void;
  58832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58833. protected _buildBlock(state: NodeMaterialBuildState): this;
  58834. }
  58835. }
  58836. declare module BABYLON {
  58837. /**
  58838. * Block used to add morph targets support to vertex shader
  58839. */
  58840. export class MorphTargetsBlock extends NodeMaterialBlock {
  58841. private _repeatableContentAnchor;
  58842. /**
  58843. * Create a new MorphTargetsBlock
  58844. * @param name defines the block name
  58845. */
  58846. constructor(name: string);
  58847. /**
  58848. * Gets the current class name
  58849. * @returns the class name
  58850. */
  58851. getClassName(): string;
  58852. /**
  58853. * Gets the position input component
  58854. */
  58855. get position(): NodeMaterialConnectionPoint;
  58856. /**
  58857. * Gets the normal input component
  58858. */
  58859. get normal(): NodeMaterialConnectionPoint;
  58860. /**
  58861. * Gets the tangent input component
  58862. */
  58863. get tangent(): NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the tangent input component
  58866. */
  58867. get uv(): NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the position output component
  58870. */
  58871. get positionOutput(): NodeMaterialConnectionPoint;
  58872. /**
  58873. * Gets the normal output component
  58874. */
  58875. get normalOutput(): NodeMaterialConnectionPoint;
  58876. /**
  58877. * Gets the tangent output component
  58878. */
  58879. get tangentOutput(): NodeMaterialConnectionPoint;
  58880. /**
  58881. * Gets the tangent output component
  58882. */
  58883. get uvOutput(): NodeMaterialConnectionPoint;
  58884. initialize(state: NodeMaterialBuildState): void;
  58885. autoConfigure(material: NodeMaterial): void;
  58886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58887. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58888. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58889. protected _buildBlock(state: NodeMaterialBuildState): this;
  58890. }
  58891. }
  58892. declare module BABYLON {
  58893. /**
  58894. * Block used to get data information from a light
  58895. */
  58896. export class LightInformationBlock extends NodeMaterialBlock {
  58897. private _lightDataUniformName;
  58898. private _lightColorUniformName;
  58899. private _lightTypeDefineName;
  58900. /**
  58901. * Gets or sets the light associated with this block
  58902. */
  58903. light: Nullable<Light>;
  58904. /**
  58905. * Creates a new LightInformationBlock
  58906. * @param name defines the block name
  58907. */
  58908. constructor(name: string);
  58909. /**
  58910. * Gets the current class name
  58911. * @returns the class name
  58912. */
  58913. getClassName(): string;
  58914. /**
  58915. * Gets the world position input component
  58916. */
  58917. get worldPosition(): NodeMaterialConnectionPoint;
  58918. /**
  58919. * Gets the direction output component
  58920. */
  58921. get direction(): NodeMaterialConnectionPoint;
  58922. /**
  58923. * Gets the direction output component
  58924. */
  58925. get color(): NodeMaterialConnectionPoint;
  58926. /**
  58927. * Gets the direction output component
  58928. */
  58929. get intensity(): NodeMaterialConnectionPoint;
  58930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58932. protected _buildBlock(state: NodeMaterialBuildState): this;
  58933. serialize(): any;
  58934. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58935. }
  58936. }
  58937. declare module BABYLON {
  58938. /**
  58939. * Block used to add image processing support to fragment shader
  58940. */
  58941. export class ImageProcessingBlock extends NodeMaterialBlock {
  58942. /**
  58943. * Create a new ImageProcessingBlock
  58944. * @param name defines the block name
  58945. */
  58946. constructor(name: string);
  58947. /**
  58948. * Gets the current class name
  58949. * @returns the class name
  58950. */
  58951. getClassName(): string;
  58952. /**
  58953. * Gets the color input component
  58954. */
  58955. get color(): NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the output component
  58958. */
  58959. get output(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Initialize the block and prepare the context for build
  58962. * @param state defines the state that will be used for the build
  58963. */
  58964. initialize(state: NodeMaterialBuildState): void;
  58965. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58967. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58968. protected _buildBlock(state: NodeMaterialBuildState): this;
  58969. }
  58970. }
  58971. declare module BABYLON {
  58972. /**
  58973. * Block used to pertub normals based on a normal map
  58974. */
  58975. export class PerturbNormalBlock extends NodeMaterialBlock {
  58976. private _tangentSpaceParameterName;
  58977. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58978. invertX: boolean;
  58979. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58980. invertY: boolean;
  58981. /**
  58982. * Create a new PerturbNormalBlock
  58983. * @param name defines the block name
  58984. */
  58985. constructor(name: string);
  58986. /**
  58987. * Gets the current class name
  58988. * @returns the class name
  58989. */
  58990. getClassName(): string;
  58991. /**
  58992. * Gets the world position input component
  58993. */
  58994. get worldPosition(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the world normal input component
  58997. */
  58998. get worldNormal(): NodeMaterialConnectionPoint;
  58999. /**
  59000. * Gets the world tangent input component
  59001. */
  59002. get worldTangent(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the uv input component
  59005. */
  59006. get uv(): NodeMaterialConnectionPoint;
  59007. /**
  59008. * Gets the normal map color input component
  59009. */
  59010. get normalMapColor(): NodeMaterialConnectionPoint;
  59011. /**
  59012. * Gets the strength input component
  59013. */
  59014. get strength(): NodeMaterialConnectionPoint;
  59015. /**
  59016. * Gets the output component
  59017. */
  59018. get output(): NodeMaterialConnectionPoint;
  59019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59021. autoConfigure(material: NodeMaterial): void;
  59022. protected _buildBlock(state: NodeMaterialBuildState): this;
  59023. protected _dumpPropertiesCode(): string;
  59024. serialize(): any;
  59025. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59026. }
  59027. }
  59028. declare module BABYLON {
  59029. /**
  59030. * Block used to discard a pixel if a value is smaller than a cutoff
  59031. */
  59032. export class DiscardBlock extends NodeMaterialBlock {
  59033. /**
  59034. * Create a new DiscardBlock
  59035. * @param name defines the block name
  59036. */
  59037. constructor(name: string);
  59038. /**
  59039. * Gets the current class name
  59040. * @returns the class name
  59041. */
  59042. getClassName(): string;
  59043. /**
  59044. * Gets the color input component
  59045. */
  59046. get value(): NodeMaterialConnectionPoint;
  59047. /**
  59048. * Gets the cutoff input component
  59049. */
  59050. get cutoff(): NodeMaterialConnectionPoint;
  59051. protected _buildBlock(state: NodeMaterialBuildState): this;
  59052. }
  59053. }
  59054. declare module BABYLON {
  59055. /**
  59056. * Block used to test if the fragment shader is front facing
  59057. */
  59058. export class FrontFacingBlock extends NodeMaterialBlock {
  59059. /**
  59060. * Creates a new FrontFacingBlock
  59061. * @param name defines the block name
  59062. */
  59063. constructor(name: string);
  59064. /**
  59065. * Gets the current class name
  59066. * @returns the class name
  59067. */
  59068. getClassName(): string;
  59069. /**
  59070. * Gets the output component
  59071. */
  59072. get output(): NodeMaterialConnectionPoint;
  59073. protected _buildBlock(state: NodeMaterialBuildState): this;
  59074. }
  59075. }
  59076. declare module BABYLON {
  59077. /**
  59078. * Block used to get the derivative value on x and y of a given input
  59079. */
  59080. export class DerivativeBlock extends NodeMaterialBlock {
  59081. /**
  59082. * Create a new DerivativeBlock
  59083. * @param name defines the block name
  59084. */
  59085. constructor(name: string);
  59086. /**
  59087. * Gets the current class name
  59088. * @returns the class name
  59089. */
  59090. getClassName(): string;
  59091. /**
  59092. * Gets the input component
  59093. */
  59094. get input(): NodeMaterialConnectionPoint;
  59095. /**
  59096. * Gets the derivative output on x
  59097. */
  59098. get dx(): NodeMaterialConnectionPoint;
  59099. /**
  59100. * Gets the derivative output on y
  59101. */
  59102. get dy(): NodeMaterialConnectionPoint;
  59103. protected _buildBlock(state: NodeMaterialBuildState): this;
  59104. }
  59105. }
  59106. declare module BABYLON {
  59107. /**
  59108. * Block used to add support for scene fog
  59109. */
  59110. export class FogBlock extends NodeMaterialBlock {
  59111. private _fogDistanceName;
  59112. private _fogParameters;
  59113. /**
  59114. * Create a new FogBlock
  59115. * @param name defines the block name
  59116. */
  59117. constructor(name: string);
  59118. /**
  59119. * Gets the current class name
  59120. * @returns the class name
  59121. */
  59122. getClassName(): string;
  59123. /**
  59124. * Gets the world position input component
  59125. */
  59126. get worldPosition(): NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the view input component
  59129. */
  59130. get view(): NodeMaterialConnectionPoint;
  59131. /**
  59132. * Gets the color input component
  59133. */
  59134. get input(): NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the fog color input component
  59137. */
  59138. get fogColor(): NodeMaterialConnectionPoint;
  59139. /**
  59140. * Gets the output component
  59141. */
  59142. get output(): NodeMaterialConnectionPoint;
  59143. autoConfigure(material: NodeMaterial): void;
  59144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59146. protected _buildBlock(state: NodeMaterialBuildState): this;
  59147. }
  59148. }
  59149. declare module BABYLON {
  59150. /**
  59151. * Block used to add light in the fragment shader
  59152. */
  59153. export class LightBlock extends NodeMaterialBlock {
  59154. private _lightId;
  59155. /**
  59156. * Gets or sets the light associated with this block
  59157. */
  59158. light: Nullable<Light>;
  59159. /**
  59160. * Create a new LightBlock
  59161. * @param name defines the block name
  59162. */
  59163. constructor(name: string);
  59164. /**
  59165. * Gets the current class name
  59166. * @returns the class name
  59167. */
  59168. getClassName(): string;
  59169. /**
  59170. * Gets the world position input component
  59171. */
  59172. get worldPosition(): NodeMaterialConnectionPoint;
  59173. /**
  59174. * Gets the world normal input component
  59175. */
  59176. get worldNormal(): NodeMaterialConnectionPoint;
  59177. /**
  59178. * Gets the camera (or eye) position component
  59179. */
  59180. get cameraPosition(): NodeMaterialConnectionPoint;
  59181. /**
  59182. * Gets the glossiness component
  59183. */
  59184. get glossiness(): NodeMaterialConnectionPoint;
  59185. /**
  59186. * Gets the glossinness power component
  59187. */
  59188. get glossPower(): NodeMaterialConnectionPoint;
  59189. /**
  59190. * Gets the diffuse color component
  59191. */
  59192. get diffuseColor(): NodeMaterialConnectionPoint;
  59193. /**
  59194. * Gets the specular color component
  59195. */
  59196. get specularColor(): NodeMaterialConnectionPoint;
  59197. /**
  59198. * Gets the diffuse output component
  59199. */
  59200. get diffuseOutput(): NodeMaterialConnectionPoint;
  59201. /**
  59202. * Gets the specular output component
  59203. */
  59204. get specularOutput(): NodeMaterialConnectionPoint;
  59205. /**
  59206. * Gets the shadow output component
  59207. */
  59208. get shadow(): NodeMaterialConnectionPoint;
  59209. autoConfigure(material: NodeMaterial): void;
  59210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59211. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59212. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59213. private _injectVertexCode;
  59214. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59215. serialize(): any;
  59216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59217. }
  59218. }
  59219. declare module BABYLON {
  59220. /**
  59221. * Block used to multiply 2 values
  59222. */
  59223. export class MultiplyBlock extends NodeMaterialBlock {
  59224. /**
  59225. * Creates a new MultiplyBlock
  59226. * @param name defines the block name
  59227. */
  59228. constructor(name: string);
  59229. /**
  59230. * Gets the current class name
  59231. * @returns the class name
  59232. */
  59233. getClassName(): string;
  59234. /**
  59235. * Gets the left operand input component
  59236. */
  59237. get left(): NodeMaterialConnectionPoint;
  59238. /**
  59239. * Gets the right operand input component
  59240. */
  59241. get right(): NodeMaterialConnectionPoint;
  59242. /**
  59243. * Gets the output component
  59244. */
  59245. get output(): NodeMaterialConnectionPoint;
  59246. protected _buildBlock(state: NodeMaterialBuildState): this;
  59247. }
  59248. }
  59249. declare module BABYLON {
  59250. /**
  59251. * Block used to add 2 vectors
  59252. */
  59253. export class AddBlock extends NodeMaterialBlock {
  59254. /**
  59255. * Creates a new AddBlock
  59256. * @param name defines the block name
  59257. */
  59258. constructor(name: string);
  59259. /**
  59260. * Gets the current class name
  59261. * @returns the class name
  59262. */
  59263. getClassName(): string;
  59264. /**
  59265. * Gets the left operand input component
  59266. */
  59267. get left(): NodeMaterialConnectionPoint;
  59268. /**
  59269. * Gets the right operand input component
  59270. */
  59271. get right(): NodeMaterialConnectionPoint;
  59272. /**
  59273. * Gets the output component
  59274. */
  59275. get output(): NodeMaterialConnectionPoint;
  59276. protected _buildBlock(state: NodeMaterialBuildState): this;
  59277. }
  59278. }
  59279. declare module BABYLON {
  59280. /**
  59281. * Block used to scale a vector by a float
  59282. */
  59283. export class ScaleBlock extends NodeMaterialBlock {
  59284. /**
  59285. * Creates a new ScaleBlock
  59286. * @param name defines the block name
  59287. */
  59288. constructor(name: string);
  59289. /**
  59290. * Gets the current class name
  59291. * @returns the class name
  59292. */
  59293. getClassName(): string;
  59294. /**
  59295. * Gets the input component
  59296. */
  59297. get input(): NodeMaterialConnectionPoint;
  59298. /**
  59299. * Gets the factor input component
  59300. */
  59301. get factor(): NodeMaterialConnectionPoint;
  59302. /**
  59303. * Gets the output component
  59304. */
  59305. get output(): NodeMaterialConnectionPoint;
  59306. protected _buildBlock(state: NodeMaterialBuildState): this;
  59307. }
  59308. }
  59309. declare module BABYLON {
  59310. /**
  59311. * Block used to clamp a float
  59312. */
  59313. export class ClampBlock extends NodeMaterialBlock {
  59314. /** Gets or sets the minimum range */
  59315. minimum: number;
  59316. /** Gets or sets the maximum range */
  59317. maximum: number;
  59318. /**
  59319. * Creates a new ClampBlock
  59320. * @param name defines the block name
  59321. */
  59322. constructor(name: string);
  59323. /**
  59324. * Gets the current class name
  59325. * @returns the class name
  59326. */
  59327. getClassName(): string;
  59328. /**
  59329. * Gets the value input component
  59330. */
  59331. get value(): NodeMaterialConnectionPoint;
  59332. /**
  59333. * Gets the output component
  59334. */
  59335. get output(): NodeMaterialConnectionPoint;
  59336. protected _buildBlock(state: NodeMaterialBuildState): this;
  59337. protected _dumpPropertiesCode(): string;
  59338. serialize(): any;
  59339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59340. }
  59341. }
  59342. declare module BABYLON {
  59343. /**
  59344. * Block used to apply a cross product between 2 vectors
  59345. */
  59346. export class CrossBlock extends NodeMaterialBlock {
  59347. /**
  59348. * Creates a new CrossBlock
  59349. * @param name defines the block name
  59350. */
  59351. constructor(name: string);
  59352. /**
  59353. * Gets the current class name
  59354. * @returns the class name
  59355. */
  59356. getClassName(): string;
  59357. /**
  59358. * Gets the left operand input component
  59359. */
  59360. get left(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the right operand input component
  59363. */
  59364. get right(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the output component
  59367. */
  59368. get output(): NodeMaterialConnectionPoint;
  59369. protected _buildBlock(state: NodeMaterialBuildState): this;
  59370. }
  59371. }
  59372. declare module BABYLON {
  59373. /**
  59374. * Block used to apply a dot product between 2 vectors
  59375. */
  59376. export class DotBlock extends NodeMaterialBlock {
  59377. /**
  59378. * Creates a new DotBlock
  59379. * @param name defines the block name
  59380. */
  59381. constructor(name: string);
  59382. /**
  59383. * Gets the current class name
  59384. * @returns the class name
  59385. */
  59386. getClassName(): string;
  59387. /**
  59388. * Gets the left operand input component
  59389. */
  59390. get left(): NodeMaterialConnectionPoint;
  59391. /**
  59392. * Gets the right operand input component
  59393. */
  59394. get right(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the output component
  59397. */
  59398. get output(): NodeMaterialConnectionPoint;
  59399. protected _buildBlock(state: NodeMaterialBuildState): this;
  59400. }
  59401. }
  59402. declare module BABYLON {
  59403. /**
  59404. * Block used to remap a float from a range to a new one
  59405. */
  59406. export class RemapBlock extends NodeMaterialBlock {
  59407. /**
  59408. * Gets or sets the source range
  59409. */
  59410. sourceRange: Vector2;
  59411. /**
  59412. * Gets or sets the target range
  59413. */
  59414. targetRange: Vector2;
  59415. /**
  59416. * Creates a new RemapBlock
  59417. * @param name defines the block name
  59418. */
  59419. constructor(name: string);
  59420. /**
  59421. * Gets the current class name
  59422. * @returns the class name
  59423. */
  59424. getClassName(): string;
  59425. /**
  59426. * Gets the input component
  59427. */
  59428. get input(): NodeMaterialConnectionPoint;
  59429. /**
  59430. * Gets the source min input component
  59431. */
  59432. get sourceMin(): NodeMaterialConnectionPoint;
  59433. /**
  59434. * Gets the source max input component
  59435. */
  59436. get sourceMax(): NodeMaterialConnectionPoint;
  59437. /**
  59438. * Gets the target min input component
  59439. */
  59440. get targetMin(): NodeMaterialConnectionPoint;
  59441. /**
  59442. * Gets the target max input component
  59443. */
  59444. get targetMax(): NodeMaterialConnectionPoint;
  59445. /**
  59446. * Gets the output component
  59447. */
  59448. get output(): NodeMaterialConnectionPoint;
  59449. protected _buildBlock(state: NodeMaterialBuildState): this;
  59450. protected _dumpPropertiesCode(): string;
  59451. serialize(): any;
  59452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59453. }
  59454. }
  59455. declare module BABYLON {
  59456. /**
  59457. * Block used to normalize a vector
  59458. */
  59459. export class NormalizeBlock extends NodeMaterialBlock {
  59460. /**
  59461. * Creates a new NormalizeBlock
  59462. * @param name defines the block name
  59463. */
  59464. constructor(name: string);
  59465. /**
  59466. * Gets the current class name
  59467. * @returns the class name
  59468. */
  59469. getClassName(): string;
  59470. /**
  59471. * Gets the input component
  59472. */
  59473. get input(): NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the output component
  59476. */
  59477. get output(): NodeMaterialConnectionPoint;
  59478. protected _buildBlock(state: NodeMaterialBuildState): this;
  59479. }
  59480. }
  59481. declare module BABYLON {
  59482. /**
  59483. * Operations supported by the Trigonometry block
  59484. */
  59485. export enum TrigonometryBlockOperations {
  59486. /** Cos */
  59487. Cos = 0,
  59488. /** Sin */
  59489. Sin = 1,
  59490. /** Abs */
  59491. Abs = 2,
  59492. /** Exp */
  59493. Exp = 3,
  59494. /** Exp2 */
  59495. Exp2 = 4,
  59496. /** Round */
  59497. Round = 5,
  59498. /** Floor */
  59499. Floor = 6,
  59500. /** Ceiling */
  59501. Ceiling = 7,
  59502. /** Square root */
  59503. Sqrt = 8,
  59504. /** Log */
  59505. Log = 9,
  59506. /** Tangent */
  59507. Tan = 10,
  59508. /** Arc tangent */
  59509. ArcTan = 11,
  59510. /** Arc cosinus */
  59511. ArcCos = 12,
  59512. /** Arc sinus */
  59513. ArcSin = 13,
  59514. /** Fraction */
  59515. Fract = 14,
  59516. /** Sign */
  59517. Sign = 15,
  59518. /** To radians (from degrees) */
  59519. Radians = 16,
  59520. /** To degrees (from radians) */
  59521. Degrees = 17
  59522. }
  59523. /**
  59524. * Block used to apply trigonometry operation to floats
  59525. */
  59526. export class TrigonometryBlock extends NodeMaterialBlock {
  59527. /**
  59528. * Gets or sets the operation applied by the block
  59529. */
  59530. operation: TrigonometryBlockOperations;
  59531. /**
  59532. * Creates a new TrigonometryBlock
  59533. * @param name defines the block name
  59534. */
  59535. constructor(name: string);
  59536. /**
  59537. * Gets the current class name
  59538. * @returns the class name
  59539. */
  59540. getClassName(): string;
  59541. /**
  59542. * Gets the input component
  59543. */
  59544. get input(): NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the output component
  59547. */
  59548. get output(): NodeMaterialConnectionPoint;
  59549. protected _buildBlock(state: NodeMaterialBuildState): this;
  59550. serialize(): any;
  59551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59552. protected _dumpPropertiesCode(): string;
  59553. }
  59554. }
  59555. declare module BABYLON {
  59556. /**
  59557. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59558. */
  59559. export class ColorMergerBlock extends NodeMaterialBlock {
  59560. /**
  59561. * Create a new ColorMergerBlock
  59562. * @param name defines the block name
  59563. */
  59564. constructor(name: string);
  59565. /**
  59566. * Gets the current class name
  59567. * @returns the class name
  59568. */
  59569. getClassName(): string;
  59570. /**
  59571. * Gets the rgb component (input)
  59572. */
  59573. get rgbIn(): NodeMaterialConnectionPoint;
  59574. /**
  59575. * Gets the r component (input)
  59576. */
  59577. get r(): NodeMaterialConnectionPoint;
  59578. /**
  59579. * Gets the g component (input)
  59580. */
  59581. get g(): NodeMaterialConnectionPoint;
  59582. /**
  59583. * Gets the b component (input)
  59584. */
  59585. get b(): NodeMaterialConnectionPoint;
  59586. /**
  59587. * Gets the a component (input)
  59588. */
  59589. get a(): NodeMaterialConnectionPoint;
  59590. /**
  59591. * Gets the rgba component (output)
  59592. */
  59593. get rgba(): NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the rgb component (output)
  59596. */
  59597. get rgbOut(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the rgb component (output)
  59600. * @deprecated Please use rgbOut instead.
  59601. */
  59602. get rgb(): NodeMaterialConnectionPoint;
  59603. protected _buildBlock(state: NodeMaterialBuildState): this;
  59604. }
  59605. }
  59606. declare module BABYLON {
  59607. /**
  59608. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59609. */
  59610. export class VectorMergerBlock extends NodeMaterialBlock {
  59611. /**
  59612. * Create a new VectorMergerBlock
  59613. * @param name defines the block name
  59614. */
  59615. constructor(name: string);
  59616. /**
  59617. * Gets the current class name
  59618. * @returns the class name
  59619. */
  59620. getClassName(): string;
  59621. /**
  59622. * Gets the xyz component (input)
  59623. */
  59624. get xyzIn(): NodeMaterialConnectionPoint;
  59625. /**
  59626. * Gets the xy component (input)
  59627. */
  59628. get xyIn(): NodeMaterialConnectionPoint;
  59629. /**
  59630. * Gets the x component (input)
  59631. */
  59632. get x(): NodeMaterialConnectionPoint;
  59633. /**
  59634. * Gets the y component (input)
  59635. */
  59636. get y(): NodeMaterialConnectionPoint;
  59637. /**
  59638. * Gets the z component (input)
  59639. */
  59640. get z(): NodeMaterialConnectionPoint;
  59641. /**
  59642. * Gets the w component (input)
  59643. */
  59644. get w(): NodeMaterialConnectionPoint;
  59645. /**
  59646. * Gets the xyzw component (output)
  59647. */
  59648. get xyzw(): NodeMaterialConnectionPoint;
  59649. /**
  59650. * Gets the xyz component (output)
  59651. */
  59652. get xyzOut(): NodeMaterialConnectionPoint;
  59653. /**
  59654. * Gets the xy component (output)
  59655. */
  59656. get xyOut(): NodeMaterialConnectionPoint;
  59657. /**
  59658. * Gets the xy component (output)
  59659. * @deprecated Please use xyOut instead.
  59660. */
  59661. get xy(): NodeMaterialConnectionPoint;
  59662. /**
  59663. * Gets the xyz component (output)
  59664. * @deprecated Please use xyzOut instead.
  59665. */
  59666. get xyz(): NodeMaterialConnectionPoint;
  59667. protected _buildBlock(state: NodeMaterialBuildState): this;
  59668. }
  59669. }
  59670. declare module BABYLON {
  59671. /**
  59672. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59673. */
  59674. export class ColorSplitterBlock extends NodeMaterialBlock {
  59675. /**
  59676. * Create a new ColorSplitterBlock
  59677. * @param name defines the block name
  59678. */
  59679. constructor(name: string);
  59680. /**
  59681. * Gets the current class name
  59682. * @returns the class name
  59683. */
  59684. getClassName(): string;
  59685. /**
  59686. * Gets the rgba component (input)
  59687. */
  59688. get rgba(): NodeMaterialConnectionPoint;
  59689. /**
  59690. * Gets the rgb component (input)
  59691. */
  59692. get rgbIn(): NodeMaterialConnectionPoint;
  59693. /**
  59694. * Gets the rgb component (output)
  59695. */
  59696. get rgbOut(): NodeMaterialConnectionPoint;
  59697. /**
  59698. * Gets the r component (output)
  59699. */
  59700. get r(): NodeMaterialConnectionPoint;
  59701. /**
  59702. * Gets the g component (output)
  59703. */
  59704. get g(): NodeMaterialConnectionPoint;
  59705. /**
  59706. * Gets the b component (output)
  59707. */
  59708. get b(): NodeMaterialConnectionPoint;
  59709. /**
  59710. * Gets the a component (output)
  59711. */
  59712. get a(): NodeMaterialConnectionPoint;
  59713. protected _inputRename(name: string): string;
  59714. protected _outputRename(name: string): string;
  59715. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59716. }
  59717. }
  59718. declare module BABYLON {
  59719. /**
  59720. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59721. */
  59722. export class VectorSplitterBlock extends NodeMaterialBlock {
  59723. /**
  59724. * Create a new VectorSplitterBlock
  59725. * @param name defines the block name
  59726. */
  59727. constructor(name: string);
  59728. /**
  59729. * Gets the current class name
  59730. * @returns the class name
  59731. */
  59732. getClassName(): string;
  59733. /**
  59734. * Gets the xyzw component (input)
  59735. */
  59736. get xyzw(): NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the xyz component (input)
  59739. */
  59740. get xyzIn(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the xy component (input)
  59743. */
  59744. get xyIn(): NodeMaterialConnectionPoint;
  59745. /**
  59746. * Gets the xyz component (output)
  59747. */
  59748. get xyzOut(): NodeMaterialConnectionPoint;
  59749. /**
  59750. * Gets the xy component (output)
  59751. */
  59752. get xyOut(): NodeMaterialConnectionPoint;
  59753. /**
  59754. * Gets the x component (output)
  59755. */
  59756. get x(): NodeMaterialConnectionPoint;
  59757. /**
  59758. * Gets the y component (output)
  59759. */
  59760. get y(): NodeMaterialConnectionPoint;
  59761. /**
  59762. * Gets the z component (output)
  59763. */
  59764. get z(): NodeMaterialConnectionPoint;
  59765. /**
  59766. * Gets the w component (output)
  59767. */
  59768. get w(): NodeMaterialConnectionPoint;
  59769. protected _inputRename(name: string): string;
  59770. protected _outputRename(name: string): string;
  59771. protected _buildBlock(state: NodeMaterialBuildState): this;
  59772. }
  59773. }
  59774. declare module BABYLON {
  59775. /**
  59776. * Block used to lerp between 2 values
  59777. */
  59778. export class LerpBlock extends NodeMaterialBlock {
  59779. /**
  59780. * Creates a new LerpBlock
  59781. * @param name defines the block name
  59782. */
  59783. constructor(name: string);
  59784. /**
  59785. * Gets the current class name
  59786. * @returns the class name
  59787. */
  59788. getClassName(): string;
  59789. /**
  59790. * Gets the left operand input component
  59791. */
  59792. get left(): NodeMaterialConnectionPoint;
  59793. /**
  59794. * Gets the right operand input component
  59795. */
  59796. get right(): NodeMaterialConnectionPoint;
  59797. /**
  59798. * Gets the gradient operand input component
  59799. */
  59800. get gradient(): NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the output component
  59803. */
  59804. get output(): NodeMaterialConnectionPoint;
  59805. protected _buildBlock(state: NodeMaterialBuildState): this;
  59806. }
  59807. }
  59808. declare module BABYLON {
  59809. /**
  59810. * Block used to divide 2 vectors
  59811. */
  59812. export class DivideBlock extends NodeMaterialBlock {
  59813. /**
  59814. * Creates a new DivideBlock
  59815. * @param name defines the block name
  59816. */
  59817. constructor(name: string);
  59818. /**
  59819. * Gets the current class name
  59820. * @returns the class name
  59821. */
  59822. getClassName(): string;
  59823. /**
  59824. * Gets the left operand input component
  59825. */
  59826. get left(): NodeMaterialConnectionPoint;
  59827. /**
  59828. * Gets the right operand input component
  59829. */
  59830. get right(): NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the output component
  59833. */
  59834. get output(): NodeMaterialConnectionPoint;
  59835. protected _buildBlock(state: NodeMaterialBuildState): this;
  59836. }
  59837. }
  59838. declare module BABYLON {
  59839. /**
  59840. * Block used to subtract 2 vectors
  59841. */
  59842. export class SubtractBlock extends NodeMaterialBlock {
  59843. /**
  59844. * Creates a new SubtractBlock
  59845. * @param name defines the block name
  59846. */
  59847. constructor(name: string);
  59848. /**
  59849. * Gets the current class name
  59850. * @returns the class name
  59851. */
  59852. getClassName(): string;
  59853. /**
  59854. * Gets the left operand input component
  59855. */
  59856. get left(): NodeMaterialConnectionPoint;
  59857. /**
  59858. * Gets the right operand input component
  59859. */
  59860. get right(): NodeMaterialConnectionPoint;
  59861. /**
  59862. * Gets the output component
  59863. */
  59864. get output(): NodeMaterialConnectionPoint;
  59865. protected _buildBlock(state: NodeMaterialBuildState): this;
  59866. }
  59867. }
  59868. declare module BABYLON {
  59869. /**
  59870. * Block used to step a value
  59871. */
  59872. export class StepBlock extends NodeMaterialBlock {
  59873. /**
  59874. * Creates a new StepBlock
  59875. * @param name defines the block name
  59876. */
  59877. constructor(name: string);
  59878. /**
  59879. * Gets the current class name
  59880. * @returns the class name
  59881. */
  59882. getClassName(): string;
  59883. /**
  59884. * Gets the value operand input component
  59885. */
  59886. get value(): NodeMaterialConnectionPoint;
  59887. /**
  59888. * Gets the edge operand input component
  59889. */
  59890. get edge(): NodeMaterialConnectionPoint;
  59891. /**
  59892. * Gets the output component
  59893. */
  59894. get output(): NodeMaterialConnectionPoint;
  59895. protected _buildBlock(state: NodeMaterialBuildState): this;
  59896. }
  59897. }
  59898. declare module BABYLON {
  59899. /**
  59900. * Block used to get the opposite (1 - x) of a value
  59901. */
  59902. export class OneMinusBlock extends NodeMaterialBlock {
  59903. /**
  59904. * Creates a new OneMinusBlock
  59905. * @param name defines the block name
  59906. */
  59907. constructor(name: string);
  59908. /**
  59909. * Gets the current class name
  59910. * @returns the class name
  59911. */
  59912. getClassName(): string;
  59913. /**
  59914. * Gets the input component
  59915. */
  59916. get input(): NodeMaterialConnectionPoint;
  59917. /**
  59918. * Gets the output component
  59919. */
  59920. get output(): NodeMaterialConnectionPoint;
  59921. protected _buildBlock(state: NodeMaterialBuildState): this;
  59922. }
  59923. }
  59924. declare module BABYLON {
  59925. /**
  59926. * Block used to get the view direction
  59927. */
  59928. export class ViewDirectionBlock extends NodeMaterialBlock {
  59929. /**
  59930. * Creates a new ViewDirectionBlock
  59931. * @param name defines the block name
  59932. */
  59933. constructor(name: string);
  59934. /**
  59935. * Gets the current class name
  59936. * @returns the class name
  59937. */
  59938. getClassName(): string;
  59939. /**
  59940. * Gets the world position component
  59941. */
  59942. get worldPosition(): NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the camera position component
  59945. */
  59946. get cameraPosition(): NodeMaterialConnectionPoint;
  59947. /**
  59948. * Gets the output component
  59949. */
  59950. get output(): NodeMaterialConnectionPoint;
  59951. autoConfigure(material: NodeMaterial): void;
  59952. protected _buildBlock(state: NodeMaterialBuildState): this;
  59953. }
  59954. }
  59955. declare module BABYLON {
  59956. /**
  59957. * Block used to compute fresnel value
  59958. */
  59959. export class FresnelBlock extends NodeMaterialBlock {
  59960. /**
  59961. * Create a new FresnelBlock
  59962. * @param name defines the block name
  59963. */
  59964. constructor(name: string);
  59965. /**
  59966. * Gets the current class name
  59967. * @returns the class name
  59968. */
  59969. getClassName(): string;
  59970. /**
  59971. * Gets the world normal input component
  59972. */
  59973. get worldNormal(): NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the view direction input component
  59976. */
  59977. get viewDirection(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the bias input component
  59980. */
  59981. get bias(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the camera (or eye) position component
  59984. */
  59985. get power(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the fresnel output component
  59988. */
  59989. get fresnel(): NodeMaterialConnectionPoint;
  59990. autoConfigure(material: NodeMaterial): void;
  59991. protected _buildBlock(state: NodeMaterialBuildState): this;
  59992. }
  59993. }
  59994. declare module BABYLON {
  59995. /**
  59996. * Block used to get the max of 2 values
  59997. */
  59998. export class MaxBlock extends NodeMaterialBlock {
  59999. /**
  60000. * Creates a new MaxBlock
  60001. * @param name defines the block name
  60002. */
  60003. constructor(name: string);
  60004. /**
  60005. * Gets the current class name
  60006. * @returns the class name
  60007. */
  60008. getClassName(): string;
  60009. /**
  60010. * Gets the left operand input component
  60011. */
  60012. get left(): NodeMaterialConnectionPoint;
  60013. /**
  60014. * Gets the right operand input component
  60015. */
  60016. get right(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the output component
  60019. */
  60020. get output(): NodeMaterialConnectionPoint;
  60021. protected _buildBlock(state: NodeMaterialBuildState): this;
  60022. }
  60023. }
  60024. declare module BABYLON {
  60025. /**
  60026. * Block used to get the min of 2 values
  60027. */
  60028. export class MinBlock extends NodeMaterialBlock {
  60029. /**
  60030. * Creates a new MinBlock
  60031. * @param name defines the block name
  60032. */
  60033. constructor(name: string);
  60034. /**
  60035. * Gets the current class name
  60036. * @returns the class name
  60037. */
  60038. getClassName(): string;
  60039. /**
  60040. * Gets the left operand input component
  60041. */
  60042. get left(): NodeMaterialConnectionPoint;
  60043. /**
  60044. * Gets the right operand input component
  60045. */
  60046. get right(): NodeMaterialConnectionPoint;
  60047. /**
  60048. * Gets the output component
  60049. */
  60050. get output(): NodeMaterialConnectionPoint;
  60051. protected _buildBlock(state: NodeMaterialBuildState): this;
  60052. }
  60053. }
  60054. declare module BABYLON {
  60055. /**
  60056. * Block used to get the distance between 2 values
  60057. */
  60058. export class DistanceBlock extends NodeMaterialBlock {
  60059. /**
  60060. * Creates a new DistanceBlock
  60061. * @param name defines the block name
  60062. */
  60063. constructor(name: string);
  60064. /**
  60065. * Gets the current class name
  60066. * @returns the class name
  60067. */
  60068. getClassName(): string;
  60069. /**
  60070. * Gets the left operand input component
  60071. */
  60072. get left(): NodeMaterialConnectionPoint;
  60073. /**
  60074. * Gets the right operand input component
  60075. */
  60076. get right(): NodeMaterialConnectionPoint;
  60077. /**
  60078. * Gets the output component
  60079. */
  60080. get output(): NodeMaterialConnectionPoint;
  60081. protected _buildBlock(state: NodeMaterialBuildState): this;
  60082. }
  60083. }
  60084. declare module BABYLON {
  60085. /**
  60086. * Block used to get the length of a vector
  60087. */
  60088. export class LengthBlock extends NodeMaterialBlock {
  60089. /**
  60090. * Creates a new LengthBlock
  60091. * @param name defines the block name
  60092. */
  60093. constructor(name: string);
  60094. /**
  60095. * Gets the current class name
  60096. * @returns the class name
  60097. */
  60098. getClassName(): string;
  60099. /**
  60100. * Gets the value input component
  60101. */
  60102. get value(): NodeMaterialConnectionPoint;
  60103. /**
  60104. * Gets the output component
  60105. */
  60106. get output(): NodeMaterialConnectionPoint;
  60107. protected _buildBlock(state: NodeMaterialBuildState): this;
  60108. }
  60109. }
  60110. declare module BABYLON {
  60111. /**
  60112. * Block used to get negative version of a value (i.e. x * -1)
  60113. */
  60114. export class NegateBlock extends NodeMaterialBlock {
  60115. /**
  60116. * Creates a new NegateBlock
  60117. * @param name defines the block name
  60118. */
  60119. constructor(name: string);
  60120. /**
  60121. * Gets the current class name
  60122. * @returns the class name
  60123. */
  60124. getClassName(): string;
  60125. /**
  60126. * Gets the value input component
  60127. */
  60128. get value(): NodeMaterialConnectionPoint;
  60129. /**
  60130. * Gets the output component
  60131. */
  60132. get output(): NodeMaterialConnectionPoint;
  60133. protected _buildBlock(state: NodeMaterialBuildState): this;
  60134. }
  60135. }
  60136. declare module BABYLON {
  60137. /**
  60138. * Block used to get the value of the first parameter raised to the power of the second
  60139. */
  60140. export class PowBlock extends NodeMaterialBlock {
  60141. /**
  60142. * Creates a new PowBlock
  60143. * @param name defines the block name
  60144. */
  60145. constructor(name: string);
  60146. /**
  60147. * Gets the current class name
  60148. * @returns the class name
  60149. */
  60150. getClassName(): string;
  60151. /**
  60152. * Gets the value operand input component
  60153. */
  60154. get value(): NodeMaterialConnectionPoint;
  60155. /**
  60156. * Gets the power operand input component
  60157. */
  60158. get power(): NodeMaterialConnectionPoint;
  60159. /**
  60160. * Gets the output component
  60161. */
  60162. get output(): NodeMaterialConnectionPoint;
  60163. protected _buildBlock(state: NodeMaterialBuildState): this;
  60164. }
  60165. }
  60166. declare module BABYLON {
  60167. /**
  60168. * Block used to get a random number
  60169. */
  60170. export class RandomNumberBlock extends NodeMaterialBlock {
  60171. /**
  60172. * Creates a new RandomNumberBlock
  60173. * @param name defines the block name
  60174. */
  60175. constructor(name: string);
  60176. /**
  60177. * Gets the current class name
  60178. * @returns the class name
  60179. */
  60180. getClassName(): string;
  60181. /**
  60182. * Gets the seed input component
  60183. */
  60184. get seed(): NodeMaterialConnectionPoint;
  60185. /**
  60186. * Gets the output component
  60187. */
  60188. get output(): NodeMaterialConnectionPoint;
  60189. protected _buildBlock(state: NodeMaterialBuildState): this;
  60190. }
  60191. }
  60192. declare module BABYLON {
  60193. /**
  60194. * Block used to compute arc tangent of 2 values
  60195. */
  60196. export class ArcTan2Block extends NodeMaterialBlock {
  60197. /**
  60198. * Creates a new ArcTan2Block
  60199. * @param name defines the block name
  60200. */
  60201. constructor(name: string);
  60202. /**
  60203. * Gets the current class name
  60204. * @returns the class name
  60205. */
  60206. getClassName(): string;
  60207. /**
  60208. * Gets the x operand input component
  60209. */
  60210. get x(): NodeMaterialConnectionPoint;
  60211. /**
  60212. * Gets the y operand input component
  60213. */
  60214. get y(): NodeMaterialConnectionPoint;
  60215. /**
  60216. * Gets the output component
  60217. */
  60218. get output(): NodeMaterialConnectionPoint;
  60219. protected _buildBlock(state: NodeMaterialBuildState): this;
  60220. }
  60221. }
  60222. declare module BABYLON {
  60223. /**
  60224. * Block used to smooth step a value
  60225. */
  60226. export class SmoothStepBlock extends NodeMaterialBlock {
  60227. /**
  60228. * Creates a new SmoothStepBlock
  60229. * @param name defines the block name
  60230. */
  60231. constructor(name: string);
  60232. /**
  60233. * Gets the current class name
  60234. * @returns the class name
  60235. */
  60236. getClassName(): string;
  60237. /**
  60238. * Gets the value operand input component
  60239. */
  60240. get value(): NodeMaterialConnectionPoint;
  60241. /**
  60242. * Gets the first edge operand input component
  60243. */
  60244. get edge0(): NodeMaterialConnectionPoint;
  60245. /**
  60246. * Gets the second edge operand input component
  60247. */
  60248. get edge1(): NodeMaterialConnectionPoint;
  60249. /**
  60250. * Gets the output component
  60251. */
  60252. get output(): NodeMaterialConnectionPoint;
  60253. protected _buildBlock(state: NodeMaterialBuildState): this;
  60254. }
  60255. }
  60256. declare module BABYLON {
  60257. /**
  60258. * Block used to get the reciprocal (1 / x) of a value
  60259. */
  60260. export class ReciprocalBlock extends NodeMaterialBlock {
  60261. /**
  60262. * Creates a new ReciprocalBlock
  60263. * @param name defines the block name
  60264. */
  60265. constructor(name: string);
  60266. /**
  60267. * Gets the current class name
  60268. * @returns the class name
  60269. */
  60270. getClassName(): string;
  60271. /**
  60272. * Gets the input component
  60273. */
  60274. get input(): NodeMaterialConnectionPoint;
  60275. /**
  60276. * Gets the output component
  60277. */
  60278. get output(): NodeMaterialConnectionPoint;
  60279. protected _buildBlock(state: NodeMaterialBuildState): this;
  60280. }
  60281. }
  60282. declare module BABYLON {
  60283. /**
  60284. * Block used to replace a color by another one
  60285. */
  60286. export class ReplaceColorBlock extends NodeMaterialBlock {
  60287. /**
  60288. * Creates a new ReplaceColorBlock
  60289. * @param name defines the block name
  60290. */
  60291. constructor(name: string);
  60292. /**
  60293. * Gets the current class name
  60294. * @returns the class name
  60295. */
  60296. getClassName(): string;
  60297. /**
  60298. * Gets the value input component
  60299. */
  60300. get value(): NodeMaterialConnectionPoint;
  60301. /**
  60302. * Gets the reference input component
  60303. */
  60304. get reference(): NodeMaterialConnectionPoint;
  60305. /**
  60306. * Gets the distance input component
  60307. */
  60308. get distance(): NodeMaterialConnectionPoint;
  60309. /**
  60310. * Gets the replacement input component
  60311. */
  60312. get replacement(): NodeMaterialConnectionPoint;
  60313. /**
  60314. * Gets the output component
  60315. */
  60316. get output(): NodeMaterialConnectionPoint;
  60317. protected _buildBlock(state: NodeMaterialBuildState): this;
  60318. }
  60319. }
  60320. declare module BABYLON {
  60321. /**
  60322. * Block used to posterize a value
  60323. * @see https://en.wikipedia.org/wiki/Posterization
  60324. */
  60325. export class PosterizeBlock extends NodeMaterialBlock {
  60326. /**
  60327. * Creates a new PosterizeBlock
  60328. * @param name defines the block name
  60329. */
  60330. constructor(name: string);
  60331. /**
  60332. * Gets the current class name
  60333. * @returns the class name
  60334. */
  60335. getClassName(): string;
  60336. /**
  60337. * Gets the value input component
  60338. */
  60339. get value(): NodeMaterialConnectionPoint;
  60340. /**
  60341. * Gets the steps input component
  60342. */
  60343. get steps(): NodeMaterialConnectionPoint;
  60344. /**
  60345. * Gets the output component
  60346. */
  60347. get output(): NodeMaterialConnectionPoint;
  60348. protected _buildBlock(state: NodeMaterialBuildState): this;
  60349. }
  60350. }
  60351. declare module BABYLON {
  60352. /**
  60353. * Operations supported by the Wave block
  60354. */
  60355. export enum WaveBlockKind {
  60356. /** SawTooth */
  60357. SawTooth = 0,
  60358. /** Square */
  60359. Square = 1,
  60360. /** Triangle */
  60361. Triangle = 2
  60362. }
  60363. /**
  60364. * Block used to apply wave operation to floats
  60365. */
  60366. export class WaveBlock extends NodeMaterialBlock {
  60367. /**
  60368. * Gets or sets the kibnd of wave to be applied by the block
  60369. */
  60370. kind: WaveBlockKind;
  60371. /**
  60372. * Creates a new WaveBlock
  60373. * @param name defines the block name
  60374. */
  60375. constructor(name: string);
  60376. /**
  60377. * Gets the current class name
  60378. * @returns the class name
  60379. */
  60380. getClassName(): string;
  60381. /**
  60382. * Gets the input component
  60383. */
  60384. get input(): NodeMaterialConnectionPoint;
  60385. /**
  60386. * Gets the output component
  60387. */
  60388. get output(): NodeMaterialConnectionPoint;
  60389. protected _buildBlock(state: NodeMaterialBuildState): this;
  60390. serialize(): any;
  60391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60392. }
  60393. }
  60394. declare module BABYLON {
  60395. /**
  60396. * Class used to store a color step for the GradientBlock
  60397. */
  60398. export class GradientBlockColorStep {
  60399. /**
  60400. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60401. */
  60402. step: number;
  60403. /**
  60404. * Gets or sets the color associated with this step
  60405. */
  60406. color: Color3;
  60407. /**
  60408. * Creates a new GradientBlockColorStep
  60409. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60410. * @param color defines the color associated with this step
  60411. */
  60412. constructor(
  60413. /**
  60414. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60415. */
  60416. step: number,
  60417. /**
  60418. * Gets or sets the color associated with this step
  60419. */
  60420. color: Color3);
  60421. }
  60422. /**
  60423. * Block used to return a color from a gradient based on an input value between 0 and 1
  60424. */
  60425. export class GradientBlock extends NodeMaterialBlock {
  60426. /**
  60427. * Gets or sets the list of color steps
  60428. */
  60429. colorSteps: GradientBlockColorStep[];
  60430. /**
  60431. * Creates a new GradientBlock
  60432. * @param name defines the block name
  60433. */
  60434. constructor(name: string);
  60435. /**
  60436. * Gets the current class name
  60437. * @returns the class name
  60438. */
  60439. getClassName(): string;
  60440. /**
  60441. * Gets the gradient input component
  60442. */
  60443. get gradient(): NodeMaterialConnectionPoint;
  60444. /**
  60445. * Gets the output component
  60446. */
  60447. get output(): NodeMaterialConnectionPoint;
  60448. private _writeColorConstant;
  60449. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60450. serialize(): any;
  60451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60452. protected _dumpPropertiesCode(): string;
  60453. }
  60454. }
  60455. declare module BABYLON {
  60456. /**
  60457. * Block used to normalize lerp between 2 values
  60458. */
  60459. export class NLerpBlock extends NodeMaterialBlock {
  60460. /**
  60461. * Creates a new NLerpBlock
  60462. * @param name defines the block name
  60463. */
  60464. constructor(name: string);
  60465. /**
  60466. * Gets the current class name
  60467. * @returns the class name
  60468. */
  60469. getClassName(): string;
  60470. /**
  60471. * Gets the left operand input component
  60472. */
  60473. get left(): NodeMaterialConnectionPoint;
  60474. /**
  60475. * Gets the right operand input component
  60476. */
  60477. get right(): NodeMaterialConnectionPoint;
  60478. /**
  60479. * Gets the gradient operand input component
  60480. */
  60481. get gradient(): NodeMaterialConnectionPoint;
  60482. /**
  60483. * Gets the output component
  60484. */
  60485. get output(): NodeMaterialConnectionPoint;
  60486. protected _buildBlock(state: NodeMaterialBuildState): this;
  60487. }
  60488. }
  60489. declare module BABYLON {
  60490. /**
  60491. * block used to Generate a Worley Noise 3D Noise Pattern
  60492. */
  60493. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60494. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60495. manhattanDistance: boolean;
  60496. /**
  60497. * Creates a new WorleyNoise3DBlock
  60498. * @param name defines the block name
  60499. */
  60500. constructor(name: string);
  60501. /**
  60502. * Gets the current class name
  60503. * @returns the class name
  60504. */
  60505. getClassName(): string;
  60506. /**
  60507. * Gets the seed input component
  60508. */
  60509. get seed(): NodeMaterialConnectionPoint;
  60510. /**
  60511. * Gets the jitter input component
  60512. */
  60513. get jitter(): NodeMaterialConnectionPoint;
  60514. /**
  60515. * Gets the output component
  60516. */
  60517. get output(): NodeMaterialConnectionPoint;
  60518. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60519. /**
  60520. * Exposes the properties to the UI?
  60521. */
  60522. protected _dumpPropertiesCode(): string;
  60523. /**
  60524. * Exposes the properties to the Seralize?
  60525. */
  60526. serialize(): any;
  60527. /**
  60528. * Exposes the properties to the deseralize?
  60529. */
  60530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60531. }
  60532. }
  60533. declare module BABYLON {
  60534. /**
  60535. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60536. */
  60537. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60538. /**
  60539. * Creates a new SimplexPerlin3DBlock
  60540. * @param name defines the block name
  60541. */
  60542. constructor(name: string);
  60543. /**
  60544. * Gets the current class name
  60545. * @returns the class name
  60546. */
  60547. getClassName(): string;
  60548. /**
  60549. * Gets the seed operand input component
  60550. */
  60551. get seed(): NodeMaterialConnectionPoint;
  60552. /**
  60553. * Gets the output component
  60554. */
  60555. get output(): NodeMaterialConnectionPoint;
  60556. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60557. }
  60558. }
  60559. declare module BABYLON {
  60560. /**
  60561. * Block used to blend normals
  60562. */
  60563. export class NormalBlendBlock extends NodeMaterialBlock {
  60564. /**
  60565. * Creates a new NormalBlendBlock
  60566. * @param name defines the block name
  60567. */
  60568. constructor(name: string);
  60569. /**
  60570. * Gets the current class name
  60571. * @returns the class name
  60572. */
  60573. getClassName(): string;
  60574. /**
  60575. * Gets the first input component
  60576. */
  60577. get normalMap0(): NodeMaterialConnectionPoint;
  60578. /**
  60579. * Gets the second input component
  60580. */
  60581. get normalMap1(): NodeMaterialConnectionPoint;
  60582. /**
  60583. * Gets the output component
  60584. */
  60585. get output(): NodeMaterialConnectionPoint;
  60586. protected _buildBlock(state: NodeMaterialBuildState): this;
  60587. }
  60588. }
  60589. declare module BABYLON {
  60590. /**
  60591. * Block used to rotate a 2d vector by a given angle
  60592. */
  60593. export class Rotate2dBlock extends NodeMaterialBlock {
  60594. /**
  60595. * Creates a new Rotate2dBlock
  60596. * @param name defines the block name
  60597. */
  60598. constructor(name: string);
  60599. /**
  60600. * Gets the current class name
  60601. * @returns the class name
  60602. */
  60603. getClassName(): string;
  60604. /**
  60605. * Gets the input vector
  60606. */
  60607. get input(): NodeMaterialConnectionPoint;
  60608. /**
  60609. * Gets the input angle
  60610. */
  60611. get angle(): NodeMaterialConnectionPoint;
  60612. /**
  60613. * Gets the output component
  60614. */
  60615. get output(): NodeMaterialConnectionPoint;
  60616. autoConfigure(material: NodeMaterial): void;
  60617. protected _buildBlock(state: NodeMaterialBuildState): this;
  60618. }
  60619. }
  60620. declare module BABYLON {
  60621. /**
  60622. * Block used to get the reflected vector from a direction and a normal
  60623. */
  60624. export class ReflectBlock extends NodeMaterialBlock {
  60625. /**
  60626. * Creates a new ReflectBlock
  60627. * @param name defines the block name
  60628. */
  60629. constructor(name: string);
  60630. /**
  60631. * Gets the current class name
  60632. * @returns the class name
  60633. */
  60634. getClassName(): string;
  60635. /**
  60636. * Gets the incident component
  60637. */
  60638. get incident(): NodeMaterialConnectionPoint;
  60639. /**
  60640. * Gets the normal component
  60641. */
  60642. get normal(): NodeMaterialConnectionPoint;
  60643. /**
  60644. * Gets the output component
  60645. */
  60646. get output(): NodeMaterialConnectionPoint;
  60647. protected _buildBlock(state: NodeMaterialBuildState): this;
  60648. }
  60649. }
  60650. declare module BABYLON {
  60651. /**
  60652. * Block used to get the refracted vector from a direction and a normal
  60653. */
  60654. export class RefractBlock extends NodeMaterialBlock {
  60655. /**
  60656. * Creates a new RefractBlock
  60657. * @param name defines the block name
  60658. */
  60659. constructor(name: string);
  60660. /**
  60661. * Gets the current class name
  60662. * @returns the class name
  60663. */
  60664. getClassName(): string;
  60665. /**
  60666. * Gets the incident component
  60667. */
  60668. get incident(): NodeMaterialConnectionPoint;
  60669. /**
  60670. * Gets the normal component
  60671. */
  60672. get normal(): NodeMaterialConnectionPoint;
  60673. /**
  60674. * Gets the index of refraction component
  60675. */
  60676. get ior(): NodeMaterialConnectionPoint;
  60677. /**
  60678. * Gets the output component
  60679. */
  60680. get output(): NodeMaterialConnectionPoint;
  60681. protected _buildBlock(state: NodeMaterialBuildState): this;
  60682. }
  60683. }
  60684. declare module BABYLON {
  60685. /**
  60686. * Block used to desaturate a color
  60687. */
  60688. export class DesaturateBlock extends NodeMaterialBlock {
  60689. /**
  60690. * Creates a new DesaturateBlock
  60691. * @param name defines the block name
  60692. */
  60693. constructor(name: string);
  60694. /**
  60695. * Gets the current class name
  60696. * @returns the class name
  60697. */
  60698. getClassName(): string;
  60699. /**
  60700. * Gets the color operand input component
  60701. */
  60702. get color(): NodeMaterialConnectionPoint;
  60703. /**
  60704. * Gets the level operand input component
  60705. */
  60706. get level(): NodeMaterialConnectionPoint;
  60707. /**
  60708. * Gets the output component
  60709. */
  60710. get output(): NodeMaterialConnectionPoint;
  60711. protected _buildBlock(state: NodeMaterialBuildState): this;
  60712. }
  60713. }
  60714. declare module BABYLON {
  60715. /**
  60716. * Effect Render Options
  60717. */
  60718. export interface IEffectRendererOptions {
  60719. /**
  60720. * Defines the vertices positions.
  60721. */
  60722. positions?: number[];
  60723. /**
  60724. * Defines the indices.
  60725. */
  60726. indices?: number[];
  60727. }
  60728. /**
  60729. * Helper class to render one or more effects.
  60730. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60731. */
  60732. export class EffectRenderer {
  60733. private engine;
  60734. private static _DefaultOptions;
  60735. private _vertexBuffers;
  60736. private _indexBuffer;
  60737. private _fullscreenViewport;
  60738. /**
  60739. * Creates an effect renderer
  60740. * @param engine the engine to use for rendering
  60741. * @param options defines the options of the effect renderer
  60742. */
  60743. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60744. /**
  60745. * Sets the current viewport in normalized coordinates 0-1
  60746. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60747. */
  60748. setViewport(viewport?: Viewport): void;
  60749. /**
  60750. * Binds the embedded attributes buffer to the effect.
  60751. * @param effect Defines the effect to bind the attributes for
  60752. */
  60753. bindBuffers(effect: Effect): void;
  60754. /**
  60755. * Sets the current effect wrapper to use during draw.
  60756. * The effect needs to be ready before calling this api.
  60757. * This also sets the default full screen position attribute.
  60758. * @param effectWrapper Defines the effect to draw with
  60759. */
  60760. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60761. /**
  60762. * Draws a full screen quad.
  60763. */
  60764. draw(): void;
  60765. private isRenderTargetTexture;
  60766. /**
  60767. * renders one or more effects to a specified texture
  60768. * @param effectWrapper the effect to renderer
  60769. * @param outputTexture texture to draw to, if null it will render to the screen.
  60770. */
  60771. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60772. /**
  60773. * Disposes of the effect renderer
  60774. */
  60775. dispose(): void;
  60776. }
  60777. /**
  60778. * Options to create an EffectWrapper
  60779. */
  60780. interface EffectWrapperCreationOptions {
  60781. /**
  60782. * Engine to use to create the effect
  60783. */
  60784. engine: ThinEngine;
  60785. /**
  60786. * Fragment shader for the effect
  60787. */
  60788. fragmentShader: string;
  60789. /**
  60790. * Vertex shader for the effect
  60791. */
  60792. vertexShader?: string;
  60793. /**
  60794. * Attributes to use in the shader
  60795. */
  60796. attributeNames?: Array<string>;
  60797. /**
  60798. * Uniforms to use in the shader
  60799. */
  60800. uniformNames?: Array<string>;
  60801. /**
  60802. * Texture sampler names to use in the shader
  60803. */
  60804. samplerNames?: Array<string>;
  60805. /**
  60806. * The friendly name of the effect displayed in Spector.
  60807. */
  60808. name?: string;
  60809. }
  60810. /**
  60811. * Wraps an effect to be used for rendering
  60812. */
  60813. export class EffectWrapper {
  60814. /**
  60815. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60816. */
  60817. onApplyObservable: Observable<{}>;
  60818. /**
  60819. * The underlying effect
  60820. */
  60821. effect: Effect;
  60822. /**
  60823. * Creates an effect to be renderer
  60824. * @param creationOptions options to create the effect
  60825. */
  60826. constructor(creationOptions: EffectWrapperCreationOptions);
  60827. /**
  60828. * Disposes of the effect wrapper
  60829. */
  60830. dispose(): void;
  60831. }
  60832. }
  60833. declare module BABYLON {
  60834. /**
  60835. * Helper class to push actions to a pool of workers.
  60836. */
  60837. export class WorkerPool implements IDisposable {
  60838. private _workerInfos;
  60839. private _pendingActions;
  60840. /**
  60841. * Constructor
  60842. * @param workers Array of workers to use for actions
  60843. */
  60844. constructor(workers: Array<Worker>);
  60845. /**
  60846. * Terminates all workers and clears any pending actions.
  60847. */
  60848. dispose(): void;
  60849. /**
  60850. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60851. * pended until a worker has completed its action.
  60852. * @param action The action to perform. Call onComplete when the action is complete.
  60853. */
  60854. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60855. private _execute;
  60856. }
  60857. }
  60858. declare module BABYLON {
  60859. /**
  60860. * Configuration for Draco compression
  60861. */
  60862. export interface IDracoCompressionConfiguration {
  60863. /**
  60864. * Configuration for the decoder.
  60865. */
  60866. decoder: {
  60867. /**
  60868. * The url to the WebAssembly module.
  60869. */
  60870. wasmUrl?: string;
  60871. /**
  60872. * The url to the WebAssembly binary.
  60873. */
  60874. wasmBinaryUrl?: string;
  60875. /**
  60876. * The url to the fallback JavaScript module.
  60877. */
  60878. fallbackUrl?: string;
  60879. };
  60880. }
  60881. /**
  60882. * Draco compression (https://google.github.io/draco/)
  60883. *
  60884. * This class wraps the Draco module.
  60885. *
  60886. * **Encoder**
  60887. *
  60888. * The encoder is not currently implemented.
  60889. *
  60890. * **Decoder**
  60891. *
  60892. * 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.
  60893. *
  60894. * To update the configuration, use the following code:
  60895. * ```javascript
  60896. * DracoCompression.Configuration = {
  60897. * decoder: {
  60898. * wasmUrl: "<url to the WebAssembly library>",
  60899. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60900. * fallbackUrl: "<url to the fallback JavaScript library>",
  60901. * }
  60902. * };
  60903. * ```
  60904. *
  60905. * 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.
  60906. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60907. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60908. *
  60909. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60910. * ```javascript
  60911. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60912. * ```
  60913. *
  60914. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60915. */
  60916. export class DracoCompression implements IDisposable {
  60917. private _workerPoolPromise?;
  60918. private _decoderModulePromise?;
  60919. /**
  60920. * The configuration. Defaults to the following urls:
  60921. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60922. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60923. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60924. */
  60925. static Configuration: IDracoCompressionConfiguration;
  60926. /**
  60927. * Returns true if the decoder configuration is available.
  60928. */
  60929. static get DecoderAvailable(): boolean;
  60930. /**
  60931. * Default number of workers to create when creating the draco compression object.
  60932. */
  60933. static DefaultNumWorkers: number;
  60934. private static GetDefaultNumWorkers;
  60935. private static _Default;
  60936. /**
  60937. * Default instance for the draco compression object.
  60938. */
  60939. static get Default(): DracoCompression;
  60940. /**
  60941. * Constructor
  60942. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60943. */
  60944. constructor(numWorkers?: number);
  60945. /**
  60946. * Stop all async operations and release resources.
  60947. */
  60948. dispose(): void;
  60949. /**
  60950. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60951. * @returns a promise that resolves when ready
  60952. */
  60953. whenReadyAsync(): Promise<void>;
  60954. /**
  60955. * Decode Draco compressed mesh data to vertex data.
  60956. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60957. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60958. * @returns A promise that resolves with the decoded vertex data
  60959. */
  60960. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60961. [kind: string]: number;
  60962. }): Promise<VertexData>;
  60963. }
  60964. }
  60965. declare module BABYLON {
  60966. /**
  60967. * Class for building Constructive Solid Geometry
  60968. */
  60969. export class CSG {
  60970. private polygons;
  60971. /**
  60972. * The world matrix
  60973. */
  60974. matrix: Matrix;
  60975. /**
  60976. * Stores the position
  60977. */
  60978. position: Vector3;
  60979. /**
  60980. * Stores the rotation
  60981. */
  60982. rotation: Vector3;
  60983. /**
  60984. * Stores the rotation quaternion
  60985. */
  60986. rotationQuaternion: Nullable<Quaternion>;
  60987. /**
  60988. * Stores the scaling vector
  60989. */
  60990. scaling: Vector3;
  60991. /**
  60992. * Convert the Mesh to CSG
  60993. * @param mesh The Mesh to convert to CSG
  60994. * @returns A new CSG from the Mesh
  60995. */
  60996. static FromMesh(mesh: Mesh): CSG;
  60997. /**
  60998. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60999. * @param polygons Polygons used to construct a CSG solid
  61000. */
  61001. private static FromPolygons;
  61002. /**
  61003. * Clones, or makes a deep copy, of the CSG
  61004. * @returns A new CSG
  61005. */
  61006. clone(): CSG;
  61007. /**
  61008. * Unions this CSG with another CSG
  61009. * @param csg The CSG to union against this CSG
  61010. * @returns The unioned CSG
  61011. */
  61012. union(csg: CSG): CSG;
  61013. /**
  61014. * Unions this CSG with another CSG in place
  61015. * @param csg The CSG to union against this CSG
  61016. */
  61017. unionInPlace(csg: CSG): void;
  61018. /**
  61019. * Subtracts this CSG with another CSG
  61020. * @param csg The CSG to subtract against this CSG
  61021. * @returns A new CSG
  61022. */
  61023. subtract(csg: CSG): CSG;
  61024. /**
  61025. * Subtracts this CSG with another CSG in place
  61026. * @param csg The CSG to subtact against this CSG
  61027. */
  61028. subtractInPlace(csg: CSG): void;
  61029. /**
  61030. * Intersect this CSG with another CSG
  61031. * @param csg The CSG to intersect against this CSG
  61032. * @returns A new CSG
  61033. */
  61034. intersect(csg: CSG): CSG;
  61035. /**
  61036. * Intersects this CSG with another CSG in place
  61037. * @param csg The CSG to intersect against this CSG
  61038. */
  61039. intersectInPlace(csg: CSG): void;
  61040. /**
  61041. * Return a new CSG solid with solid and empty space switched. This solid is
  61042. * not modified.
  61043. * @returns A new CSG solid with solid and empty space switched
  61044. */
  61045. inverse(): CSG;
  61046. /**
  61047. * Inverses the CSG in place
  61048. */
  61049. inverseInPlace(): void;
  61050. /**
  61051. * This is used to keep meshes transformations so they can be restored
  61052. * when we build back a Babylon Mesh
  61053. * NB : All CSG operations are performed in world coordinates
  61054. * @param csg The CSG to copy the transform attributes from
  61055. * @returns This CSG
  61056. */
  61057. copyTransformAttributes(csg: CSG): CSG;
  61058. /**
  61059. * Build Raw mesh from CSG
  61060. * Coordinates here are in world space
  61061. * @param name The name of the mesh geometry
  61062. * @param scene The Scene
  61063. * @param keepSubMeshes Specifies if the submeshes should be kept
  61064. * @returns A new Mesh
  61065. */
  61066. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61067. /**
  61068. * Build Mesh from CSG taking material and transforms into account
  61069. * @param name The name of the Mesh
  61070. * @param material The material of the Mesh
  61071. * @param scene The Scene
  61072. * @param keepSubMeshes Specifies if submeshes should be kept
  61073. * @returns The new Mesh
  61074. */
  61075. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61076. }
  61077. }
  61078. declare module BABYLON {
  61079. /**
  61080. * Class used to create a trail following a mesh
  61081. */
  61082. export class TrailMesh extends Mesh {
  61083. private _generator;
  61084. private _autoStart;
  61085. private _running;
  61086. private _diameter;
  61087. private _length;
  61088. private _sectionPolygonPointsCount;
  61089. private _sectionVectors;
  61090. private _sectionNormalVectors;
  61091. private _beforeRenderObserver;
  61092. /**
  61093. * @constructor
  61094. * @param name The value used by scene.getMeshByName() to do a lookup.
  61095. * @param generator The mesh or transform node to generate a trail.
  61096. * @param scene The scene to add this mesh to.
  61097. * @param diameter Diameter of trailing mesh. Default is 1.
  61098. * @param length Length of trailing mesh. Default is 60.
  61099. * @param autoStart Automatically start trailing mesh. Default true.
  61100. */
  61101. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61102. /**
  61103. * "TrailMesh"
  61104. * @returns "TrailMesh"
  61105. */
  61106. getClassName(): string;
  61107. private _createMesh;
  61108. /**
  61109. * Start trailing mesh.
  61110. */
  61111. start(): void;
  61112. /**
  61113. * Stop trailing mesh.
  61114. */
  61115. stop(): void;
  61116. /**
  61117. * Update trailing mesh geometry.
  61118. */
  61119. update(): void;
  61120. /**
  61121. * Returns a new TrailMesh object.
  61122. * @param name is a string, the name given to the new mesh
  61123. * @param newGenerator use new generator object for cloned trail mesh
  61124. * @returns a new mesh
  61125. */
  61126. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61127. /**
  61128. * Serializes this trail mesh
  61129. * @param serializationObject object to write serialization to
  61130. */
  61131. serialize(serializationObject: any): void;
  61132. /**
  61133. * Parses a serialized trail mesh
  61134. * @param parsedMesh the serialized mesh
  61135. * @param scene the scene to create the trail mesh in
  61136. * @returns the created trail mesh
  61137. */
  61138. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61139. }
  61140. }
  61141. declare module BABYLON {
  61142. /**
  61143. * Class containing static functions to help procedurally build meshes
  61144. */
  61145. export class TiledBoxBuilder {
  61146. /**
  61147. * Creates a box mesh
  61148. * 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)
  61149. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61151. * * 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
  61152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61153. * @param name defines the name of the mesh
  61154. * @param options defines the options used to create the mesh
  61155. * @param scene defines the hosting scene
  61156. * @returns the box mesh
  61157. */
  61158. static CreateTiledBox(name: string, options: {
  61159. pattern?: number;
  61160. width?: number;
  61161. height?: number;
  61162. depth?: number;
  61163. tileSize?: number;
  61164. tileWidth?: number;
  61165. tileHeight?: number;
  61166. alignHorizontal?: number;
  61167. alignVertical?: number;
  61168. faceUV?: Vector4[];
  61169. faceColors?: Color4[];
  61170. sideOrientation?: number;
  61171. updatable?: boolean;
  61172. }, scene?: Nullable<Scene>): Mesh;
  61173. }
  61174. }
  61175. declare module BABYLON {
  61176. /**
  61177. * Class containing static functions to help procedurally build meshes
  61178. */
  61179. export class TorusKnotBuilder {
  61180. /**
  61181. * Creates a torus knot mesh
  61182. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61183. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61184. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61185. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61187. * * 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
  61188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61189. * @param name defines the name of the mesh
  61190. * @param options defines the options used to create the mesh
  61191. * @param scene defines the hosting scene
  61192. * @returns the torus knot mesh
  61193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61194. */
  61195. static CreateTorusKnot(name: string, options: {
  61196. radius?: number;
  61197. tube?: number;
  61198. radialSegments?: number;
  61199. tubularSegments?: number;
  61200. p?: number;
  61201. q?: number;
  61202. updatable?: boolean;
  61203. sideOrientation?: number;
  61204. frontUVs?: Vector4;
  61205. backUVs?: Vector4;
  61206. }, scene: any): Mesh;
  61207. }
  61208. }
  61209. declare module BABYLON {
  61210. /**
  61211. * Polygon
  61212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61213. */
  61214. export class Polygon {
  61215. /**
  61216. * Creates a rectangle
  61217. * @param xmin bottom X coord
  61218. * @param ymin bottom Y coord
  61219. * @param xmax top X coord
  61220. * @param ymax top Y coord
  61221. * @returns points that make the resulting rectation
  61222. */
  61223. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61224. /**
  61225. * Creates a circle
  61226. * @param radius radius of circle
  61227. * @param cx scale in x
  61228. * @param cy scale in y
  61229. * @param numberOfSides number of sides that make up the circle
  61230. * @returns points that make the resulting circle
  61231. */
  61232. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61233. /**
  61234. * Creates a polygon from input string
  61235. * @param input Input polygon data
  61236. * @returns the parsed points
  61237. */
  61238. static Parse(input: string): Vector2[];
  61239. /**
  61240. * Starts building a polygon from x and y coordinates
  61241. * @param x x coordinate
  61242. * @param y y coordinate
  61243. * @returns the started path2
  61244. */
  61245. static StartingAt(x: number, y: number): Path2;
  61246. }
  61247. /**
  61248. * Builds a polygon
  61249. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61250. */
  61251. export class PolygonMeshBuilder {
  61252. private _points;
  61253. private _outlinepoints;
  61254. private _holes;
  61255. private _name;
  61256. private _scene;
  61257. private _epoints;
  61258. private _eholes;
  61259. private _addToepoint;
  61260. /**
  61261. * Babylon reference to the earcut plugin.
  61262. */
  61263. bjsEarcut: any;
  61264. /**
  61265. * Creates a PolygonMeshBuilder
  61266. * @param name name of the builder
  61267. * @param contours Path of the polygon
  61268. * @param scene scene to add to when creating the mesh
  61269. * @param earcutInjection can be used to inject your own earcut reference
  61270. */
  61271. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61272. /**
  61273. * Adds a whole within the polygon
  61274. * @param hole Array of points defining the hole
  61275. * @returns this
  61276. */
  61277. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61278. /**
  61279. * Creates the polygon
  61280. * @param updatable If the mesh should be updatable
  61281. * @param depth The depth of the mesh created
  61282. * @returns the created mesh
  61283. */
  61284. build(updatable?: boolean, depth?: number): Mesh;
  61285. /**
  61286. * Creates the polygon
  61287. * @param depth The depth of the mesh created
  61288. * @returns the created VertexData
  61289. */
  61290. buildVertexData(depth?: number): VertexData;
  61291. /**
  61292. * Adds a side to the polygon
  61293. * @param positions points that make the polygon
  61294. * @param normals normals of the polygon
  61295. * @param uvs uvs of the polygon
  61296. * @param indices indices of the polygon
  61297. * @param bounds bounds of the polygon
  61298. * @param points points of the polygon
  61299. * @param depth depth of the polygon
  61300. * @param flip flip of the polygon
  61301. */
  61302. private addSide;
  61303. }
  61304. }
  61305. declare module BABYLON {
  61306. /**
  61307. * Class containing static functions to help procedurally build meshes
  61308. */
  61309. export class PolygonBuilder {
  61310. /**
  61311. * Creates a polygon mesh
  61312. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61313. * * 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
  61314. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61316. * * 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)
  61317. * * Remember you can only change the shape positions, not their number when updating a polygon
  61318. * @param name defines the name of the mesh
  61319. * @param options defines the options used to create the mesh
  61320. * @param scene defines the hosting scene
  61321. * @param earcutInjection can be used to inject your own earcut reference
  61322. * @returns the polygon mesh
  61323. */
  61324. static CreatePolygon(name: string, options: {
  61325. shape: Vector3[];
  61326. holes?: Vector3[][];
  61327. depth?: number;
  61328. faceUV?: Vector4[];
  61329. faceColors?: Color4[];
  61330. updatable?: boolean;
  61331. sideOrientation?: number;
  61332. frontUVs?: Vector4;
  61333. backUVs?: Vector4;
  61334. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61335. /**
  61336. * Creates an extruded polygon mesh, with depth in the Y direction.
  61337. * * 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)
  61338. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61339. * @param name defines the name of the mesh
  61340. * @param options defines the options used to create the mesh
  61341. * @param scene defines the hosting scene
  61342. * @param earcutInjection can be used to inject your own earcut reference
  61343. * @returns the polygon mesh
  61344. */
  61345. static ExtrudePolygon(name: string, options: {
  61346. shape: Vector3[];
  61347. holes?: Vector3[][];
  61348. depth?: number;
  61349. faceUV?: Vector4[];
  61350. faceColors?: Color4[];
  61351. updatable?: boolean;
  61352. sideOrientation?: number;
  61353. frontUVs?: Vector4;
  61354. backUVs?: Vector4;
  61355. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61356. }
  61357. }
  61358. declare module BABYLON {
  61359. /**
  61360. * Class containing static functions to help procedurally build meshes
  61361. */
  61362. export class LatheBuilder {
  61363. /**
  61364. * Creates lathe mesh.
  61365. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61366. * * 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
  61367. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61368. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61369. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61370. * * 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
  61371. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61372. * * 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
  61373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61374. * * 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
  61375. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61377. * @param name defines the name of the mesh
  61378. * @param options defines the options used to create the mesh
  61379. * @param scene defines the hosting scene
  61380. * @returns the lathe mesh
  61381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61382. */
  61383. static CreateLathe(name: string, options: {
  61384. shape: Vector3[];
  61385. radius?: number;
  61386. tessellation?: number;
  61387. clip?: number;
  61388. arc?: number;
  61389. closed?: boolean;
  61390. updatable?: boolean;
  61391. sideOrientation?: number;
  61392. frontUVs?: Vector4;
  61393. backUVs?: Vector4;
  61394. cap?: number;
  61395. invertUV?: boolean;
  61396. }, scene?: Nullable<Scene>): Mesh;
  61397. }
  61398. }
  61399. declare module BABYLON {
  61400. /**
  61401. * Class containing static functions to help procedurally build meshes
  61402. */
  61403. export class TiledPlaneBuilder {
  61404. /**
  61405. * Creates a tiled plane mesh
  61406. * * The parameter `pattern` will, depending on value, do nothing or
  61407. * * * flip (reflect about central vertical) alternate tiles across and up
  61408. * * * flip every tile on alternate rows
  61409. * * * rotate (180 degs) alternate tiles across and up
  61410. * * * rotate every tile on alternate rows
  61411. * * * flip and rotate alternate tiles across and up
  61412. * * * flip and rotate every tile on alternate rows
  61413. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61414. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61415. * * 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
  61416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61417. * * 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)
  61418. * * 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)
  61419. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61420. * @param name defines the name of the mesh
  61421. * @param options defines the options used to create the mesh
  61422. * @param scene defines the hosting scene
  61423. * @returns the box mesh
  61424. */
  61425. static CreateTiledPlane(name: string, options: {
  61426. pattern?: number;
  61427. tileSize?: number;
  61428. tileWidth?: number;
  61429. tileHeight?: number;
  61430. size?: number;
  61431. width?: number;
  61432. height?: number;
  61433. alignHorizontal?: number;
  61434. alignVertical?: number;
  61435. sideOrientation?: number;
  61436. frontUVs?: Vector4;
  61437. backUVs?: Vector4;
  61438. updatable?: boolean;
  61439. }, scene?: Nullable<Scene>): Mesh;
  61440. }
  61441. }
  61442. declare module BABYLON {
  61443. /**
  61444. * Class containing static functions to help procedurally build meshes
  61445. */
  61446. export class TubeBuilder {
  61447. /**
  61448. * Creates a tube mesh.
  61449. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61450. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61451. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61452. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61453. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61454. * * 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)
  61455. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61456. * * 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
  61457. * * 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
  61458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61459. * * 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
  61460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61462. * @param name defines the name of the mesh
  61463. * @param options defines the options used to create the mesh
  61464. * @param scene defines the hosting scene
  61465. * @returns the tube mesh
  61466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61467. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61468. */
  61469. static CreateTube(name: string, options: {
  61470. path: Vector3[];
  61471. radius?: number;
  61472. tessellation?: number;
  61473. radiusFunction?: {
  61474. (i: number, distance: number): number;
  61475. };
  61476. cap?: number;
  61477. arc?: number;
  61478. updatable?: boolean;
  61479. sideOrientation?: number;
  61480. frontUVs?: Vector4;
  61481. backUVs?: Vector4;
  61482. instance?: Mesh;
  61483. invertUV?: 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 IcoSphereBuilder {
  61492. /**
  61493. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61494. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61495. * * 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`)
  61496. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61497. * * 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
  61498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61499. * * 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
  61500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61501. * @param name defines the name of the mesh
  61502. * @param options defines the options used to create the mesh
  61503. * @param scene defines the hosting scene
  61504. * @returns the icosahedron mesh
  61505. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61506. */
  61507. static CreateIcoSphere(name: string, options: {
  61508. radius?: number;
  61509. radiusX?: number;
  61510. radiusY?: number;
  61511. radiusZ?: number;
  61512. flat?: boolean;
  61513. subdivisions?: number;
  61514. sideOrientation?: number;
  61515. frontUVs?: Vector4;
  61516. backUVs?: Vector4;
  61517. updatable?: boolean;
  61518. }, scene?: Nullable<Scene>): Mesh;
  61519. }
  61520. }
  61521. declare module BABYLON {
  61522. /**
  61523. * Class containing static functions to help procedurally build meshes
  61524. */
  61525. export class DecalBuilder {
  61526. /**
  61527. * Creates a decal mesh.
  61528. * 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
  61529. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61530. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61531. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61532. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61533. * @param name defines the name of the mesh
  61534. * @param sourceMesh defines the mesh where the decal must be applied
  61535. * @param options defines the options used to create the mesh
  61536. * @param scene defines the hosting scene
  61537. * @returns the decal mesh
  61538. * @see https://doc.babylonjs.com/how_to/decals
  61539. */
  61540. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61541. position?: Vector3;
  61542. normal?: Vector3;
  61543. size?: Vector3;
  61544. angle?: number;
  61545. }): Mesh;
  61546. }
  61547. }
  61548. declare module BABYLON {
  61549. /**
  61550. * Class containing static functions to help procedurally build meshes
  61551. */
  61552. export class MeshBuilder {
  61553. /**
  61554. * Creates a box mesh
  61555. * * The parameter `size` sets the size (float) of each box side (default 1)
  61556. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61557. * * 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)
  61558. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61560. * * 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
  61561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61562. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61563. * @param name defines the name of the mesh
  61564. * @param options defines the options used to create the mesh
  61565. * @param scene defines the hosting scene
  61566. * @returns the box mesh
  61567. */
  61568. static CreateBox(name: string, options: {
  61569. size?: number;
  61570. width?: number;
  61571. height?: number;
  61572. depth?: number;
  61573. faceUV?: Vector4[];
  61574. faceColors?: Color4[];
  61575. sideOrientation?: number;
  61576. frontUVs?: Vector4;
  61577. backUVs?: Vector4;
  61578. wrap?: boolean;
  61579. topBaseAt?: number;
  61580. bottomBaseAt?: number;
  61581. updatable?: boolean;
  61582. }, scene?: Nullable<Scene>): Mesh;
  61583. /**
  61584. * Creates a tiled box mesh
  61585. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61587. * @param name defines the name of the mesh
  61588. * @param options defines the options used to create the mesh
  61589. * @param scene defines the hosting scene
  61590. * @returns the tiled box mesh
  61591. */
  61592. static CreateTiledBox(name: string, options: {
  61593. pattern?: number;
  61594. size?: number;
  61595. width?: number;
  61596. height?: number;
  61597. depth: number;
  61598. tileSize?: number;
  61599. tileWidth?: number;
  61600. tileHeight?: number;
  61601. faceUV?: Vector4[];
  61602. faceColors?: Color4[];
  61603. alignHorizontal?: number;
  61604. alignVertical?: number;
  61605. sideOrientation?: number;
  61606. updatable?: boolean;
  61607. }, scene?: Nullable<Scene>): Mesh;
  61608. /**
  61609. * Creates a sphere mesh
  61610. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61611. * * 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`)
  61612. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61613. * * 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
  61614. * * 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)
  61615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61616. * * 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
  61617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61618. * @param name defines the name of the mesh
  61619. * @param options defines the options used to create the mesh
  61620. * @param scene defines the hosting scene
  61621. * @returns the sphere mesh
  61622. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61623. */
  61624. static CreateSphere(name: string, options: {
  61625. segments?: number;
  61626. diameter?: number;
  61627. diameterX?: number;
  61628. diameterY?: number;
  61629. diameterZ?: number;
  61630. arc?: number;
  61631. slice?: number;
  61632. sideOrientation?: number;
  61633. frontUVs?: Vector4;
  61634. backUVs?: Vector4;
  61635. updatable?: boolean;
  61636. }, scene?: Nullable<Scene>): Mesh;
  61637. /**
  61638. * Creates a plane polygonal mesh. By default, this is a disc
  61639. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61640. * * 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
  61641. * * 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
  61642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61643. * * 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
  61644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61645. * @param name defines the name of the mesh
  61646. * @param options defines the options used to create the mesh
  61647. * @param scene defines the hosting scene
  61648. * @returns the plane polygonal mesh
  61649. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61650. */
  61651. static CreateDisc(name: string, options: {
  61652. radius?: number;
  61653. tessellation?: number;
  61654. arc?: number;
  61655. updatable?: boolean;
  61656. sideOrientation?: number;
  61657. frontUVs?: Vector4;
  61658. backUVs?: Vector4;
  61659. }, scene?: Nullable<Scene>): Mesh;
  61660. /**
  61661. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61662. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61663. * * 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`)
  61664. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61665. * * 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
  61666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61667. * * 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
  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 icosahedron mesh
  61673. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61674. */
  61675. static CreateIcoSphere(name: string, options: {
  61676. radius?: number;
  61677. radiusX?: number;
  61678. radiusY?: number;
  61679. radiusZ?: number;
  61680. flat?: boolean;
  61681. subdivisions?: number;
  61682. sideOrientation?: number;
  61683. frontUVs?: Vector4;
  61684. backUVs?: Vector4;
  61685. updatable?: boolean;
  61686. }, scene?: Nullable<Scene>): Mesh;
  61687. /**
  61688. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61689. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61690. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61691. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61692. * * 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
  61693. * * 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
  61694. * * 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
  61695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61696. * * 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
  61697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61698. * * 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
  61699. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61700. * * 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
  61701. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61703. * @param name defines the name of the mesh
  61704. * @param options defines the options used to create the mesh
  61705. * @param scene defines the hosting scene
  61706. * @returns the ribbon mesh
  61707. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61708. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61709. */
  61710. static CreateRibbon(name: string, options: {
  61711. pathArray: Vector3[][];
  61712. closeArray?: boolean;
  61713. closePath?: boolean;
  61714. offset?: number;
  61715. updatable?: boolean;
  61716. sideOrientation?: number;
  61717. frontUVs?: Vector4;
  61718. backUVs?: Vector4;
  61719. instance?: Mesh;
  61720. invertUV?: boolean;
  61721. uvs?: Vector2[];
  61722. colors?: Color4[];
  61723. }, scene?: Nullable<Scene>): Mesh;
  61724. /**
  61725. * Creates a cylinder or a cone mesh
  61726. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61727. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61728. * * 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.
  61729. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61730. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61731. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61732. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61733. * * 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).
  61734. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61735. * * 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).
  61736. * * 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
  61737. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61738. * * 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
  61739. * * 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.
  61740. * * If `enclose` is false, a ring surface is one element.
  61741. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61742. * * 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
  61743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61744. * * 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
  61745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61746. * @param name defines the name of the mesh
  61747. * @param options defines the options used to create the mesh
  61748. * @param scene defines the hosting scene
  61749. * @returns the cylinder mesh
  61750. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61751. */
  61752. static CreateCylinder(name: string, options: {
  61753. height?: number;
  61754. diameterTop?: number;
  61755. diameterBottom?: number;
  61756. diameter?: number;
  61757. tessellation?: number;
  61758. subdivisions?: number;
  61759. arc?: number;
  61760. faceColors?: Color4[];
  61761. faceUV?: Vector4[];
  61762. updatable?: boolean;
  61763. hasRings?: boolean;
  61764. enclose?: boolean;
  61765. cap?: number;
  61766. sideOrientation?: number;
  61767. frontUVs?: Vector4;
  61768. backUVs?: Vector4;
  61769. }, scene?: Nullable<Scene>): Mesh;
  61770. /**
  61771. * Creates a torus mesh
  61772. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61773. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61774. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61776. * * 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
  61777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61778. * @param name defines the name of the mesh
  61779. * @param options defines the options used to create the mesh
  61780. * @param scene defines the hosting scene
  61781. * @returns the torus mesh
  61782. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61783. */
  61784. static CreateTorus(name: string, options: {
  61785. diameter?: number;
  61786. thickness?: number;
  61787. tessellation?: number;
  61788. updatable?: boolean;
  61789. sideOrientation?: number;
  61790. frontUVs?: Vector4;
  61791. backUVs?: Vector4;
  61792. }, scene?: Nullable<Scene>): Mesh;
  61793. /**
  61794. * Creates a torus knot mesh
  61795. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61796. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61797. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61798. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61800. * * 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
  61801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61802. * @param name defines the name of the mesh
  61803. * @param options defines the options used to create the mesh
  61804. * @param scene defines the hosting scene
  61805. * @returns the torus knot mesh
  61806. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61807. */
  61808. static CreateTorusKnot(name: string, options: {
  61809. radius?: number;
  61810. tube?: number;
  61811. radialSegments?: number;
  61812. tubularSegments?: number;
  61813. p?: number;
  61814. q?: number;
  61815. updatable?: boolean;
  61816. sideOrientation?: number;
  61817. frontUVs?: Vector4;
  61818. backUVs?: Vector4;
  61819. }, scene?: Nullable<Scene>): Mesh;
  61820. /**
  61821. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61822. * * 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
  61823. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61824. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61825. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61826. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61827. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61828. * * 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
  61829. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61832. * @param name defines the name of the new line system
  61833. * @param options defines the options used to create the line system
  61834. * @param scene defines the hosting scene
  61835. * @returns a new line system mesh
  61836. */
  61837. static CreateLineSystem(name: string, options: {
  61838. lines: Vector3[][];
  61839. updatable?: boolean;
  61840. instance?: Nullable<LinesMesh>;
  61841. colors?: Nullable<Color4[][]>;
  61842. useVertexAlpha?: boolean;
  61843. }, scene: Nullable<Scene>): LinesMesh;
  61844. /**
  61845. * Creates a line mesh
  61846. * 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
  61847. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61848. * * The parameter `points` is an array successive Vector3
  61849. * * 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
  61850. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61851. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61852. * * When updating an instance, remember that only point positions can change, not the number of points
  61853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61855. * @param name defines the name of the new line system
  61856. * @param options defines the options used to create the line system
  61857. * @param scene defines the hosting scene
  61858. * @returns a new line mesh
  61859. */
  61860. static CreateLines(name: string, options: {
  61861. points: Vector3[];
  61862. updatable?: boolean;
  61863. instance?: Nullable<LinesMesh>;
  61864. colors?: Color4[];
  61865. useVertexAlpha?: boolean;
  61866. }, scene?: Nullable<Scene>): LinesMesh;
  61867. /**
  61868. * Creates a dashed line mesh
  61869. * * 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
  61870. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61871. * * The parameter `points` is an array successive Vector3
  61872. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61873. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61874. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61875. * * 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
  61876. * * When updating an instance, remember that only point positions can change, not the number of points
  61877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61878. * @param name defines the name of the mesh
  61879. * @param options defines the options used to create the mesh
  61880. * @param scene defines the hosting scene
  61881. * @returns the dashed line mesh
  61882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61883. */
  61884. static CreateDashedLines(name: string, options: {
  61885. points: Vector3[];
  61886. dashSize?: number;
  61887. gapSize?: number;
  61888. dashNb?: number;
  61889. updatable?: boolean;
  61890. instance?: LinesMesh;
  61891. }, scene?: Nullable<Scene>): LinesMesh;
  61892. /**
  61893. * 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.
  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 `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.
  61897. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61898. * * 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
  61899. * * 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
  61900. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61902. * * 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
  61903. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61905. * @param name defines the name of the mesh
  61906. * @param options defines the options used to create the mesh
  61907. * @param scene defines the hosting scene
  61908. * @returns the extruded shape mesh
  61909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61911. */
  61912. static ExtrudeShape(name: string, options: {
  61913. shape: Vector3[];
  61914. path: Vector3[];
  61915. scale?: number;
  61916. rotation?: number;
  61917. cap?: number;
  61918. updatable?: boolean;
  61919. sideOrientation?: number;
  61920. frontUVs?: Vector4;
  61921. backUVs?: Vector4;
  61922. instance?: Mesh;
  61923. invertUV?: boolean;
  61924. }, scene?: Nullable<Scene>): Mesh;
  61925. /**
  61926. * Creates an custom extruded shape mesh.
  61927. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61928. * * 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.
  61929. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61930. * * 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
  61931. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61932. * * 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
  61933. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61934. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61935. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61936. * * 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
  61937. * * 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
  61938. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61940. * * 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
  61941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61943. * @param name defines the name of the mesh
  61944. * @param options defines the options used to create the mesh
  61945. * @param scene defines the hosting scene
  61946. * @returns the custom extruded shape mesh
  61947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61950. */
  61951. static ExtrudeShapeCustom(name: string, options: {
  61952. shape: Vector3[];
  61953. path: Vector3[];
  61954. scaleFunction?: any;
  61955. rotationFunction?: any;
  61956. ribbonCloseArray?: boolean;
  61957. ribbonClosePath?: boolean;
  61958. cap?: number;
  61959. updatable?: boolean;
  61960. sideOrientation?: number;
  61961. frontUVs?: Vector4;
  61962. backUVs?: Vector4;
  61963. instance?: Mesh;
  61964. invertUV?: boolean;
  61965. }, scene?: Nullable<Scene>): Mesh;
  61966. /**
  61967. * Creates lathe mesh.
  61968. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61969. * * 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
  61970. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61971. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61972. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61973. * * 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
  61974. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61975. * * 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
  61976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61977. * * 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
  61978. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61980. * @param name defines the name of the mesh
  61981. * @param options defines the options used to create the mesh
  61982. * @param scene defines the hosting scene
  61983. * @returns the lathe mesh
  61984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61985. */
  61986. static CreateLathe(name: string, options: {
  61987. shape: Vector3[];
  61988. radius?: number;
  61989. tessellation?: number;
  61990. clip?: number;
  61991. arc?: number;
  61992. closed?: boolean;
  61993. updatable?: boolean;
  61994. sideOrientation?: number;
  61995. frontUVs?: Vector4;
  61996. backUVs?: Vector4;
  61997. cap?: number;
  61998. invertUV?: boolean;
  61999. }, scene?: Nullable<Scene>): Mesh;
  62000. /**
  62001. * Creates a tiled plane mesh
  62002. * * You can set a limited pattern arrangement with the tiles
  62003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62004. * * 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
  62005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62006. * @param name defines the name of the mesh
  62007. * @param options defines the options used to create the mesh
  62008. * @param scene defines the hosting scene
  62009. * @returns the plane mesh
  62010. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62011. */
  62012. static CreateTiledPlane(name: string, options: {
  62013. pattern?: number;
  62014. tileSize?: number;
  62015. tileWidth?: number;
  62016. tileHeight?: number;
  62017. size?: number;
  62018. width?: number;
  62019. height?: number;
  62020. alignHorizontal?: number;
  62021. alignVertical?: number;
  62022. sideOrientation?: number;
  62023. frontUVs?: Vector4;
  62024. backUVs?: Vector4;
  62025. updatable?: boolean;
  62026. }, scene?: Nullable<Scene>): Mesh;
  62027. /**
  62028. * Creates a plane mesh
  62029. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62030. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62031. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62033. * * 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
  62034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62035. * @param name defines the name of the mesh
  62036. * @param options defines the options used to create the mesh
  62037. * @param scene defines the hosting scene
  62038. * @returns the plane mesh
  62039. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62040. */
  62041. static CreatePlane(name: string, options: {
  62042. size?: number;
  62043. width?: number;
  62044. height?: number;
  62045. sideOrientation?: number;
  62046. frontUVs?: Vector4;
  62047. backUVs?: Vector4;
  62048. updatable?: boolean;
  62049. sourcePlane?: Plane;
  62050. }, scene?: Nullable<Scene>): Mesh;
  62051. /**
  62052. * Creates a ground mesh
  62053. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62054. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62056. * @param name defines the name of the mesh
  62057. * @param options defines the options used to create the mesh
  62058. * @param scene defines the hosting scene
  62059. * @returns the ground mesh
  62060. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62061. */
  62062. static CreateGround(name: string, options: {
  62063. width?: number;
  62064. height?: number;
  62065. subdivisions?: number;
  62066. subdivisionsX?: number;
  62067. subdivisionsY?: number;
  62068. updatable?: boolean;
  62069. }, scene?: Nullable<Scene>): Mesh;
  62070. /**
  62071. * Creates a tiled ground mesh
  62072. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62073. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62074. * * 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
  62075. * * 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
  62076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62077. * @param name defines the name of the mesh
  62078. * @param options defines the options used to create the mesh
  62079. * @param scene defines the hosting scene
  62080. * @returns the tiled ground mesh
  62081. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62082. */
  62083. static CreateTiledGround(name: string, options: {
  62084. xmin: number;
  62085. zmin: number;
  62086. xmax: number;
  62087. zmax: number;
  62088. subdivisions?: {
  62089. w: number;
  62090. h: number;
  62091. };
  62092. precision?: {
  62093. w: number;
  62094. h: number;
  62095. };
  62096. updatable?: boolean;
  62097. }, scene?: Nullable<Scene>): Mesh;
  62098. /**
  62099. * Creates a ground mesh from a height map
  62100. * * The parameter `url` sets the URL of the height map image resource.
  62101. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62102. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62103. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62104. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62105. * * 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.
  62106. * * 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).
  62107. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62109. * @param name defines the name of the mesh
  62110. * @param url defines the url to the height map
  62111. * @param options defines the options used to create the mesh
  62112. * @param scene defines the hosting scene
  62113. * @returns the ground mesh
  62114. * @see https://doc.babylonjs.com/babylon101/height_map
  62115. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62116. */
  62117. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62118. width?: number;
  62119. height?: number;
  62120. subdivisions?: number;
  62121. minHeight?: number;
  62122. maxHeight?: number;
  62123. colorFilter?: Color3;
  62124. alphaFilter?: number;
  62125. updatable?: boolean;
  62126. onReady?: (mesh: GroundMesh) => void;
  62127. }, scene?: Nullable<Scene>): GroundMesh;
  62128. /**
  62129. * Creates a polygon mesh
  62130. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62131. * * 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
  62132. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62134. * * 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)
  62135. * * Remember you can only change the shape positions, not their number when updating a polygon
  62136. * @param name defines the name of the mesh
  62137. * @param options defines the options used to create the mesh
  62138. * @param scene defines the hosting scene
  62139. * @param earcutInjection can be used to inject your own earcut reference
  62140. * @returns the polygon mesh
  62141. */
  62142. static CreatePolygon(name: string, options: {
  62143. shape: Vector3[];
  62144. holes?: Vector3[][];
  62145. depth?: number;
  62146. faceUV?: Vector4[];
  62147. faceColors?: Color4[];
  62148. updatable?: boolean;
  62149. sideOrientation?: number;
  62150. frontUVs?: Vector4;
  62151. backUVs?: Vector4;
  62152. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62153. /**
  62154. * Creates an extruded polygon mesh, with depth in the Y direction.
  62155. * * 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)
  62156. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62157. * @param name defines the name of the mesh
  62158. * @param options defines the options used to create the mesh
  62159. * @param scene defines the hosting scene
  62160. * @param earcutInjection can be used to inject your own earcut reference
  62161. * @returns the polygon mesh
  62162. */
  62163. static ExtrudePolygon(name: string, options: {
  62164. shape: Vector3[];
  62165. holes?: Vector3[][];
  62166. depth?: number;
  62167. faceUV?: Vector4[];
  62168. faceColors?: Color4[];
  62169. updatable?: boolean;
  62170. sideOrientation?: number;
  62171. frontUVs?: Vector4;
  62172. backUVs?: Vector4;
  62173. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62174. /**
  62175. * Creates a tube mesh.
  62176. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62177. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62178. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62179. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62180. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62181. * * 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)
  62182. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62183. * * 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
  62184. * * 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
  62185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62186. * * 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
  62187. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62189. * @param name defines the name of the mesh
  62190. * @param options defines the options used to create the mesh
  62191. * @param scene defines the hosting scene
  62192. * @returns the tube mesh
  62193. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62194. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62195. */
  62196. static CreateTube(name: string, options: {
  62197. path: Vector3[];
  62198. radius?: number;
  62199. tessellation?: number;
  62200. radiusFunction?: {
  62201. (i: number, distance: number): number;
  62202. };
  62203. cap?: number;
  62204. arc?: number;
  62205. updatable?: boolean;
  62206. sideOrientation?: number;
  62207. frontUVs?: Vector4;
  62208. backUVs?: Vector4;
  62209. instance?: Mesh;
  62210. invertUV?: boolean;
  62211. }, scene?: Nullable<Scene>): Mesh;
  62212. /**
  62213. * Creates a polyhedron mesh
  62214. * * 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
  62215. * * The parameter `size` (positive float, default 1) sets the polygon size
  62216. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62217. * * 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`
  62218. * * 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
  62219. * * 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)`)
  62220. * * 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
  62221. * * 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
  62222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62223. * * 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
  62224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62225. * @param name defines the name of the mesh
  62226. * @param options defines the options used to create the mesh
  62227. * @param scene defines the hosting scene
  62228. * @returns the polyhedron mesh
  62229. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62230. */
  62231. static CreatePolyhedron(name: string, options: {
  62232. type?: number;
  62233. size?: number;
  62234. sizeX?: number;
  62235. sizeY?: number;
  62236. sizeZ?: number;
  62237. custom?: any;
  62238. faceUV?: Vector4[];
  62239. faceColors?: Color4[];
  62240. flat?: boolean;
  62241. updatable?: boolean;
  62242. sideOrientation?: number;
  62243. frontUVs?: Vector4;
  62244. backUVs?: Vector4;
  62245. }, scene?: Nullable<Scene>): Mesh;
  62246. /**
  62247. * Creates a decal mesh.
  62248. * 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
  62249. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62250. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62251. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62252. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62253. * @param name defines the name of the mesh
  62254. * @param sourceMesh defines the mesh where the decal must be applied
  62255. * @param options defines the options used to create the mesh
  62256. * @param scene defines the hosting scene
  62257. * @returns the decal mesh
  62258. * @see https://doc.babylonjs.com/how_to/decals
  62259. */
  62260. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62261. position?: Vector3;
  62262. normal?: Vector3;
  62263. size?: Vector3;
  62264. angle?: number;
  62265. }): Mesh;
  62266. }
  62267. }
  62268. declare module BABYLON {
  62269. /**
  62270. * A simplifier interface for future simplification implementations
  62271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62272. */
  62273. export interface ISimplifier {
  62274. /**
  62275. * Simplification of a given mesh according to the given settings.
  62276. * Since this requires computation, it is assumed that the function runs async.
  62277. * @param settings The settings of the simplification, including quality and distance
  62278. * @param successCallback A callback that will be called after the mesh was simplified.
  62279. * @param errorCallback in case of an error, this callback will be called. optional.
  62280. */
  62281. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62282. }
  62283. /**
  62284. * Expected simplification settings.
  62285. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62286. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62287. */
  62288. export interface ISimplificationSettings {
  62289. /**
  62290. * Gets or sets the expected quality
  62291. */
  62292. quality: number;
  62293. /**
  62294. * Gets or sets the distance when this optimized version should be used
  62295. */
  62296. distance: number;
  62297. /**
  62298. * Gets an already optimized mesh
  62299. */
  62300. optimizeMesh?: boolean;
  62301. }
  62302. /**
  62303. * Class used to specify simplification options
  62304. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62305. */
  62306. export class SimplificationSettings implements ISimplificationSettings {
  62307. /** expected quality */
  62308. quality: number;
  62309. /** distance when this optimized version should be used */
  62310. distance: number;
  62311. /** already optimized mesh */
  62312. optimizeMesh?: boolean | undefined;
  62313. /**
  62314. * Creates a SimplificationSettings
  62315. * @param quality expected quality
  62316. * @param distance distance when this optimized version should be used
  62317. * @param optimizeMesh already optimized mesh
  62318. */
  62319. constructor(
  62320. /** expected quality */
  62321. quality: number,
  62322. /** distance when this optimized version should be used */
  62323. distance: number,
  62324. /** already optimized mesh */
  62325. optimizeMesh?: boolean | undefined);
  62326. }
  62327. /**
  62328. * Interface used to define a simplification task
  62329. */
  62330. export interface ISimplificationTask {
  62331. /**
  62332. * Array of settings
  62333. */
  62334. settings: Array<ISimplificationSettings>;
  62335. /**
  62336. * Simplification type
  62337. */
  62338. simplificationType: SimplificationType;
  62339. /**
  62340. * Mesh to simplify
  62341. */
  62342. mesh: Mesh;
  62343. /**
  62344. * Callback called on success
  62345. */
  62346. successCallback?: () => void;
  62347. /**
  62348. * Defines if parallel processing can be used
  62349. */
  62350. parallelProcessing: boolean;
  62351. }
  62352. /**
  62353. * Queue used to order the simplification tasks
  62354. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62355. */
  62356. export class SimplificationQueue {
  62357. private _simplificationArray;
  62358. /**
  62359. * Gets a boolean indicating that the process is still running
  62360. */
  62361. running: boolean;
  62362. /**
  62363. * Creates a new queue
  62364. */
  62365. constructor();
  62366. /**
  62367. * Adds a new simplification task
  62368. * @param task defines a task to add
  62369. */
  62370. addTask(task: ISimplificationTask): void;
  62371. /**
  62372. * Execute next task
  62373. */
  62374. executeNext(): void;
  62375. /**
  62376. * Execute a simplification task
  62377. * @param task defines the task to run
  62378. */
  62379. runSimplification(task: ISimplificationTask): void;
  62380. private getSimplifier;
  62381. }
  62382. /**
  62383. * The implemented types of simplification
  62384. * At the moment only Quadratic Error Decimation is implemented
  62385. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62386. */
  62387. export enum SimplificationType {
  62388. /** Quadratic error decimation */
  62389. QUADRATIC = 0
  62390. }
  62391. /**
  62392. * An implementation of the Quadratic Error simplification algorithm.
  62393. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62394. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62395. * @author RaananW
  62396. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62397. */
  62398. export class QuadraticErrorSimplification implements ISimplifier {
  62399. private _mesh;
  62400. private triangles;
  62401. private vertices;
  62402. private references;
  62403. private _reconstructedMesh;
  62404. /** Gets or sets the number pf sync interations */
  62405. syncIterations: number;
  62406. /** Gets or sets the aggressiveness of the simplifier */
  62407. aggressiveness: number;
  62408. /** Gets or sets the number of allowed iterations for decimation */
  62409. decimationIterations: number;
  62410. /** Gets or sets the espilon to use for bounding box computation */
  62411. boundingBoxEpsilon: number;
  62412. /**
  62413. * Creates a new QuadraticErrorSimplification
  62414. * @param _mesh defines the target mesh
  62415. */
  62416. constructor(_mesh: Mesh);
  62417. /**
  62418. * Simplification of a given mesh according to the given settings.
  62419. * Since this requires computation, it is assumed that the function runs async.
  62420. * @param settings The settings of the simplification, including quality and distance
  62421. * @param successCallback A callback that will be called after the mesh was simplified.
  62422. */
  62423. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62424. private runDecimation;
  62425. private initWithMesh;
  62426. private init;
  62427. private reconstructMesh;
  62428. private initDecimatedMesh;
  62429. private isFlipped;
  62430. private updateTriangles;
  62431. private identifyBorder;
  62432. private updateMesh;
  62433. private vertexError;
  62434. private calculateError;
  62435. }
  62436. }
  62437. declare module BABYLON {
  62438. interface Scene {
  62439. /** @hidden (Backing field) */
  62440. _simplificationQueue: SimplificationQueue;
  62441. /**
  62442. * Gets or sets the simplification queue attached to the scene
  62443. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62444. */
  62445. simplificationQueue: SimplificationQueue;
  62446. }
  62447. interface Mesh {
  62448. /**
  62449. * Simplify the mesh according to the given array of settings.
  62450. * Function will return immediately and will simplify async
  62451. * @param settings a collection of simplification settings
  62452. * @param parallelProcessing should all levels calculate parallel or one after the other
  62453. * @param simplificationType the type of simplification to run
  62454. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62455. * @returns the current mesh
  62456. */
  62457. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62458. }
  62459. /**
  62460. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62461. * created in a scene
  62462. */
  62463. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62464. /**
  62465. * The component name helpfull to identify the component in the list of scene components.
  62466. */
  62467. readonly name: string;
  62468. /**
  62469. * The scene the component belongs to.
  62470. */
  62471. scene: Scene;
  62472. /**
  62473. * Creates a new instance of the component for the given scene
  62474. * @param scene Defines the scene to register the component in
  62475. */
  62476. constructor(scene: Scene);
  62477. /**
  62478. * Registers the component in a given scene
  62479. */
  62480. register(): void;
  62481. /**
  62482. * Rebuilds the elements related to this component in case of
  62483. * context lost for instance.
  62484. */
  62485. rebuild(): void;
  62486. /**
  62487. * Disposes the component and the associated ressources
  62488. */
  62489. dispose(): void;
  62490. private _beforeCameraUpdate;
  62491. }
  62492. }
  62493. declare module BABYLON {
  62494. /**
  62495. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62496. */
  62497. export interface INavigationEnginePlugin {
  62498. /**
  62499. * plugin name
  62500. */
  62501. name: string;
  62502. /**
  62503. * Creates a navigation mesh
  62504. * @param meshes array of all the geometry used to compute the navigatio mesh
  62505. * @param parameters bunch of parameters used to filter geometry
  62506. */
  62507. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62508. /**
  62509. * Create a navigation mesh debug mesh
  62510. * @param scene is where the mesh will be added
  62511. * @returns debug display mesh
  62512. */
  62513. createDebugNavMesh(scene: Scene): Mesh;
  62514. /**
  62515. * Get a navigation mesh constrained position, closest to the parameter position
  62516. * @param position world position
  62517. * @returns the closest point to position constrained by the navigation mesh
  62518. */
  62519. getClosestPoint(position: Vector3): Vector3;
  62520. /**
  62521. * Get a navigation mesh constrained position, closest to the parameter position
  62522. * @param position world position
  62523. * @param result output the closest point to position constrained by the navigation mesh
  62524. */
  62525. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62526. /**
  62527. * Get a navigation mesh constrained position, within a particular radius
  62528. * @param position world position
  62529. * @param maxRadius the maximum distance to the constrained world position
  62530. * @returns the closest point to position constrained by the navigation mesh
  62531. */
  62532. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62533. /**
  62534. * Get a navigation mesh constrained position, within a particular radius
  62535. * @param position world position
  62536. * @param maxRadius the maximum distance to the constrained world position
  62537. * @param result output the closest point to position constrained by the navigation mesh
  62538. */
  62539. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62540. /**
  62541. * Compute the final position from a segment made of destination-position
  62542. * @param position world position
  62543. * @param destination world position
  62544. * @returns the resulting point along the navmesh
  62545. */
  62546. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62547. /**
  62548. * Compute the final position from a segment made of destination-position
  62549. * @param position world position
  62550. * @param destination world position
  62551. * @param result output the resulting point along the navmesh
  62552. */
  62553. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62554. /**
  62555. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62556. * @param start world position
  62557. * @param end world position
  62558. * @returns array containing world position composing the path
  62559. */
  62560. computePath(start: Vector3, end: Vector3): Vector3[];
  62561. /**
  62562. * If this plugin is supported
  62563. * @returns true if plugin is supported
  62564. */
  62565. isSupported(): boolean;
  62566. /**
  62567. * Create a new Crowd so you can add agents
  62568. * @param maxAgents the maximum agent count in the crowd
  62569. * @param maxAgentRadius the maximum radius an agent can have
  62570. * @param scene to attach the crowd to
  62571. * @returns the crowd you can add agents to
  62572. */
  62573. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62574. /**
  62575. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62576. * The queries will try to find a solution within those bounds
  62577. * default is (1,1,1)
  62578. * @param extent x,y,z value that define the extent around the queries point of reference
  62579. */
  62580. setDefaultQueryExtent(extent: Vector3): void;
  62581. /**
  62582. * Get the Bounding box extent specified by setDefaultQueryExtent
  62583. * @returns the box extent values
  62584. */
  62585. getDefaultQueryExtent(): Vector3;
  62586. /**
  62587. * build the navmesh from a previously saved state using getNavmeshData
  62588. * @param data the Uint8Array returned by getNavmeshData
  62589. */
  62590. buildFromNavmeshData(data: Uint8Array): void;
  62591. /**
  62592. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62593. * @returns data the Uint8Array that can be saved and reused
  62594. */
  62595. getNavmeshData(): Uint8Array;
  62596. /**
  62597. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62598. * @param result output the box extent values
  62599. */
  62600. getDefaultQueryExtentToRef(result: Vector3): void;
  62601. /**
  62602. * Release all resources
  62603. */
  62604. dispose(): void;
  62605. }
  62606. /**
  62607. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62608. */
  62609. export interface ICrowd {
  62610. /**
  62611. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62612. * You can attach anything to that node. The node position is updated in the scene update tick.
  62613. * @param pos world position that will be constrained by the navigation mesh
  62614. * @param parameters agent parameters
  62615. * @param transform hooked to the agent that will be update by the scene
  62616. * @returns agent index
  62617. */
  62618. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62619. /**
  62620. * Returns the agent position in world space
  62621. * @param index agent index returned by addAgent
  62622. * @returns world space position
  62623. */
  62624. getAgentPosition(index: number): Vector3;
  62625. /**
  62626. * Gets the agent position result in world space
  62627. * @param index agent index returned by addAgent
  62628. * @param result output world space position
  62629. */
  62630. getAgentPositionToRef(index: number, result: Vector3): void;
  62631. /**
  62632. * Gets the agent velocity in world space
  62633. * @param index agent index returned by addAgent
  62634. * @returns world space velocity
  62635. */
  62636. getAgentVelocity(index: number): Vector3;
  62637. /**
  62638. * Gets the agent velocity result in world space
  62639. * @param index agent index returned by addAgent
  62640. * @param result output world space velocity
  62641. */
  62642. getAgentVelocityToRef(index: number, result: Vector3): void;
  62643. /**
  62644. * remove a particular agent previously created
  62645. * @param index agent index returned by addAgent
  62646. */
  62647. removeAgent(index: number): void;
  62648. /**
  62649. * get the list of all agents attached to this crowd
  62650. * @returns list of agent indices
  62651. */
  62652. getAgents(): number[];
  62653. /**
  62654. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62655. * @param deltaTime in seconds
  62656. */
  62657. update(deltaTime: number): void;
  62658. /**
  62659. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62660. * @param index agent index returned by addAgent
  62661. * @param destination targeted world position
  62662. */
  62663. agentGoto(index: number, destination: Vector3): void;
  62664. /**
  62665. * Teleport the agent to a new position
  62666. * @param index agent index returned by addAgent
  62667. * @param destination targeted world position
  62668. */
  62669. agentTeleport(index: number, destination: Vector3): void;
  62670. /**
  62671. * Update agent parameters
  62672. * @param index agent index returned by addAgent
  62673. * @param parameters agent parameters
  62674. */
  62675. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62676. /**
  62677. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62678. * The queries will try to find a solution within those bounds
  62679. * default is (1,1,1)
  62680. * @param extent x,y,z value that define the extent around the queries point of reference
  62681. */
  62682. setDefaultQueryExtent(extent: Vector3): void;
  62683. /**
  62684. * Get the Bounding box extent specified by setDefaultQueryExtent
  62685. * @returns the box extent values
  62686. */
  62687. getDefaultQueryExtent(): Vector3;
  62688. /**
  62689. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62690. * @param result output the box extent values
  62691. */
  62692. getDefaultQueryExtentToRef(result: Vector3): void;
  62693. /**
  62694. * Release all resources
  62695. */
  62696. dispose(): void;
  62697. }
  62698. /**
  62699. * Configures an agent
  62700. */
  62701. export interface IAgentParameters {
  62702. /**
  62703. * Agent radius. [Limit: >= 0]
  62704. */
  62705. radius: number;
  62706. /**
  62707. * Agent height. [Limit: > 0]
  62708. */
  62709. height: number;
  62710. /**
  62711. * Maximum allowed acceleration. [Limit: >= 0]
  62712. */
  62713. maxAcceleration: number;
  62714. /**
  62715. * Maximum allowed speed. [Limit: >= 0]
  62716. */
  62717. maxSpeed: number;
  62718. /**
  62719. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62720. */
  62721. collisionQueryRange: number;
  62722. /**
  62723. * The path visibility optimization range. [Limit: > 0]
  62724. */
  62725. pathOptimizationRange: number;
  62726. /**
  62727. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62728. */
  62729. separationWeight: number;
  62730. }
  62731. /**
  62732. * Configures the navigation mesh creation
  62733. */
  62734. export interface INavMeshParameters {
  62735. /**
  62736. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62737. */
  62738. cs: number;
  62739. /**
  62740. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62741. */
  62742. ch: number;
  62743. /**
  62744. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62745. */
  62746. walkableSlopeAngle: number;
  62747. /**
  62748. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62749. * be considered walkable. [Limit: >= 3] [Units: vx]
  62750. */
  62751. walkableHeight: number;
  62752. /**
  62753. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62754. */
  62755. walkableClimb: number;
  62756. /**
  62757. * The distance to erode/shrink the walkable area of the heightfield away from
  62758. * obstructions. [Limit: >=0] [Units: vx]
  62759. */
  62760. walkableRadius: number;
  62761. /**
  62762. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62763. */
  62764. maxEdgeLen: number;
  62765. /**
  62766. * The maximum distance a simplfied contour's border edges should deviate
  62767. * the original raw contour. [Limit: >=0] [Units: vx]
  62768. */
  62769. maxSimplificationError: number;
  62770. /**
  62771. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62772. */
  62773. minRegionArea: number;
  62774. /**
  62775. * Any regions with a span count smaller than this value will, if possible,
  62776. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62777. */
  62778. mergeRegionArea: number;
  62779. /**
  62780. * The maximum number of vertices allowed for polygons generated during the
  62781. * contour to polygon conversion process. [Limit: >= 3]
  62782. */
  62783. maxVertsPerPoly: number;
  62784. /**
  62785. * Sets the sampling distance to use when generating the detail mesh.
  62786. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62787. */
  62788. detailSampleDist: number;
  62789. /**
  62790. * The maximum distance the detail mesh surface should deviate from heightfield
  62791. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62792. */
  62793. detailSampleMaxError: number;
  62794. }
  62795. }
  62796. declare module BABYLON {
  62797. /**
  62798. * RecastJS navigation plugin
  62799. */
  62800. export class RecastJSPlugin implements INavigationEnginePlugin {
  62801. /**
  62802. * Reference to the Recast library
  62803. */
  62804. bjsRECAST: any;
  62805. /**
  62806. * plugin name
  62807. */
  62808. name: string;
  62809. /**
  62810. * the first navmesh created. We might extend this to support multiple navmeshes
  62811. */
  62812. navMesh: any;
  62813. /**
  62814. * Initializes the recastJS plugin
  62815. * @param recastInjection can be used to inject your own recast reference
  62816. */
  62817. constructor(recastInjection?: any);
  62818. /**
  62819. * Creates a navigation mesh
  62820. * @param meshes array of all the geometry used to compute the navigatio mesh
  62821. * @param parameters bunch of parameters used to filter geometry
  62822. */
  62823. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62824. /**
  62825. * Create a navigation mesh debug mesh
  62826. * @param scene is where the mesh will be added
  62827. * @returns debug display mesh
  62828. */
  62829. createDebugNavMesh(scene: Scene): Mesh;
  62830. /**
  62831. * Get a navigation mesh constrained position, closest to the parameter position
  62832. * @param position world position
  62833. * @returns the closest point to position constrained by the navigation mesh
  62834. */
  62835. getClosestPoint(position: Vector3): Vector3;
  62836. /**
  62837. * Get a navigation mesh constrained position, closest to the parameter position
  62838. * @param position world position
  62839. * @param result output the closest point to position constrained by the navigation mesh
  62840. */
  62841. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62842. /**
  62843. * Get a navigation mesh constrained position, within a particular radius
  62844. * @param position world position
  62845. * @param maxRadius the maximum distance to the constrained world position
  62846. * @returns the closest point to position constrained by the navigation mesh
  62847. */
  62848. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62849. /**
  62850. * Get a navigation mesh constrained position, within a particular radius
  62851. * @param position world position
  62852. * @param maxRadius the maximum distance to the constrained world position
  62853. * @param result output the closest point to position constrained by the navigation mesh
  62854. */
  62855. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62856. /**
  62857. * Compute the final position from a segment made of destination-position
  62858. * @param position world position
  62859. * @param destination world position
  62860. * @returns the resulting point along the navmesh
  62861. */
  62862. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62863. /**
  62864. * Compute the final position from a segment made of destination-position
  62865. * @param position world position
  62866. * @param destination world position
  62867. * @param result output the resulting point along the navmesh
  62868. */
  62869. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62870. /**
  62871. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62872. * @param start world position
  62873. * @param end world position
  62874. * @returns array containing world position composing the path
  62875. */
  62876. computePath(start: Vector3, end: Vector3): Vector3[];
  62877. /**
  62878. * Create a new Crowd so you can add agents
  62879. * @param maxAgents the maximum agent count in the crowd
  62880. * @param maxAgentRadius the maximum radius an agent can have
  62881. * @param scene to attach the crowd to
  62882. * @returns the crowd you can add agents to
  62883. */
  62884. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62885. /**
  62886. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62887. * The queries will try to find a solution within those bounds
  62888. * default is (1,1,1)
  62889. * @param extent x,y,z value that define the extent around the queries point of reference
  62890. */
  62891. setDefaultQueryExtent(extent: Vector3): void;
  62892. /**
  62893. * Get the Bounding box extent specified by setDefaultQueryExtent
  62894. * @returns the box extent values
  62895. */
  62896. getDefaultQueryExtent(): Vector3;
  62897. /**
  62898. * build the navmesh from a previously saved state using getNavmeshData
  62899. * @param data the Uint8Array returned by getNavmeshData
  62900. */
  62901. buildFromNavmeshData(data: Uint8Array): void;
  62902. /**
  62903. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62904. * @returns data the Uint8Array that can be saved and reused
  62905. */
  62906. getNavmeshData(): Uint8Array;
  62907. /**
  62908. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62909. * @param result output the box extent values
  62910. */
  62911. getDefaultQueryExtentToRef(result: Vector3): void;
  62912. /**
  62913. * Disposes
  62914. */
  62915. dispose(): void;
  62916. /**
  62917. * If this plugin is supported
  62918. * @returns true if plugin is supported
  62919. */
  62920. isSupported(): boolean;
  62921. }
  62922. /**
  62923. * Recast detour crowd implementation
  62924. */
  62925. export class RecastJSCrowd implements ICrowd {
  62926. /**
  62927. * Recast/detour plugin
  62928. */
  62929. bjsRECASTPlugin: RecastJSPlugin;
  62930. /**
  62931. * Link to the detour crowd
  62932. */
  62933. recastCrowd: any;
  62934. /**
  62935. * One transform per agent
  62936. */
  62937. transforms: TransformNode[];
  62938. /**
  62939. * All agents created
  62940. */
  62941. agents: number[];
  62942. /**
  62943. * Link to the scene is kept to unregister the crowd from the scene
  62944. */
  62945. private _scene;
  62946. /**
  62947. * Observer for crowd updates
  62948. */
  62949. private _onBeforeAnimationsObserver;
  62950. /**
  62951. * Constructor
  62952. * @param plugin recastJS plugin
  62953. * @param maxAgents the maximum agent count in the crowd
  62954. * @param maxAgentRadius the maximum radius an agent can have
  62955. * @param scene to attach the crowd to
  62956. * @returns the crowd you can add agents to
  62957. */
  62958. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62959. /**
  62960. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62961. * You can attach anything to that node. The node position is updated in the scene update tick.
  62962. * @param pos world position that will be constrained by the navigation mesh
  62963. * @param parameters agent parameters
  62964. * @param transform hooked to the agent that will be update by the scene
  62965. * @returns agent index
  62966. */
  62967. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62968. /**
  62969. * Returns the agent position in world space
  62970. * @param index agent index returned by addAgent
  62971. * @returns world space position
  62972. */
  62973. getAgentPosition(index: number): Vector3;
  62974. /**
  62975. * Returns the agent position result in world space
  62976. * @param index agent index returned by addAgent
  62977. * @param result output world space position
  62978. */
  62979. getAgentPositionToRef(index: number, result: Vector3): void;
  62980. /**
  62981. * Returns the agent velocity in world space
  62982. * @param index agent index returned by addAgent
  62983. * @returns world space velocity
  62984. */
  62985. getAgentVelocity(index: number): Vector3;
  62986. /**
  62987. * Returns the agent velocity result in world space
  62988. * @param index agent index returned by addAgent
  62989. * @param result output world space velocity
  62990. */
  62991. getAgentVelocityToRef(index: number, result: Vector3): void;
  62992. /**
  62993. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62994. * @param index agent index returned by addAgent
  62995. * @param destination targeted world position
  62996. */
  62997. agentGoto(index: number, destination: Vector3): void;
  62998. /**
  62999. * Teleport the agent to a new position
  63000. * @param index agent index returned by addAgent
  63001. * @param destination targeted world position
  63002. */
  63003. agentTeleport(index: number, destination: Vector3): void;
  63004. /**
  63005. * Update agent parameters
  63006. * @param index agent index returned by addAgent
  63007. * @param parameters agent parameters
  63008. */
  63009. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63010. /**
  63011. * remove a particular agent previously created
  63012. * @param index agent index returned by addAgent
  63013. */
  63014. removeAgent(index: number): void;
  63015. /**
  63016. * get the list of all agents attached to this crowd
  63017. * @returns list of agent indices
  63018. */
  63019. getAgents(): number[];
  63020. /**
  63021. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63022. * @param deltaTime in seconds
  63023. */
  63024. update(deltaTime: number): void;
  63025. /**
  63026. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63027. * The queries will try to find a solution within those bounds
  63028. * default is (1,1,1)
  63029. * @param extent x,y,z value that define the extent around the queries point of reference
  63030. */
  63031. setDefaultQueryExtent(extent: Vector3): void;
  63032. /**
  63033. * Get the Bounding box extent specified by setDefaultQueryExtent
  63034. * @returns the box extent values
  63035. */
  63036. getDefaultQueryExtent(): Vector3;
  63037. /**
  63038. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63039. * @param result output the box extent values
  63040. */
  63041. getDefaultQueryExtentToRef(result: Vector3): void;
  63042. /**
  63043. * Release all resources
  63044. */
  63045. dispose(): void;
  63046. }
  63047. }
  63048. declare module BABYLON {
  63049. /**
  63050. * Class used to enable access to IndexedDB
  63051. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63052. */
  63053. export class Database implements IOfflineProvider {
  63054. private _callbackManifestChecked;
  63055. private _currentSceneUrl;
  63056. private _db;
  63057. private _enableSceneOffline;
  63058. private _enableTexturesOffline;
  63059. private _manifestVersionFound;
  63060. private _mustUpdateRessources;
  63061. private _hasReachedQuota;
  63062. private _isSupported;
  63063. private _idbFactory;
  63064. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63065. private static IsUASupportingBlobStorage;
  63066. /**
  63067. * Gets a boolean indicating if Database storate is enabled (off by default)
  63068. */
  63069. static IDBStorageEnabled: boolean;
  63070. /**
  63071. * Gets a boolean indicating if scene must be saved in the database
  63072. */
  63073. get enableSceneOffline(): boolean;
  63074. /**
  63075. * Gets a boolean indicating if textures must be saved in the database
  63076. */
  63077. get enableTexturesOffline(): boolean;
  63078. /**
  63079. * Creates a new Database
  63080. * @param urlToScene defines the url to load the scene
  63081. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63082. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63083. */
  63084. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63085. private static _ParseURL;
  63086. private static _ReturnFullUrlLocation;
  63087. private _checkManifestFile;
  63088. /**
  63089. * Open the database and make it available
  63090. * @param successCallback defines the callback to call on success
  63091. * @param errorCallback defines the callback to call on error
  63092. */
  63093. open(successCallback: () => void, errorCallback: () => void): void;
  63094. /**
  63095. * Loads an image from the database
  63096. * @param url defines the url to load from
  63097. * @param image defines the target DOM image
  63098. */
  63099. loadImage(url: string, image: HTMLImageElement): void;
  63100. private _loadImageFromDBAsync;
  63101. private _saveImageIntoDBAsync;
  63102. private _checkVersionFromDB;
  63103. private _loadVersionFromDBAsync;
  63104. private _saveVersionIntoDBAsync;
  63105. /**
  63106. * Loads a file from database
  63107. * @param url defines the URL to load from
  63108. * @param sceneLoaded defines a callback to call on success
  63109. * @param progressCallBack defines a callback to call when progress changed
  63110. * @param errorCallback defines a callback to call on error
  63111. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63112. */
  63113. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63114. private _loadFileAsync;
  63115. private _saveFileAsync;
  63116. /**
  63117. * Validates if xhr data is correct
  63118. * @param xhr defines the request to validate
  63119. * @param dataType defines the expected data type
  63120. * @returns true if data is correct
  63121. */
  63122. private static _ValidateXHRData;
  63123. }
  63124. }
  63125. declare module BABYLON {
  63126. /** @hidden */
  63127. export var gpuUpdateParticlesPixelShader: {
  63128. name: string;
  63129. shader: string;
  63130. };
  63131. }
  63132. declare module BABYLON {
  63133. /** @hidden */
  63134. export var gpuUpdateParticlesVertexShader: {
  63135. name: string;
  63136. shader: string;
  63137. };
  63138. }
  63139. declare module BABYLON {
  63140. /** @hidden */
  63141. export var clipPlaneFragmentDeclaration2: {
  63142. name: string;
  63143. shader: string;
  63144. };
  63145. }
  63146. declare module BABYLON {
  63147. /** @hidden */
  63148. export var gpuRenderParticlesPixelShader: {
  63149. name: string;
  63150. shader: string;
  63151. };
  63152. }
  63153. declare module BABYLON {
  63154. /** @hidden */
  63155. export var clipPlaneVertexDeclaration2: {
  63156. name: string;
  63157. shader: string;
  63158. };
  63159. }
  63160. declare module BABYLON {
  63161. /** @hidden */
  63162. export var gpuRenderParticlesVertexShader: {
  63163. name: string;
  63164. shader: string;
  63165. };
  63166. }
  63167. declare module BABYLON {
  63168. /**
  63169. * This represents a GPU particle system in Babylon
  63170. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63171. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63172. */
  63173. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63174. /**
  63175. * The layer mask we are rendering the particles through.
  63176. */
  63177. layerMask: number;
  63178. private _capacity;
  63179. private _activeCount;
  63180. private _currentActiveCount;
  63181. private _accumulatedCount;
  63182. private _renderEffect;
  63183. private _updateEffect;
  63184. private _buffer0;
  63185. private _buffer1;
  63186. private _spriteBuffer;
  63187. private _updateVAO;
  63188. private _renderVAO;
  63189. private _targetIndex;
  63190. private _sourceBuffer;
  63191. private _targetBuffer;
  63192. private _engine;
  63193. private _currentRenderId;
  63194. private _started;
  63195. private _stopped;
  63196. private _timeDelta;
  63197. private _randomTexture;
  63198. private _randomTexture2;
  63199. private _attributesStrideSize;
  63200. private _updateEffectOptions;
  63201. private _randomTextureSize;
  63202. private _actualFrame;
  63203. private readonly _rawTextureWidth;
  63204. /**
  63205. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63206. */
  63207. static get IsSupported(): boolean;
  63208. /**
  63209. * An event triggered when the system is disposed.
  63210. */
  63211. onDisposeObservable: Observable<GPUParticleSystem>;
  63212. /**
  63213. * Gets the maximum number of particles active at the same time.
  63214. * @returns The max number of active particles.
  63215. */
  63216. getCapacity(): number;
  63217. /**
  63218. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63219. * to override the particles.
  63220. */
  63221. forceDepthWrite: boolean;
  63222. /**
  63223. * Gets or set the number of active particles
  63224. */
  63225. get activeParticleCount(): number;
  63226. set activeParticleCount(value: number);
  63227. private _preWarmDone;
  63228. /**
  63229. * Specifies if the particles are updated in emitter local space or world space.
  63230. * This is always false for GPU particles
  63231. */
  63232. get isLocal(): boolean;
  63233. set isLocal(value: boolean);
  63234. /**
  63235. * Is this system ready to be used/rendered
  63236. * @return true if the system is ready
  63237. */
  63238. isReady(): boolean;
  63239. /**
  63240. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63241. * @returns True if it has been started, otherwise false.
  63242. */
  63243. isStarted(): boolean;
  63244. /**
  63245. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63246. * @returns True if it has been stopped, otherwise false.
  63247. */
  63248. isStopped(): boolean;
  63249. /**
  63250. * Gets a boolean indicating that the system is stopping
  63251. * @returns true if the system is currently stopping
  63252. */
  63253. isStopping(): boolean;
  63254. /**
  63255. * Gets the number of particles active at the same time.
  63256. * @returns The number of active particles.
  63257. */
  63258. getActiveCount(): number;
  63259. /**
  63260. * Starts the particle system and begins to emit
  63261. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63262. */
  63263. start(delay?: number): void;
  63264. /**
  63265. * Stops the particle system.
  63266. */
  63267. stop(): void;
  63268. /**
  63269. * Remove all active particles
  63270. */
  63271. reset(): void;
  63272. /**
  63273. * Returns the string "GPUParticleSystem"
  63274. * @returns a string containing the class name
  63275. */
  63276. getClassName(): string;
  63277. private _colorGradientsTexture;
  63278. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63279. /**
  63280. * Adds a new color gradient
  63281. * @param gradient defines the gradient to use (between 0 and 1)
  63282. * @param color1 defines the color to affect to the specified gradient
  63283. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63284. * @returns the current particle system
  63285. */
  63286. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63287. private _refreshColorGradient;
  63288. /** Force the system to rebuild all gradients that need to be resync */
  63289. forceRefreshGradients(): void;
  63290. /**
  63291. * Remove a specific color gradient
  63292. * @param gradient defines the gradient to remove
  63293. * @returns the current particle system
  63294. */
  63295. removeColorGradient(gradient: number): GPUParticleSystem;
  63296. private _angularSpeedGradientsTexture;
  63297. private _sizeGradientsTexture;
  63298. private _velocityGradientsTexture;
  63299. private _limitVelocityGradientsTexture;
  63300. private _dragGradientsTexture;
  63301. private _addFactorGradient;
  63302. /**
  63303. * Adds a new size gradient
  63304. * @param gradient defines the gradient to use (between 0 and 1)
  63305. * @param factor defines the size factor to affect to the specified gradient
  63306. * @returns the current particle system
  63307. */
  63308. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63309. /**
  63310. * Remove a specific size gradient
  63311. * @param gradient defines the gradient to remove
  63312. * @returns the current particle system
  63313. */
  63314. removeSizeGradient(gradient: number): GPUParticleSystem;
  63315. private _refreshFactorGradient;
  63316. /**
  63317. * Adds a new angular speed gradient
  63318. * @param gradient defines the gradient to use (between 0 and 1)
  63319. * @param factor defines the angular speed to affect to the specified gradient
  63320. * @returns the current particle system
  63321. */
  63322. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63323. /**
  63324. * Remove a specific angular speed gradient
  63325. * @param gradient defines the gradient to remove
  63326. * @returns the current particle system
  63327. */
  63328. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63329. /**
  63330. * Adds a new velocity gradient
  63331. * @param gradient defines the gradient to use (between 0 and 1)
  63332. * @param factor defines the velocity to affect to the specified gradient
  63333. * @returns the current particle system
  63334. */
  63335. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63336. /**
  63337. * Remove a specific velocity gradient
  63338. * @param gradient defines the gradient to remove
  63339. * @returns the current particle system
  63340. */
  63341. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63342. /**
  63343. * Adds a new limit velocity gradient
  63344. * @param gradient defines the gradient to use (between 0 and 1)
  63345. * @param factor defines the limit velocity value to affect to the specified gradient
  63346. * @returns the current particle system
  63347. */
  63348. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63349. /**
  63350. * Remove a specific limit velocity gradient
  63351. * @param gradient defines the gradient to remove
  63352. * @returns the current particle system
  63353. */
  63354. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63355. /**
  63356. * Adds a new drag gradient
  63357. * @param gradient defines the gradient to use (between 0 and 1)
  63358. * @param factor defines the drag value to affect to the specified gradient
  63359. * @returns the current particle system
  63360. */
  63361. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63362. /**
  63363. * Remove a specific drag gradient
  63364. * @param gradient defines the gradient to remove
  63365. * @returns the current particle system
  63366. */
  63367. removeDragGradient(gradient: number): GPUParticleSystem;
  63368. /**
  63369. * Not supported by GPUParticleSystem
  63370. * @param gradient defines the gradient to use (between 0 and 1)
  63371. * @param factor defines the emit rate value to affect to the specified gradient
  63372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63373. * @returns the current particle system
  63374. */
  63375. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63376. /**
  63377. * Not supported by GPUParticleSystem
  63378. * @param gradient defines the gradient to remove
  63379. * @returns the current particle system
  63380. */
  63381. removeEmitRateGradient(gradient: number): IParticleSystem;
  63382. /**
  63383. * Not supported by GPUParticleSystem
  63384. * @param gradient defines the gradient to use (between 0 and 1)
  63385. * @param factor defines the start size value to affect to the specified gradient
  63386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63387. * @returns the current particle system
  63388. */
  63389. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63390. /**
  63391. * Not supported by GPUParticleSystem
  63392. * @param gradient defines the gradient to remove
  63393. * @returns the current particle system
  63394. */
  63395. removeStartSizeGradient(gradient: number): IParticleSystem;
  63396. /**
  63397. * Not supported by GPUParticleSystem
  63398. * @param gradient defines the gradient to use (between 0 and 1)
  63399. * @param min defines the color remap minimal range
  63400. * @param max defines the color remap maximal range
  63401. * @returns the current particle system
  63402. */
  63403. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63404. /**
  63405. * Not supported by GPUParticleSystem
  63406. * @param gradient defines the gradient to remove
  63407. * @returns the current particle system
  63408. */
  63409. removeColorRemapGradient(): IParticleSystem;
  63410. /**
  63411. * Not supported by GPUParticleSystem
  63412. * @param gradient defines the gradient to use (between 0 and 1)
  63413. * @param min defines the alpha remap minimal range
  63414. * @param max defines the alpha remap maximal range
  63415. * @returns the current particle system
  63416. */
  63417. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63418. /**
  63419. * Not supported by GPUParticleSystem
  63420. * @param gradient defines the gradient to remove
  63421. * @returns the current particle system
  63422. */
  63423. removeAlphaRemapGradient(): IParticleSystem;
  63424. /**
  63425. * Not supported by GPUParticleSystem
  63426. * @param gradient defines the gradient to use (between 0 and 1)
  63427. * @param color defines the color to affect to the specified gradient
  63428. * @returns the current particle system
  63429. */
  63430. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63431. /**
  63432. * Not supported by GPUParticleSystem
  63433. * @param gradient defines the gradient to remove
  63434. * @returns the current particle system
  63435. */
  63436. removeRampGradient(): IParticleSystem;
  63437. /**
  63438. * Not supported by GPUParticleSystem
  63439. * @returns the list of ramp gradients
  63440. */
  63441. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63442. /**
  63443. * Not supported by GPUParticleSystem
  63444. * Gets or sets a boolean indicating that ramp gradients must be used
  63445. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63446. */
  63447. get useRampGradients(): boolean;
  63448. set useRampGradients(value: boolean);
  63449. /**
  63450. * Not supported by GPUParticleSystem
  63451. * @param gradient defines the gradient to use (between 0 and 1)
  63452. * @param factor defines the life time factor to affect to the specified gradient
  63453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63454. * @returns the current particle system
  63455. */
  63456. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63457. /**
  63458. * Not supported by GPUParticleSystem
  63459. * @param gradient defines the gradient to remove
  63460. * @returns the current particle system
  63461. */
  63462. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63463. /**
  63464. * Instantiates a GPU particle system.
  63465. * 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.
  63466. * @param name The name of the particle system
  63467. * @param options The options used to create the system
  63468. * @param scene The scene the particle system belongs to
  63469. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63470. */
  63471. constructor(name: string, options: Partial<{
  63472. capacity: number;
  63473. randomTextureSize: number;
  63474. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63475. protected _reset(): void;
  63476. private _createUpdateVAO;
  63477. private _createRenderVAO;
  63478. private _initialize;
  63479. /** @hidden */
  63480. _recreateUpdateEffect(): void;
  63481. /** @hidden */
  63482. _recreateRenderEffect(): void;
  63483. /**
  63484. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63485. * @param preWarm defines if we are in the pre-warmimg phase
  63486. */
  63487. animate(preWarm?: boolean): void;
  63488. private _createFactorGradientTexture;
  63489. private _createSizeGradientTexture;
  63490. private _createAngularSpeedGradientTexture;
  63491. private _createVelocityGradientTexture;
  63492. private _createLimitVelocityGradientTexture;
  63493. private _createDragGradientTexture;
  63494. private _createColorGradientTexture;
  63495. /**
  63496. * Renders the particle system in its current state
  63497. * @param preWarm defines if the system should only update the particles but not render them
  63498. * @returns the current number of particles
  63499. */
  63500. render(preWarm?: boolean): number;
  63501. /**
  63502. * Rebuilds the particle system
  63503. */
  63504. rebuild(): void;
  63505. private _releaseBuffers;
  63506. private _releaseVAOs;
  63507. /**
  63508. * Disposes the particle system and free the associated resources
  63509. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63510. */
  63511. dispose(disposeTexture?: boolean): void;
  63512. /**
  63513. * Clones the particle system.
  63514. * @param name The name of the cloned object
  63515. * @param newEmitter The new emitter to use
  63516. * @returns the cloned particle system
  63517. */
  63518. clone(name: string, newEmitter: any): GPUParticleSystem;
  63519. /**
  63520. * Serializes the particle system to a JSON object
  63521. * @param serializeTexture defines if the texture must be serialized as well
  63522. * @returns the JSON object
  63523. */
  63524. serialize(serializeTexture?: boolean): any;
  63525. /**
  63526. * Parses a JSON object to create a GPU particle system.
  63527. * @param parsedParticleSystem The JSON object to parse
  63528. * @param scene The scene to create the particle system in
  63529. * @param rootUrl The root url to use to load external dependencies like texture
  63530. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63531. * @returns the parsed GPU particle system
  63532. */
  63533. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63534. }
  63535. }
  63536. declare module BABYLON {
  63537. /**
  63538. * Represents a set of particle systems working together to create a specific effect
  63539. */
  63540. export class ParticleSystemSet implements IDisposable {
  63541. /**
  63542. * Gets or sets base Assets URL
  63543. */
  63544. static BaseAssetsUrl: string;
  63545. private _emitterCreationOptions;
  63546. private _emitterNode;
  63547. /**
  63548. * Gets the particle system list
  63549. */
  63550. systems: IParticleSystem[];
  63551. /**
  63552. * Gets the emitter node used with this set
  63553. */
  63554. get emitterNode(): Nullable<TransformNode>;
  63555. /**
  63556. * Creates a new emitter mesh as a sphere
  63557. * @param options defines the options used to create the sphere
  63558. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63559. * @param scene defines the hosting scene
  63560. */
  63561. setEmitterAsSphere(options: {
  63562. diameter: number;
  63563. segments: number;
  63564. color: Color3;
  63565. }, renderingGroupId: number, scene: Scene): void;
  63566. /**
  63567. * Starts all particle systems of the set
  63568. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63569. */
  63570. start(emitter?: AbstractMesh): void;
  63571. /**
  63572. * Release all associated resources
  63573. */
  63574. dispose(): void;
  63575. /**
  63576. * Serialize the set into a JSON compatible object
  63577. * @param serializeTexture defines if the texture must be serialized as well
  63578. * @returns a JSON compatible representation of the set
  63579. */
  63580. serialize(serializeTexture?: boolean): any;
  63581. /**
  63582. * Parse a new ParticleSystemSet from a serialized source
  63583. * @param data defines a JSON compatible representation of the set
  63584. * @param scene defines the hosting scene
  63585. * @param gpu defines if we want GPU particles or CPU particles
  63586. * @returns a new ParticleSystemSet
  63587. */
  63588. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63589. }
  63590. }
  63591. declare module BABYLON {
  63592. /**
  63593. * This class is made for on one-liner static method to help creating particle system set.
  63594. */
  63595. export class ParticleHelper {
  63596. /**
  63597. * Gets or sets base Assets URL
  63598. */
  63599. static BaseAssetsUrl: string;
  63600. /** Define the Url to load snippets */
  63601. static SnippetUrl: string;
  63602. /**
  63603. * Create a default particle system that you can tweak
  63604. * @param emitter defines the emitter to use
  63605. * @param capacity defines the system capacity (default is 500 particles)
  63606. * @param scene defines the hosting scene
  63607. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63608. * @returns the new Particle system
  63609. */
  63610. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63611. /**
  63612. * This is the main static method (one-liner) of this helper to create different particle systems
  63613. * @param type This string represents the type to the particle system to create
  63614. * @param scene The scene where the particle system should live
  63615. * @param gpu If the system will use gpu
  63616. * @returns the ParticleSystemSet created
  63617. */
  63618. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63619. /**
  63620. * Static function used to export a particle system to a ParticleSystemSet variable.
  63621. * Please note that the emitter shape is not exported
  63622. * @param systems defines the particle systems to export
  63623. * @returns the created particle system set
  63624. */
  63625. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63626. /**
  63627. * Creates a particle system from a snippet saved in a remote file
  63628. * @param name defines the name of the particle system to create
  63629. * @param url defines the url to load from
  63630. * @param scene defines the hosting scene
  63631. * @param gpu If the system will use gpu
  63632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63633. * @returns a promise that will resolve to the new particle system
  63634. */
  63635. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63636. /**
  63637. * Creates a particle system from a snippet saved by the particle system editor
  63638. * @param snippetId defines the snippet to load
  63639. * @param scene defines the hosting scene
  63640. * @param gpu If the system will use gpu
  63641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63642. * @returns a promise that will resolve to the new particle system
  63643. */
  63644. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63645. }
  63646. }
  63647. declare module BABYLON {
  63648. interface Engine {
  63649. /**
  63650. * Create an effect to use with particle systems.
  63651. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63652. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63653. * @param uniformsNames defines a list of attribute names
  63654. * @param samplers defines an array of string used to represent textures
  63655. * @param defines defines the string containing the defines to use to compile the shaders
  63656. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63657. * @param onCompiled defines a function to call when the effect creation is successful
  63658. * @param onError defines a function to call when the effect creation has failed
  63659. * @returns the new Effect
  63660. */
  63661. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63662. }
  63663. interface Mesh {
  63664. /**
  63665. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63666. * @returns an array of IParticleSystem
  63667. */
  63668. getEmittedParticleSystems(): IParticleSystem[];
  63669. /**
  63670. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63671. * @returns an array of IParticleSystem
  63672. */
  63673. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63674. }
  63675. /**
  63676. * @hidden
  63677. */
  63678. export var _IDoNeedToBeInTheBuild: number;
  63679. }
  63680. declare module BABYLON {
  63681. /** Defines the 4 color options */
  63682. export enum PointColor {
  63683. /** color value */
  63684. Color = 2,
  63685. /** uv value */
  63686. UV = 1,
  63687. /** random value */
  63688. Random = 0,
  63689. /** stated value */
  63690. Stated = 3
  63691. }
  63692. /**
  63693. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63694. * 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.
  63695. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63696. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63697. *
  63698. * Full documentation here : TO BE ENTERED
  63699. */
  63700. export class PointsCloudSystem implements IDisposable {
  63701. /**
  63702. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63703. * Example : var p = SPS.particles[i];
  63704. */
  63705. particles: CloudPoint[];
  63706. /**
  63707. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63708. */
  63709. nbParticles: number;
  63710. /**
  63711. * This a counter for your own usage. It's not set by any SPS functions.
  63712. */
  63713. counter: number;
  63714. /**
  63715. * The PCS name. This name is also given to the underlying mesh.
  63716. */
  63717. name: string;
  63718. /**
  63719. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63720. */
  63721. mesh: Mesh;
  63722. /**
  63723. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63724. * Please read :
  63725. */
  63726. vars: any;
  63727. /**
  63728. * @hidden
  63729. */
  63730. _size: number;
  63731. private _scene;
  63732. private _promises;
  63733. private _positions;
  63734. private _indices;
  63735. private _normals;
  63736. private _colors;
  63737. private _uvs;
  63738. private _indices32;
  63739. private _positions32;
  63740. private _colors32;
  63741. private _uvs32;
  63742. private _updatable;
  63743. private _isVisibilityBoxLocked;
  63744. private _alwaysVisible;
  63745. private _groups;
  63746. private _groupCounter;
  63747. private _computeParticleColor;
  63748. private _computeParticleTexture;
  63749. private _computeParticleRotation;
  63750. private _computeBoundingBox;
  63751. private _isReady;
  63752. /**
  63753. * Creates a PCS (Points Cloud System) object
  63754. * @param name (String) is the PCS name, this will be the underlying mesh name
  63755. * @param pointSize (number) is the size for each point
  63756. * @param scene (Scene) is the scene in which the PCS is added
  63757. * @param options defines the options of the PCS e.g.
  63758. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63759. */
  63760. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63761. updatable?: boolean;
  63762. });
  63763. /**
  63764. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63765. * If no points were added to the PCS, the returned mesh is just a single point.
  63766. * @returns a promise for the created mesh
  63767. */
  63768. buildMeshAsync(): Promise<Mesh>;
  63769. /**
  63770. * @hidden
  63771. */
  63772. private _buildMesh;
  63773. private _addParticle;
  63774. private _randomUnitVector;
  63775. private _getColorIndicesForCoord;
  63776. private _setPointsColorOrUV;
  63777. private _colorFromTexture;
  63778. private _calculateDensity;
  63779. /**
  63780. * Adds points to the PCS in random positions within a unit sphere
  63781. * @param nb (positive integer) the number of particles to be created from this model
  63782. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63783. * @returns the number of groups in the system
  63784. */
  63785. addPoints(nb: number, pointFunction?: any): number;
  63786. /**
  63787. * Adds points to the PCS from the surface of the model shape
  63788. * @param mesh is any Mesh object that will be used as a surface model for the points
  63789. * @param nb (positive integer) the number of particles to be created from this model
  63790. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63791. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63792. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63793. * @returns the number of groups in the system
  63794. */
  63795. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63796. /**
  63797. * Adds points to the PCS inside the model shape
  63798. * @param mesh is any Mesh object that will be used as a surface model for the points
  63799. * @param nb (positive integer) the number of particles to be created from this model
  63800. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63801. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63802. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63803. * @returns the number of groups in the system
  63804. */
  63805. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63806. /**
  63807. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63808. * This method calls `updateParticle()` for each particle of the SPS.
  63809. * For an animated SPS, it is usually called within the render loop.
  63810. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63811. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63812. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63813. * @returns the PCS.
  63814. */
  63815. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63816. /**
  63817. * Disposes the PCS.
  63818. */
  63819. dispose(): void;
  63820. /**
  63821. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63822. * doc :
  63823. * @returns the PCS.
  63824. */
  63825. refreshVisibleSize(): PointsCloudSystem;
  63826. /**
  63827. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63828. * @param size the size (float) of the visibility box
  63829. * note : this doesn't lock the PCS mesh bounding box.
  63830. * doc :
  63831. */
  63832. setVisibilityBox(size: number): void;
  63833. /**
  63834. * Gets whether the PCS is always visible or not
  63835. * doc :
  63836. */
  63837. get isAlwaysVisible(): boolean;
  63838. /**
  63839. * Sets the PCS as always visible or not
  63840. * doc :
  63841. */
  63842. set isAlwaysVisible(val: boolean);
  63843. /**
  63844. * Tells to `setParticles()` to compute the particle rotations or not
  63845. * Default value : false. The PCS is faster when it's set to false
  63846. * Note : particle rotations are only applied to parent particles
  63847. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63848. */
  63849. set computeParticleRotation(val: boolean);
  63850. /**
  63851. * Tells to `setParticles()` to compute the particle colors or not.
  63852. * Default value : true. The PCS is faster when it's set to false.
  63853. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63854. */
  63855. set computeParticleColor(val: boolean);
  63856. set computeParticleTexture(val: boolean);
  63857. /**
  63858. * Gets if `setParticles()` computes the particle colors or not.
  63859. * Default value : false. The PCS is faster when it's set to false.
  63860. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63861. */
  63862. get computeParticleColor(): boolean;
  63863. /**
  63864. * Gets if `setParticles()` computes the particle textures or not.
  63865. * Default value : false. The PCS is faster when it's set to false.
  63866. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63867. */
  63868. get computeParticleTexture(): boolean;
  63869. /**
  63870. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63871. */
  63872. set computeBoundingBox(val: boolean);
  63873. /**
  63874. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63875. */
  63876. get computeBoundingBox(): boolean;
  63877. /**
  63878. * This function does nothing. It may be overwritten to set all the particle first values.
  63879. * The PCS doesn't call this function, you may have to call it by your own.
  63880. * doc :
  63881. */
  63882. initParticles(): void;
  63883. /**
  63884. * This function does nothing. It may be overwritten to recycle a particle
  63885. * The PCS doesn't call this function, you can to call it
  63886. * doc :
  63887. * @param particle The particle to recycle
  63888. * @returns the recycled particle
  63889. */
  63890. recycleParticle(particle: CloudPoint): CloudPoint;
  63891. /**
  63892. * Updates a particle : this function should be overwritten by the user.
  63893. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63894. * doc :
  63895. * @example : just set a particle position or velocity and recycle conditions
  63896. * @param particle The particle to update
  63897. * @returns the updated particle
  63898. */
  63899. updateParticle(particle: CloudPoint): CloudPoint;
  63900. /**
  63901. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63902. * This does nothing and may be overwritten by the user.
  63903. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63904. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63905. * @param update the boolean update value actually passed to setParticles()
  63906. */
  63907. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63908. /**
  63909. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63910. * This will be passed three parameters.
  63911. * This does nothing and may be overwritten by the user.
  63912. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63913. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63914. * @param update the boolean update value actually passed to setParticles()
  63915. */
  63916. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63917. }
  63918. }
  63919. declare module BABYLON {
  63920. /**
  63921. * Represents one particle of a points cloud system.
  63922. */
  63923. export class CloudPoint {
  63924. /**
  63925. * particle global index
  63926. */
  63927. idx: number;
  63928. /**
  63929. * The color of the particle
  63930. */
  63931. color: Nullable<Color4>;
  63932. /**
  63933. * The world space position of the particle.
  63934. */
  63935. position: Vector3;
  63936. /**
  63937. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63938. */
  63939. rotation: Vector3;
  63940. /**
  63941. * The world space rotation quaternion of the particle.
  63942. */
  63943. rotationQuaternion: Nullable<Quaternion>;
  63944. /**
  63945. * The uv of the particle.
  63946. */
  63947. uv: Nullable<Vector2>;
  63948. /**
  63949. * The current speed of the particle.
  63950. */
  63951. velocity: Vector3;
  63952. /**
  63953. * The pivot point in the particle local space.
  63954. */
  63955. pivot: Vector3;
  63956. /**
  63957. * Must the particle be translated from its pivot point in its local space ?
  63958. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63959. * Default : false
  63960. */
  63961. translateFromPivot: boolean;
  63962. /**
  63963. * Index of this particle in the global "positions" array (Internal use)
  63964. * @hidden
  63965. */
  63966. _pos: number;
  63967. /**
  63968. * @hidden Index of this particle in the global "indices" array (Internal use)
  63969. */
  63970. _ind: number;
  63971. /**
  63972. * Group this particle belongs to
  63973. */
  63974. _group: PointsGroup;
  63975. /**
  63976. * Group id of this particle
  63977. */
  63978. groupId: number;
  63979. /**
  63980. * Index of the particle in its group id (Internal use)
  63981. */
  63982. idxInGroup: number;
  63983. /**
  63984. * @hidden Particle BoundingInfo object (Internal use)
  63985. */
  63986. _boundingInfo: BoundingInfo;
  63987. /**
  63988. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63989. */
  63990. _pcs: PointsCloudSystem;
  63991. /**
  63992. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63993. */
  63994. _stillInvisible: boolean;
  63995. /**
  63996. * @hidden Last computed particle rotation matrix
  63997. */
  63998. _rotationMatrix: number[];
  63999. /**
  64000. * Parent particle Id, if any.
  64001. * Default null.
  64002. */
  64003. parentId: Nullable<number>;
  64004. /**
  64005. * @hidden Internal global position in the PCS.
  64006. */
  64007. _globalPosition: Vector3;
  64008. /**
  64009. * Creates a Point Cloud object.
  64010. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64011. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64012. * @param group (PointsGroup) is the group the particle belongs to
  64013. * @param groupId (integer) is the group identifier in the PCS.
  64014. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64015. * @param pcs defines the PCS it is associated to
  64016. */
  64017. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64018. /**
  64019. * get point size
  64020. */
  64021. get size(): Vector3;
  64022. /**
  64023. * Set point size
  64024. */
  64025. set size(scale: Vector3);
  64026. /**
  64027. * Legacy support, changed quaternion to rotationQuaternion
  64028. */
  64029. get quaternion(): Nullable<Quaternion>;
  64030. /**
  64031. * Legacy support, changed quaternion to rotationQuaternion
  64032. */
  64033. set quaternion(q: Nullable<Quaternion>);
  64034. /**
  64035. * Returns a boolean. True if the particle intersects a mesh, else false
  64036. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64037. * @param target is the object (point or mesh) what the intersection is computed against
  64038. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64039. * @returns true if it intersects
  64040. */
  64041. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64042. /**
  64043. * get the rotation matrix of the particle
  64044. * @hidden
  64045. */
  64046. getRotationMatrix(m: Matrix): void;
  64047. }
  64048. /**
  64049. * Represents a group of points in a points cloud system
  64050. * * PCS internal tool, don't use it manually.
  64051. */
  64052. export class PointsGroup {
  64053. /**
  64054. * The group id
  64055. * @hidden
  64056. */
  64057. groupID: number;
  64058. /**
  64059. * image data for group (internal use)
  64060. * @hidden
  64061. */
  64062. _groupImageData: Nullable<ArrayBufferView>;
  64063. /**
  64064. * Image Width (internal use)
  64065. * @hidden
  64066. */
  64067. _groupImgWidth: number;
  64068. /**
  64069. * Image Height (internal use)
  64070. * @hidden
  64071. */
  64072. _groupImgHeight: number;
  64073. /**
  64074. * Custom position function (internal use)
  64075. * @hidden
  64076. */
  64077. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64078. /**
  64079. * density per facet for surface points
  64080. * @hidden
  64081. */
  64082. _groupDensity: number[];
  64083. /**
  64084. * Only when points are colored by texture carries pointer to texture list array
  64085. * @hidden
  64086. */
  64087. _textureNb: number;
  64088. /**
  64089. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64090. * PCS internal tool, don't use it manually.
  64091. * @hidden
  64092. */
  64093. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64094. }
  64095. }
  64096. declare module BABYLON {
  64097. interface Scene {
  64098. /** @hidden (Backing field) */
  64099. _physicsEngine: Nullable<IPhysicsEngine>;
  64100. /** @hidden */
  64101. _physicsTimeAccumulator: number;
  64102. /**
  64103. * Gets the current physics engine
  64104. * @returns a IPhysicsEngine or null if none attached
  64105. */
  64106. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64107. /**
  64108. * Enables physics to the current scene
  64109. * @param gravity defines the scene's gravity for the physics engine
  64110. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64111. * @return a boolean indicating if the physics engine was initialized
  64112. */
  64113. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64114. /**
  64115. * Disables and disposes the physics engine associated with the scene
  64116. */
  64117. disablePhysicsEngine(): void;
  64118. /**
  64119. * Gets a boolean indicating if there is an active physics engine
  64120. * @returns a boolean indicating if there is an active physics engine
  64121. */
  64122. isPhysicsEnabled(): boolean;
  64123. /**
  64124. * Deletes a physics compound impostor
  64125. * @param compound defines the compound to delete
  64126. */
  64127. deleteCompoundImpostor(compound: any): void;
  64128. /**
  64129. * An event triggered when physic simulation is about to be run
  64130. */
  64131. onBeforePhysicsObservable: Observable<Scene>;
  64132. /**
  64133. * An event triggered when physic simulation has been done
  64134. */
  64135. onAfterPhysicsObservable: Observable<Scene>;
  64136. }
  64137. interface AbstractMesh {
  64138. /** @hidden */
  64139. _physicsImpostor: Nullable<PhysicsImpostor>;
  64140. /**
  64141. * Gets or sets impostor used for physic simulation
  64142. * @see http://doc.babylonjs.com/features/physics_engine
  64143. */
  64144. physicsImpostor: Nullable<PhysicsImpostor>;
  64145. /**
  64146. * Gets the current physics impostor
  64147. * @see http://doc.babylonjs.com/features/physics_engine
  64148. * @returns a physics impostor or null
  64149. */
  64150. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64151. /** Apply a physic impulse to the mesh
  64152. * @param force defines the force to apply
  64153. * @param contactPoint defines where to apply the force
  64154. * @returns the current mesh
  64155. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64156. */
  64157. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64158. /**
  64159. * Creates a physic joint between two meshes
  64160. * @param otherMesh defines the other mesh to use
  64161. * @param pivot1 defines the pivot to use on this mesh
  64162. * @param pivot2 defines the pivot to use on the other mesh
  64163. * @param options defines additional options (can be plugin dependent)
  64164. * @returns the current mesh
  64165. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64166. */
  64167. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64168. /** @hidden */
  64169. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64170. }
  64171. /**
  64172. * Defines the physics engine scene component responsible to manage a physics engine
  64173. */
  64174. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64175. /**
  64176. * The component name helpful to identify the component in the list of scene components.
  64177. */
  64178. readonly name: string;
  64179. /**
  64180. * The scene the component belongs to.
  64181. */
  64182. scene: Scene;
  64183. /**
  64184. * Creates a new instance of the component for the given scene
  64185. * @param scene Defines the scene to register the component in
  64186. */
  64187. constructor(scene: Scene);
  64188. /**
  64189. * Registers the component in a given scene
  64190. */
  64191. register(): void;
  64192. /**
  64193. * Rebuilds the elements related to this component in case of
  64194. * context lost for instance.
  64195. */
  64196. rebuild(): void;
  64197. /**
  64198. * Disposes the component and the associated ressources
  64199. */
  64200. dispose(): void;
  64201. }
  64202. }
  64203. declare module BABYLON {
  64204. /**
  64205. * A helper for physics simulations
  64206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64207. */
  64208. export class PhysicsHelper {
  64209. private _scene;
  64210. private _physicsEngine;
  64211. /**
  64212. * Initializes the Physics helper
  64213. * @param scene Babylon.js scene
  64214. */
  64215. constructor(scene: Scene);
  64216. /**
  64217. * Applies a radial explosion impulse
  64218. * @param origin the origin of the explosion
  64219. * @param radiusOrEventOptions the radius or the options of radial explosion
  64220. * @param strength the explosion strength
  64221. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64222. * @returns A physics radial explosion event, or null
  64223. */
  64224. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64225. /**
  64226. * Applies a radial explosion force
  64227. * @param origin the origin of the explosion
  64228. * @param radiusOrEventOptions the radius or the options of radial explosion
  64229. * @param strength the explosion strength
  64230. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64231. * @returns A physics radial explosion event, or null
  64232. */
  64233. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64234. /**
  64235. * Creates a gravitational field
  64236. * @param origin the origin of the explosion
  64237. * @param radiusOrEventOptions the radius or the options of radial explosion
  64238. * @param strength the explosion strength
  64239. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64240. * @returns A physics gravitational field event, or null
  64241. */
  64242. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64243. /**
  64244. * Creates a physics updraft event
  64245. * @param origin the origin of the updraft
  64246. * @param radiusOrEventOptions the radius or the options of the updraft
  64247. * @param strength the strength of the updraft
  64248. * @param height the height of the updraft
  64249. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64250. * @returns A physics updraft event, or null
  64251. */
  64252. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64253. /**
  64254. * Creates a physics vortex event
  64255. * @param origin the of the vortex
  64256. * @param radiusOrEventOptions the radius or the options of the vortex
  64257. * @param strength the strength of the vortex
  64258. * @param height the height of the vortex
  64259. * @returns a Physics vortex event, or null
  64260. * A physics vortex event or null
  64261. */
  64262. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64263. }
  64264. /**
  64265. * Represents a physics radial explosion event
  64266. */
  64267. class PhysicsRadialExplosionEvent {
  64268. private _scene;
  64269. private _options;
  64270. private _sphere;
  64271. private _dataFetched;
  64272. /**
  64273. * Initializes a radial explosioin event
  64274. * @param _scene BabylonJS scene
  64275. * @param _options The options for the vortex event
  64276. */
  64277. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64278. /**
  64279. * Returns the data related to the radial explosion event (sphere).
  64280. * @returns The radial explosion event data
  64281. */
  64282. getData(): PhysicsRadialExplosionEventData;
  64283. /**
  64284. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64285. * @param impostor A physics imposter
  64286. * @param origin the origin of the explosion
  64287. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64288. */
  64289. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64290. /**
  64291. * Triggers affecterd impostors callbacks
  64292. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64293. */
  64294. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64295. /**
  64296. * Disposes the sphere.
  64297. * @param force Specifies if the sphere should be disposed by force
  64298. */
  64299. dispose(force?: boolean): void;
  64300. /*** Helpers ***/
  64301. private _prepareSphere;
  64302. private _intersectsWithSphere;
  64303. }
  64304. /**
  64305. * Represents a gravitational field event
  64306. */
  64307. class PhysicsGravitationalFieldEvent {
  64308. private _physicsHelper;
  64309. private _scene;
  64310. private _origin;
  64311. private _options;
  64312. private _tickCallback;
  64313. private _sphere;
  64314. private _dataFetched;
  64315. /**
  64316. * Initializes the physics gravitational field event
  64317. * @param _physicsHelper A physics helper
  64318. * @param _scene BabylonJS scene
  64319. * @param _origin The origin position of the gravitational field event
  64320. * @param _options The options for the vortex event
  64321. */
  64322. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64323. /**
  64324. * Returns the data related to the gravitational field event (sphere).
  64325. * @returns A gravitational field event
  64326. */
  64327. getData(): PhysicsGravitationalFieldEventData;
  64328. /**
  64329. * Enables the gravitational field.
  64330. */
  64331. enable(): void;
  64332. /**
  64333. * Disables the gravitational field.
  64334. */
  64335. disable(): void;
  64336. /**
  64337. * Disposes the sphere.
  64338. * @param force The force to dispose from the gravitational field event
  64339. */
  64340. dispose(force?: boolean): void;
  64341. private _tick;
  64342. }
  64343. /**
  64344. * Represents a physics updraft event
  64345. */
  64346. class PhysicsUpdraftEvent {
  64347. private _scene;
  64348. private _origin;
  64349. private _options;
  64350. private _physicsEngine;
  64351. private _originTop;
  64352. private _originDirection;
  64353. private _tickCallback;
  64354. private _cylinder;
  64355. private _cylinderPosition;
  64356. private _dataFetched;
  64357. /**
  64358. * Initializes the physics updraft event
  64359. * @param _scene BabylonJS scene
  64360. * @param _origin The origin position of the updraft
  64361. * @param _options The options for the updraft event
  64362. */
  64363. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64364. /**
  64365. * Returns the data related to the updraft event (cylinder).
  64366. * @returns A physics updraft event
  64367. */
  64368. getData(): PhysicsUpdraftEventData;
  64369. /**
  64370. * Enables the updraft.
  64371. */
  64372. enable(): void;
  64373. /**
  64374. * Disables the updraft.
  64375. */
  64376. disable(): void;
  64377. /**
  64378. * Disposes the cylinder.
  64379. * @param force Specifies if the updraft should be disposed by force
  64380. */
  64381. dispose(force?: boolean): void;
  64382. private getImpostorHitData;
  64383. private _tick;
  64384. /*** Helpers ***/
  64385. private _prepareCylinder;
  64386. private _intersectsWithCylinder;
  64387. }
  64388. /**
  64389. * Represents a physics vortex event
  64390. */
  64391. class PhysicsVortexEvent {
  64392. private _scene;
  64393. private _origin;
  64394. private _options;
  64395. private _physicsEngine;
  64396. private _originTop;
  64397. private _tickCallback;
  64398. private _cylinder;
  64399. private _cylinderPosition;
  64400. private _dataFetched;
  64401. /**
  64402. * Initializes the physics vortex event
  64403. * @param _scene The BabylonJS scene
  64404. * @param _origin The origin position of the vortex
  64405. * @param _options The options for the vortex event
  64406. */
  64407. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64408. /**
  64409. * Returns the data related to the vortex event (cylinder).
  64410. * @returns The physics vortex event data
  64411. */
  64412. getData(): PhysicsVortexEventData;
  64413. /**
  64414. * Enables the vortex.
  64415. */
  64416. enable(): void;
  64417. /**
  64418. * Disables the cortex.
  64419. */
  64420. disable(): void;
  64421. /**
  64422. * Disposes the sphere.
  64423. * @param force
  64424. */
  64425. dispose(force?: boolean): void;
  64426. private getImpostorHitData;
  64427. private _tick;
  64428. /*** Helpers ***/
  64429. private _prepareCylinder;
  64430. private _intersectsWithCylinder;
  64431. }
  64432. /**
  64433. * Options fot the radial explosion event
  64434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64435. */
  64436. export class PhysicsRadialExplosionEventOptions {
  64437. /**
  64438. * The radius of the sphere for the radial explosion.
  64439. */
  64440. radius: number;
  64441. /**
  64442. * The strenth of the explosion.
  64443. */
  64444. strength: number;
  64445. /**
  64446. * The strenght of the force in correspondence to the distance of the affected object
  64447. */
  64448. falloff: PhysicsRadialImpulseFalloff;
  64449. /**
  64450. * Sphere options for the radial explosion.
  64451. */
  64452. sphere: {
  64453. segments: number;
  64454. diameter: number;
  64455. };
  64456. /**
  64457. * Sphere options for the radial explosion.
  64458. */
  64459. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64460. }
  64461. /**
  64462. * Options fot the updraft event
  64463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64464. */
  64465. export class PhysicsUpdraftEventOptions {
  64466. /**
  64467. * The radius of the cylinder for the vortex
  64468. */
  64469. radius: number;
  64470. /**
  64471. * The strenth of the updraft.
  64472. */
  64473. strength: number;
  64474. /**
  64475. * The height of the cylinder for the updraft.
  64476. */
  64477. height: number;
  64478. /**
  64479. * The mode for the the updraft.
  64480. */
  64481. updraftMode: PhysicsUpdraftMode;
  64482. }
  64483. /**
  64484. * Options fot the vortex event
  64485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64486. */
  64487. export class PhysicsVortexEventOptions {
  64488. /**
  64489. * The radius of the cylinder for the vortex
  64490. */
  64491. radius: number;
  64492. /**
  64493. * The strenth of the vortex.
  64494. */
  64495. strength: number;
  64496. /**
  64497. * The height of the cylinder for the vortex.
  64498. */
  64499. height: number;
  64500. /**
  64501. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64502. */
  64503. centripetalForceThreshold: number;
  64504. /**
  64505. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64506. */
  64507. centripetalForceMultiplier: number;
  64508. /**
  64509. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64510. */
  64511. centrifugalForceMultiplier: number;
  64512. /**
  64513. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64514. */
  64515. updraftForceMultiplier: number;
  64516. }
  64517. /**
  64518. * The strenght of the force in correspondence to the distance of the affected object
  64519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64520. */
  64521. export enum PhysicsRadialImpulseFalloff {
  64522. /** Defines that impulse is constant in strength across it's whole radius */
  64523. Constant = 0,
  64524. /** Defines that impulse gets weaker if it's further from the origin */
  64525. Linear = 1
  64526. }
  64527. /**
  64528. * The strength of the force in correspondence to the distance of the affected object
  64529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64530. */
  64531. export enum PhysicsUpdraftMode {
  64532. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64533. Center = 0,
  64534. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64535. Perpendicular = 1
  64536. }
  64537. /**
  64538. * Interface for a physics hit data
  64539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64540. */
  64541. export interface PhysicsHitData {
  64542. /**
  64543. * The force applied at the contact point
  64544. */
  64545. force: Vector3;
  64546. /**
  64547. * The contact point
  64548. */
  64549. contactPoint: Vector3;
  64550. /**
  64551. * The distance from the origin to the contact point
  64552. */
  64553. distanceFromOrigin: number;
  64554. }
  64555. /**
  64556. * Interface for radial explosion event data
  64557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64558. */
  64559. export interface PhysicsRadialExplosionEventData {
  64560. /**
  64561. * A sphere used for the radial explosion event
  64562. */
  64563. sphere: Mesh;
  64564. }
  64565. /**
  64566. * Interface for gravitational field event data
  64567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64568. */
  64569. export interface PhysicsGravitationalFieldEventData {
  64570. /**
  64571. * A sphere mesh used for the gravitational field event
  64572. */
  64573. sphere: Mesh;
  64574. }
  64575. /**
  64576. * Interface for updraft event data
  64577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64578. */
  64579. export interface PhysicsUpdraftEventData {
  64580. /**
  64581. * A cylinder used for the updraft event
  64582. */
  64583. cylinder: Mesh;
  64584. }
  64585. /**
  64586. * Interface for vortex event data
  64587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64588. */
  64589. export interface PhysicsVortexEventData {
  64590. /**
  64591. * A cylinder used for the vortex event
  64592. */
  64593. cylinder: Mesh;
  64594. }
  64595. /**
  64596. * Interface for an affected physics impostor
  64597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64598. */
  64599. export interface PhysicsAffectedImpostorWithData {
  64600. /**
  64601. * The impostor affected by the effect
  64602. */
  64603. impostor: PhysicsImpostor;
  64604. /**
  64605. * The data about the hit/horce from the explosion
  64606. */
  64607. hitData: PhysicsHitData;
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /** @hidden */
  64612. export var blackAndWhitePixelShader: {
  64613. name: string;
  64614. shader: string;
  64615. };
  64616. }
  64617. declare module BABYLON {
  64618. /**
  64619. * Post process used to render in black and white
  64620. */
  64621. export class BlackAndWhitePostProcess extends PostProcess {
  64622. /**
  64623. * Linear about to convert he result to black and white (default: 1)
  64624. */
  64625. degree: number;
  64626. /**
  64627. * Creates a black and white post process
  64628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64629. * @param name The name of the effect.
  64630. * @param options The required width/height ratio to downsize to before computing the render pass.
  64631. * @param camera The camera to apply the render pass to.
  64632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64633. * @param engine The engine which the post process will be applied. (default: current engine)
  64634. * @param reusable If the post process can be reused on the same frame. (default: false)
  64635. */
  64636. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64637. }
  64638. }
  64639. declare module BABYLON {
  64640. /**
  64641. * This represents a set of one or more post processes in Babylon.
  64642. * A post process can be used to apply a shader to a texture after it is rendered.
  64643. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64644. */
  64645. export class PostProcessRenderEffect {
  64646. private _postProcesses;
  64647. private _getPostProcesses;
  64648. private _singleInstance;
  64649. private _cameras;
  64650. private _indicesForCamera;
  64651. /**
  64652. * Name of the effect
  64653. * @hidden
  64654. */
  64655. _name: string;
  64656. /**
  64657. * Instantiates a post process render effect.
  64658. * A post process can be used to apply a shader to a texture after it is rendered.
  64659. * @param engine The engine the effect is tied to
  64660. * @param name The name of the effect
  64661. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64662. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64663. */
  64664. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64665. /**
  64666. * Checks if all the post processes in the effect are supported.
  64667. */
  64668. get isSupported(): boolean;
  64669. /**
  64670. * Updates the current state of the effect
  64671. * @hidden
  64672. */
  64673. _update(): void;
  64674. /**
  64675. * Attaches the effect on cameras
  64676. * @param cameras The camera to attach to.
  64677. * @hidden
  64678. */
  64679. _attachCameras(cameras: Camera): void;
  64680. /**
  64681. * Attaches the effect on cameras
  64682. * @param cameras The camera to attach to.
  64683. * @hidden
  64684. */
  64685. _attachCameras(cameras: Camera[]): void;
  64686. /**
  64687. * Detaches the effect on cameras
  64688. * @param cameras The camera to detatch from.
  64689. * @hidden
  64690. */
  64691. _detachCameras(cameras: Camera): void;
  64692. /**
  64693. * Detatches the effect on cameras
  64694. * @param cameras The camera to detatch from.
  64695. * @hidden
  64696. */
  64697. _detachCameras(cameras: Camera[]): void;
  64698. /**
  64699. * Enables the effect on given cameras
  64700. * @param cameras The camera to enable.
  64701. * @hidden
  64702. */
  64703. _enable(cameras: Camera): void;
  64704. /**
  64705. * Enables the effect on given cameras
  64706. * @param cameras The camera to enable.
  64707. * @hidden
  64708. */
  64709. _enable(cameras: Nullable<Camera[]>): void;
  64710. /**
  64711. * Disables the effect on the given cameras
  64712. * @param cameras The camera to disable.
  64713. * @hidden
  64714. */
  64715. _disable(cameras: Camera): void;
  64716. /**
  64717. * Disables the effect on the given cameras
  64718. * @param cameras The camera to disable.
  64719. * @hidden
  64720. */
  64721. _disable(cameras: Nullable<Camera[]>): void;
  64722. /**
  64723. * Gets a list of the post processes contained in the effect.
  64724. * @param camera The camera to get the post processes on.
  64725. * @returns The list of the post processes in the effect.
  64726. */
  64727. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64728. }
  64729. }
  64730. declare module BABYLON {
  64731. /** @hidden */
  64732. export var extractHighlightsPixelShader: {
  64733. name: string;
  64734. shader: string;
  64735. };
  64736. }
  64737. declare module BABYLON {
  64738. /**
  64739. * 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.
  64740. */
  64741. export class ExtractHighlightsPostProcess extends PostProcess {
  64742. /**
  64743. * The luminance threshold, pixels below this value will be set to black.
  64744. */
  64745. threshold: number;
  64746. /** @hidden */
  64747. _exposure: number;
  64748. /**
  64749. * Post process which has the input texture to be used when performing highlight extraction
  64750. * @hidden
  64751. */
  64752. _inputPostProcess: Nullable<PostProcess>;
  64753. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64754. }
  64755. }
  64756. declare module BABYLON {
  64757. /** @hidden */
  64758. export var bloomMergePixelShader: {
  64759. name: string;
  64760. shader: string;
  64761. };
  64762. }
  64763. declare module BABYLON {
  64764. /**
  64765. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64766. */
  64767. export class BloomMergePostProcess extends PostProcess {
  64768. /** Weight of the bloom to be added to the original input. */
  64769. weight: number;
  64770. /**
  64771. * Creates a new instance of @see BloomMergePostProcess
  64772. * @param name The name of the effect.
  64773. * @param originalFromInput Post process which's input will be used for the merge.
  64774. * @param blurred Blurred highlights post process which's output will be used.
  64775. * @param weight Weight of the bloom to be added to the original input.
  64776. * @param options The required width/height ratio to downsize to before computing the render pass.
  64777. * @param camera The camera to apply the render pass to.
  64778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64779. * @param engine The engine which the post process will be applied. (default: current engine)
  64780. * @param reusable If the post process can be reused on the same frame. (default: false)
  64781. * @param textureType Type of textures used when performing the post process. (default: 0)
  64782. * @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)
  64783. */
  64784. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64785. /** Weight of the bloom to be added to the original input. */
  64786. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /**
  64791. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64792. */
  64793. export class BloomEffect extends PostProcessRenderEffect {
  64794. private bloomScale;
  64795. /**
  64796. * @hidden Internal
  64797. */
  64798. _effects: Array<PostProcess>;
  64799. /**
  64800. * @hidden Internal
  64801. */
  64802. _downscale: ExtractHighlightsPostProcess;
  64803. private _blurX;
  64804. private _blurY;
  64805. private _merge;
  64806. /**
  64807. * The luminance threshold to find bright areas of the image to bloom.
  64808. */
  64809. get threshold(): number;
  64810. set threshold(value: number);
  64811. /**
  64812. * The strength of the bloom.
  64813. */
  64814. get weight(): number;
  64815. set weight(value: number);
  64816. /**
  64817. * Specifies the size of the bloom blur kernel, relative to the final output size
  64818. */
  64819. get kernel(): number;
  64820. set kernel(value: number);
  64821. /**
  64822. * Creates a new instance of @see BloomEffect
  64823. * @param scene The scene the effect belongs to.
  64824. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64825. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64826. * @param bloomWeight The the strength of bloom.
  64827. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64828. * @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)
  64829. */
  64830. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64831. /**
  64832. * Disposes each of the internal effects for a given camera.
  64833. * @param camera The camera to dispose the effect on.
  64834. */
  64835. disposeEffects(camera: Camera): void;
  64836. /**
  64837. * @hidden Internal
  64838. */
  64839. _updateEffects(): void;
  64840. /**
  64841. * Internal
  64842. * @returns if all the contained post processes are ready.
  64843. * @hidden
  64844. */
  64845. _isReady(): boolean;
  64846. }
  64847. }
  64848. declare module BABYLON {
  64849. /** @hidden */
  64850. export var chromaticAberrationPixelShader: {
  64851. name: string;
  64852. shader: string;
  64853. };
  64854. }
  64855. declare module BABYLON {
  64856. /**
  64857. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64858. */
  64859. export class ChromaticAberrationPostProcess extends PostProcess {
  64860. /**
  64861. * The amount of seperation of rgb channels (default: 30)
  64862. */
  64863. aberrationAmount: number;
  64864. /**
  64865. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64866. */
  64867. radialIntensity: number;
  64868. /**
  64869. * 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))
  64870. */
  64871. direction: Vector2;
  64872. /**
  64873. * 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))
  64874. */
  64875. centerPosition: Vector2;
  64876. /**
  64877. * Creates a new instance ChromaticAberrationPostProcess
  64878. * @param name The name of the effect.
  64879. * @param screenWidth The width of the screen to apply the effect on.
  64880. * @param screenHeight The height of the screen to apply the effect on.
  64881. * @param options The required width/height ratio to downsize to before computing the render pass.
  64882. * @param camera The camera to apply the render pass to.
  64883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64884. * @param engine The engine which the post process will be applied. (default: current engine)
  64885. * @param reusable If the post process can be reused on the same frame. (default: false)
  64886. * @param textureType Type of textures used when performing the post process. (default: 0)
  64887. * @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)
  64888. */
  64889. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64890. }
  64891. }
  64892. declare module BABYLON {
  64893. /** @hidden */
  64894. export var circleOfConfusionPixelShader: {
  64895. name: string;
  64896. shader: string;
  64897. };
  64898. }
  64899. declare module BABYLON {
  64900. /**
  64901. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64902. */
  64903. export class CircleOfConfusionPostProcess extends PostProcess {
  64904. /**
  64905. * 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.
  64906. */
  64907. lensSize: number;
  64908. /**
  64909. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64910. */
  64911. fStop: number;
  64912. /**
  64913. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64914. */
  64915. focusDistance: number;
  64916. /**
  64917. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64918. */
  64919. focalLength: number;
  64920. private _depthTexture;
  64921. /**
  64922. * Creates a new instance CircleOfConfusionPostProcess
  64923. * @param name The name of the effect.
  64924. * @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.
  64925. * @param options The required width/height ratio to downsize to before computing the render pass.
  64926. * @param camera The camera to apply the render pass to.
  64927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64928. * @param engine The engine which the post process will be applied. (default: current engine)
  64929. * @param reusable If the post process can be reused on the same frame. (default: false)
  64930. * @param textureType Type of textures used when performing the post process. (default: 0)
  64931. * @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)
  64932. */
  64933. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64934. /**
  64935. * 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.
  64936. */
  64937. set depthTexture(value: RenderTargetTexture);
  64938. }
  64939. }
  64940. declare module BABYLON {
  64941. /** @hidden */
  64942. export var colorCorrectionPixelShader: {
  64943. name: string;
  64944. shader: string;
  64945. };
  64946. }
  64947. declare module BABYLON {
  64948. /**
  64949. *
  64950. * This post-process allows the modification of rendered colors by using
  64951. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64952. *
  64953. * The object needs to be provided an url to a texture containing the color
  64954. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64955. * Use an image editing software to tweak the LUT to match your needs.
  64956. *
  64957. * For an example of a color LUT, see here:
  64958. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64959. * For explanations on color grading, see here:
  64960. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64961. *
  64962. */
  64963. export class ColorCorrectionPostProcess extends PostProcess {
  64964. private _colorTableTexture;
  64965. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64966. }
  64967. }
  64968. declare module BABYLON {
  64969. /** @hidden */
  64970. export var convolutionPixelShader: {
  64971. name: string;
  64972. shader: string;
  64973. };
  64974. }
  64975. declare module BABYLON {
  64976. /**
  64977. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64978. * input texture to perform effects such as edge detection or sharpening
  64979. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64980. */
  64981. export class ConvolutionPostProcess extends PostProcess {
  64982. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64983. kernel: number[];
  64984. /**
  64985. * Creates a new instance ConvolutionPostProcess
  64986. * @param name The name of the effect.
  64987. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64988. * @param options The required width/height ratio to downsize to before computing the render pass.
  64989. * @param camera The camera to apply the render pass to.
  64990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64991. * @param engine The engine which the post process will be applied. (default: current engine)
  64992. * @param reusable If the post process can be reused on the same frame. (default: false)
  64993. * @param textureType Type of textures used when performing the post process. (default: 0)
  64994. */
  64995. constructor(name: string,
  64996. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64997. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64998. /**
  64999. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65000. */
  65001. static EdgeDetect0Kernel: number[];
  65002. /**
  65003. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65004. */
  65005. static EdgeDetect1Kernel: number[];
  65006. /**
  65007. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65008. */
  65009. static EdgeDetect2Kernel: number[];
  65010. /**
  65011. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65012. */
  65013. static SharpenKernel: number[];
  65014. /**
  65015. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65016. */
  65017. static EmbossKernel: number[];
  65018. /**
  65019. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65020. */
  65021. static GaussianKernel: number[];
  65022. }
  65023. }
  65024. declare module BABYLON {
  65025. /**
  65026. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65027. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65028. * based on samples that have a large difference in distance than the center pixel.
  65029. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65030. */
  65031. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65032. direction: Vector2;
  65033. /**
  65034. * Creates a new instance CircleOfConfusionPostProcess
  65035. * @param name The name of the effect.
  65036. * @param scene The scene the effect belongs to.
  65037. * @param direction The direction the blur should be applied.
  65038. * @param kernel The size of the kernel used to blur.
  65039. * @param options The required width/height ratio to downsize to before computing the render pass.
  65040. * @param camera The camera to apply the render pass to.
  65041. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65042. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65044. * @param engine The engine which the post process will be applied. (default: current engine)
  65045. * @param reusable If the post process can be reused on the same frame. (default: false)
  65046. * @param textureType Type of textures used when performing the post process. (default: 0)
  65047. * @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)
  65048. */
  65049. 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);
  65050. }
  65051. }
  65052. declare module BABYLON {
  65053. /** @hidden */
  65054. export var depthOfFieldMergePixelShader: {
  65055. name: string;
  65056. shader: string;
  65057. };
  65058. }
  65059. declare module BABYLON {
  65060. /**
  65061. * Options to be set when merging outputs from the default pipeline.
  65062. */
  65063. export class DepthOfFieldMergePostProcessOptions {
  65064. /**
  65065. * The original image to merge on top of
  65066. */
  65067. originalFromInput: PostProcess;
  65068. /**
  65069. * Parameters to perform the merge of the depth of field effect
  65070. */
  65071. depthOfField?: {
  65072. circleOfConfusion: PostProcess;
  65073. blurSteps: Array<PostProcess>;
  65074. };
  65075. /**
  65076. * Parameters to perform the merge of bloom effect
  65077. */
  65078. bloom?: {
  65079. blurred: PostProcess;
  65080. weight: number;
  65081. };
  65082. }
  65083. /**
  65084. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65085. */
  65086. export class DepthOfFieldMergePostProcess extends PostProcess {
  65087. private blurSteps;
  65088. /**
  65089. * Creates a new instance of DepthOfFieldMergePostProcess
  65090. * @param name The name of the effect.
  65091. * @param originalFromInput Post process which's input will be used for the merge.
  65092. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65093. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65094. * @param options The required width/height ratio to downsize to before computing the render pass.
  65095. * @param camera The camera to apply the render pass to.
  65096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65097. * @param engine The engine which the post process will be applied. (default: current engine)
  65098. * @param reusable If the post process can be reused on the same frame. (default: false)
  65099. * @param textureType Type of textures used when performing the post process. (default: 0)
  65100. * @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)
  65101. */
  65102. 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);
  65103. /**
  65104. * Updates the effect with the current post process compile time values and recompiles the shader.
  65105. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65106. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65107. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65108. * @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
  65109. * @param onCompiled Called when the shader has been compiled.
  65110. * @param onError Called if there is an error when compiling a shader.
  65111. */
  65112. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65113. }
  65114. }
  65115. declare module BABYLON {
  65116. /**
  65117. * Specifies the level of max blur that should be applied when using the depth of field effect
  65118. */
  65119. export enum DepthOfFieldEffectBlurLevel {
  65120. /**
  65121. * Subtle blur
  65122. */
  65123. Low = 0,
  65124. /**
  65125. * Medium blur
  65126. */
  65127. Medium = 1,
  65128. /**
  65129. * Large blur
  65130. */
  65131. High = 2
  65132. }
  65133. /**
  65134. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65135. */
  65136. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65137. private _circleOfConfusion;
  65138. /**
  65139. * @hidden Internal, blurs from high to low
  65140. */
  65141. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65142. private _depthOfFieldBlurY;
  65143. private _dofMerge;
  65144. /**
  65145. * @hidden Internal post processes in depth of field effect
  65146. */
  65147. _effects: Array<PostProcess>;
  65148. /**
  65149. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65150. */
  65151. set focalLength(value: number);
  65152. get focalLength(): number;
  65153. /**
  65154. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65155. */
  65156. set fStop(value: number);
  65157. get fStop(): number;
  65158. /**
  65159. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65160. */
  65161. set focusDistance(value: number);
  65162. get focusDistance(): number;
  65163. /**
  65164. * 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.
  65165. */
  65166. set lensSize(value: number);
  65167. get lensSize(): number;
  65168. /**
  65169. * Creates a new instance DepthOfFieldEffect
  65170. * @param scene The scene the effect belongs to.
  65171. * @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.
  65172. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65173. * @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)
  65174. */
  65175. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65176. /**
  65177. * Get the current class name of the current effet
  65178. * @returns "DepthOfFieldEffect"
  65179. */
  65180. getClassName(): string;
  65181. /**
  65182. * 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.
  65183. */
  65184. set depthTexture(value: RenderTargetTexture);
  65185. /**
  65186. * Disposes each of the internal effects for a given camera.
  65187. * @param camera The camera to dispose the effect on.
  65188. */
  65189. disposeEffects(camera: Camera): void;
  65190. /**
  65191. * @hidden Internal
  65192. */
  65193. _updateEffects(): void;
  65194. /**
  65195. * Internal
  65196. * @returns if all the contained post processes are ready.
  65197. * @hidden
  65198. */
  65199. _isReady(): boolean;
  65200. }
  65201. }
  65202. declare module BABYLON {
  65203. /** @hidden */
  65204. export var displayPassPixelShader: {
  65205. name: string;
  65206. shader: string;
  65207. };
  65208. }
  65209. declare module BABYLON {
  65210. /**
  65211. * DisplayPassPostProcess which produces an output the same as it's input
  65212. */
  65213. export class DisplayPassPostProcess extends PostProcess {
  65214. /**
  65215. * Creates the DisplayPassPostProcess
  65216. * @param name The name of the effect.
  65217. * @param options The required width/height ratio to downsize to before computing the render pass.
  65218. * @param camera The camera to apply the render pass to.
  65219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65220. * @param engine The engine which the post process will be applied. (default: current engine)
  65221. * @param reusable If the post process can be reused on the same frame. (default: false)
  65222. */
  65223. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65224. }
  65225. }
  65226. declare module BABYLON {
  65227. /** @hidden */
  65228. export var filterPixelShader: {
  65229. name: string;
  65230. shader: string;
  65231. };
  65232. }
  65233. declare module BABYLON {
  65234. /**
  65235. * Applies a kernel filter to the image
  65236. */
  65237. export class FilterPostProcess extends PostProcess {
  65238. /** The matrix to be applied to the image */
  65239. kernelMatrix: Matrix;
  65240. /**
  65241. *
  65242. * @param name The name of the effect.
  65243. * @param kernelMatrix The matrix to be applied to the image
  65244. * @param options The required width/height ratio to downsize to before computing the render pass.
  65245. * @param camera The camera to apply the render pass to.
  65246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65247. * @param engine The engine which the post process will be applied. (default: current engine)
  65248. * @param reusable If the post process can be reused on the same frame. (default: false)
  65249. */
  65250. constructor(name: string,
  65251. /** The matrix to be applied to the image */
  65252. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65253. }
  65254. }
  65255. declare module BABYLON {
  65256. /** @hidden */
  65257. export var fxaaPixelShader: {
  65258. name: string;
  65259. shader: string;
  65260. };
  65261. }
  65262. declare module BABYLON {
  65263. /** @hidden */
  65264. export var fxaaVertexShader: {
  65265. name: string;
  65266. shader: string;
  65267. };
  65268. }
  65269. declare module BABYLON {
  65270. /**
  65271. * Fxaa post process
  65272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65273. */
  65274. export class FxaaPostProcess extends PostProcess {
  65275. /** @hidden */
  65276. texelWidth: number;
  65277. /** @hidden */
  65278. texelHeight: number;
  65279. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65280. private _getDefines;
  65281. }
  65282. }
  65283. declare module BABYLON {
  65284. /** @hidden */
  65285. export var grainPixelShader: {
  65286. name: string;
  65287. shader: string;
  65288. };
  65289. }
  65290. declare module BABYLON {
  65291. /**
  65292. * The GrainPostProcess adds noise to the image at mid luminance levels
  65293. */
  65294. export class GrainPostProcess extends PostProcess {
  65295. /**
  65296. * The intensity of the grain added (default: 30)
  65297. */
  65298. intensity: number;
  65299. /**
  65300. * If the grain should be randomized on every frame
  65301. */
  65302. animated: boolean;
  65303. /**
  65304. * Creates a new instance of @see GrainPostProcess
  65305. * @param name The name of the effect.
  65306. * @param options The required width/height ratio to downsize to before computing the render pass.
  65307. * @param camera The camera to apply the render pass to.
  65308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65309. * @param engine The engine which the post process will be applied. (default: current engine)
  65310. * @param reusable If the post process can be reused on the same frame. (default: false)
  65311. * @param textureType Type of textures used when performing the post process. (default: 0)
  65312. * @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)
  65313. */
  65314. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65315. }
  65316. }
  65317. declare module BABYLON {
  65318. /** @hidden */
  65319. export var highlightsPixelShader: {
  65320. name: string;
  65321. shader: string;
  65322. };
  65323. }
  65324. declare module BABYLON {
  65325. /**
  65326. * Extracts highlights from the image
  65327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65328. */
  65329. export class HighlightsPostProcess extends PostProcess {
  65330. /**
  65331. * Extracts highlights from the image
  65332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65333. * @param name The name of the effect.
  65334. * @param options The required width/height ratio to downsize to before computing the render pass.
  65335. * @param camera The camera to apply the render pass to.
  65336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65337. * @param engine The engine which the post process will be applied. (default: current engine)
  65338. * @param reusable If the post process can be reused on the same frame. (default: false)
  65339. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65340. */
  65341. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65342. }
  65343. }
  65344. declare module BABYLON {
  65345. /** @hidden */
  65346. export var mrtFragmentDeclaration: {
  65347. name: string;
  65348. shader: string;
  65349. };
  65350. }
  65351. declare module BABYLON {
  65352. /** @hidden */
  65353. export var geometryPixelShader: {
  65354. name: string;
  65355. shader: string;
  65356. };
  65357. }
  65358. declare module BABYLON {
  65359. /** @hidden */
  65360. export var geometryVertexShader: {
  65361. name: string;
  65362. shader: string;
  65363. };
  65364. }
  65365. declare module BABYLON {
  65366. /** @hidden */
  65367. interface ISavedTransformationMatrix {
  65368. world: Matrix;
  65369. viewProjection: Matrix;
  65370. }
  65371. /**
  65372. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65373. */
  65374. export class GeometryBufferRenderer {
  65375. /**
  65376. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65377. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65378. */
  65379. static readonly POSITION_TEXTURE_TYPE: number;
  65380. /**
  65381. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65382. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65383. */
  65384. static readonly VELOCITY_TEXTURE_TYPE: number;
  65385. /**
  65386. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65387. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65388. */
  65389. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65390. /**
  65391. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65392. * in order to compute objects velocities when enableVelocity is set to "true"
  65393. * @hidden
  65394. */
  65395. _previousTransformationMatrices: {
  65396. [index: number]: ISavedTransformationMatrix;
  65397. };
  65398. /**
  65399. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65400. * in order to compute objects velocities when enableVelocity is set to "true"
  65401. * @hidden
  65402. */
  65403. _previousBonesTransformationMatrices: {
  65404. [index: number]: Float32Array;
  65405. };
  65406. /**
  65407. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65408. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65409. */
  65410. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65411. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65412. renderTransparentMeshes: boolean;
  65413. private _scene;
  65414. private _multiRenderTarget;
  65415. private _ratio;
  65416. private _enablePosition;
  65417. private _enableVelocity;
  65418. private _enableReflectivity;
  65419. private _positionIndex;
  65420. private _velocityIndex;
  65421. private _reflectivityIndex;
  65422. protected _effect: Effect;
  65423. protected _cachedDefines: string;
  65424. /**
  65425. * Set the render list (meshes to be rendered) used in the G buffer.
  65426. */
  65427. set renderList(meshes: Mesh[]);
  65428. /**
  65429. * Gets wether or not G buffer are supported by the running hardware.
  65430. * This requires draw buffer supports
  65431. */
  65432. get isSupported(): boolean;
  65433. /**
  65434. * Returns the index of the given texture type in the G-Buffer textures array
  65435. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65436. * @returns the index of the given texture type in the G-Buffer textures array
  65437. */
  65438. getTextureIndex(textureType: number): number;
  65439. /**
  65440. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65441. */
  65442. get enablePosition(): boolean;
  65443. /**
  65444. * Sets whether or not objects positions are enabled for the G buffer.
  65445. */
  65446. set enablePosition(enable: boolean);
  65447. /**
  65448. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65449. */
  65450. get enableVelocity(): boolean;
  65451. /**
  65452. * Sets wether or not objects velocities are enabled for the G buffer.
  65453. */
  65454. set enableVelocity(enable: boolean);
  65455. /**
  65456. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65457. */
  65458. get enableReflectivity(): boolean;
  65459. /**
  65460. * Sets wether or not objects roughness are enabled for the G buffer.
  65461. */
  65462. set enableReflectivity(enable: boolean);
  65463. /**
  65464. * Gets the scene associated with the buffer.
  65465. */
  65466. get scene(): Scene;
  65467. /**
  65468. * Gets the ratio used by the buffer during its creation.
  65469. * How big is the buffer related to the main canvas.
  65470. */
  65471. get ratio(): number;
  65472. /** @hidden */
  65473. static _SceneComponentInitialization: (scene: Scene) => void;
  65474. /**
  65475. * Creates a new G Buffer for the scene
  65476. * @param scene The scene the buffer belongs to
  65477. * @param ratio How big is the buffer related to the main canvas.
  65478. */
  65479. constructor(scene: Scene, ratio?: number);
  65480. /**
  65481. * Checks wether everything is ready to render a submesh to the G buffer.
  65482. * @param subMesh the submesh to check readiness for
  65483. * @param useInstances is the mesh drawn using instance or not
  65484. * @returns true if ready otherwise false
  65485. */
  65486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65487. /**
  65488. * Gets the current underlying G Buffer.
  65489. * @returns the buffer
  65490. */
  65491. getGBuffer(): MultiRenderTarget;
  65492. /**
  65493. * Gets the number of samples used to render the buffer (anti aliasing).
  65494. */
  65495. get samples(): number;
  65496. /**
  65497. * Sets the number of samples used to render the buffer (anti aliasing).
  65498. */
  65499. set samples(value: number);
  65500. /**
  65501. * Disposes the renderer and frees up associated resources.
  65502. */
  65503. dispose(): void;
  65504. protected _createRenderTargets(): void;
  65505. private _copyBonesTransformationMatrices;
  65506. }
  65507. }
  65508. declare module BABYLON {
  65509. interface Scene {
  65510. /** @hidden (Backing field) */
  65511. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65512. /**
  65513. * Gets or Sets the current geometry buffer associated to the scene.
  65514. */
  65515. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65516. /**
  65517. * Enables a GeometryBufferRender and associates it with the scene
  65518. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65519. * @returns the GeometryBufferRenderer
  65520. */
  65521. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65522. /**
  65523. * Disables the GeometryBufferRender associated with the scene
  65524. */
  65525. disableGeometryBufferRenderer(): void;
  65526. }
  65527. /**
  65528. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65529. * in several rendering techniques.
  65530. */
  65531. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65532. /**
  65533. * The component name helpful to identify the component in the list of scene components.
  65534. */
  65535. readonly name: string;
  65536. /**
  65537. * The scene the component belongs to.
  65538. */
  65539. scene: Scene;
  65540. /**
  65541. * Creates a new instance of the component for the given scene
  65542. * @param scene Defines the scene to register the component in
  65543. */
  65544. constructor(scene: Scene);
  65545. /**
  65546. * Registers the component in a given scene
  65547. */
  65548. register(): void;
  65549. /**
  65550. * Rebuilds the elements related to this component in case of
  65551. * context lost for instance.
  65552. */
  65553. rebuild(): void;
  65554. /**
  65555. * Disposes the component and the associated ressources
  65556. */
  65557. dispose(): void;
  65558. private _gatherRenderTargets;
  65559. }
  65560. }
  65561. declare module BABYLON {
  65562. /** @hidden */
  65563. export var motionBlurPixelShader: {
  65564. name: string;
  65565. shader: string;
  65566. };
  65567. }
  65568. declare module BABYLON {
  65569. /**
  65570. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65571. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65572. * As an example, all you have to do is to create the post-process:
  65573. * var mb = new BABYLON.MotionBlurPostProcess(
  65574. * 'mb', // The name of the effect.
  65575. * scene, // The scene containing the objects to blur according to their velocity.
  65576. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65577. * camera // The camera to apply the render pass to.
  65578. * );
  65579. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65580. */
  65581. export class MotionBlurPostProcess extends PostProcess {
  65582. /**
  65583. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65584. */
  65585. motionStrength: number;
  65586. /**
  65587. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65588. */
  65589. get motionBlurSamples(): number;
  65590. /**
  65591. * Sets the number of iterations to be used for motion blur quality
  65592. */
  65593. set motionBlurSamples(samples: number);
  65594. private _motionBlurSamples;
  65595. private _geometryBufferRenderer;
  65596. /**
  65597. * Creates a new instance MotionBlurPostProcess
  65598. * @param name The name of the effect.
  65599. * @param scene The scene containing the objects to blur according to their velocity.
  65600. * @param options The required width/height ratio to downsize to before computing the render pass.
  65601. * @param camera The camera to apply the render pass to.
  65602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65603. * @param engine The engine which the post process will be applied. (default: current engine)
  65604. * @param reusable If the post process can be reused on the same frame. (default: false)
  65605. * @param textureType Type of textures used when performing the post process. (default: 0)
  65606. * @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)
  65607. */
  65608. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65609. /**
  65610. * Excludes the given skinned mesh from computing bones velocities.
  65611. * 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.
  65612. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65613. */
  65614. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65615. /**
  65616. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65617. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65618. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65619. */
  65620. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65621. /**
  65622. * Disposes the post process.
  65623. * @param camera The camera to dispose the post process on.
  65624. */
  65625. dispose(camera?: Camera): void;
  65626. }
  65627. }
  65628. declare module BABYLON {
  65629. /** @hidden */
  65630. export var refractionPixelShader: {
  65631. name: string;
  65632. shader: string;
  65633. };
  65634. }
  65635. declare module BABYLON {
  65636. /**
  65637. * Post process which applies a refractin texture
  65638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65639. */
  65640. export class RefractionPostProcess extends PostProcess {
  65641. /** the base color of the refraction (used to taint the rendering) */
  65642. color: Color3;
  65643. /** simulated refraction depth */
  65644. depth: number;
  65645. /** the coefficient of the base color (0 to remove base color tainting) */
  65646. colorLevel: number;
  65647. private _refTexture;
  65648. private _ownRefractionTexture;
  65649. /**
  65650. * Gets or sets the refraction texture
  65651. * Please note that you are responsible for disposing the texture if you set it manually
  65652. */
  65653. get refractionTexture(): Texture;
  65654. set refractionTexture(value: Texture);
  65655. /**
  65656. * Initializes the RefractionPostProcess
  65657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65658. * @param name The name of the effect.
  65659. * @param refractionTextureUrl Url of the refraction texture to use
  65660. * @param color the base color of the refraction (used to taint the rendering)
  65661. * @param depth simulated refraction depth
  65662. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65663. * @param camera The camera to apply the render pass to.
  65664. * @param options The required width/height ratio to downsize to before computing the render pass.
  65665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65666. * @param engine The engine which the post process will be applied. (default: current engine)
  65667. * @param reusable If the post process can be reused on the same frame. (default: false)
  65668. */
  65669. constructor(name: string, refractionTextureUrl: string,
  65670. /** the base color of the refraction (used to taint the rendering) */
  65671. color: Color3,
  65672. /** simulated refraction depth */
  65673. depth: number,
  65674. /** the coefficient of the base color (0 to remove base color tainting) */
  65675. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65676. /**
  65677. * Disposes of the post process
  65678. * @param camera Camera to dispose post process on
  65679. */
  65680. dispose(camera: Camera): void;
  65681. }
  65682. }
  65683. declare module BABYLON {
  65684. /** @hidden */
  65685. export var sharpenPixelShader: {
  65686. name: string;
  65687. shader: string;
  65688. };
  65689. }
  65690. declare module BABYLON {
  65691. /**
  65692. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65693. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65694. */
  65695. export class SharpenPostProcess extends PostProcess {
  65696. /**
  65697. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65698. */
  65699. colorAmount: number;
  65700. /**
  65701. * How much sharpness should be applied (default: 0.3)
  65702. */
  65703. edgeAmount: number;
  65704. /**
  65705. * Creates a new instance ConvolutionPostProcess
  65706. * @param name The name of the effect.
  65707. * @param options The required width/height ratio to downsize to before computing the render pass.
  65708. * @param camera The camera to apply the render pass to.
  65709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65710. * @param engine The engine which the post process will be applied. (default: current engine)
  65711. * @param reusable If the post process can be reused on the same frame. (default: false)
  65712. * @param textureType Type of textures used when performing the post process. (default: 0)
  65713. * @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)
  65714. */
  65715. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65716. }
  65717. }
  65718. declare module BABYLON {
  65719. /**
  65720. * PostProcessRenderPipeline
  65721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65722. */
  65723. export class PostProcessRenderPipeline {
  65724. private engine;
  65725. private _renderEffects;
  65726. private _renderEffectsForIsolatedPass;
  65727. /**
  65728. * List of inspectable custom properties (used by the Inspector)
  65729. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65730. */
  65731. inspectableCustomProperties: IInspectable[];
  65732. /**
  65733. * @hidden
  65734. */
  65735. protected _cameras: Camera[];
  65736. /** @hidden */
  65737. _name: string;
  65738. /**
  65739. * Gets pipeline name
  65740. */
  65741. get name(): string;
  65742. /** Gets the list of attached cameras */
  65743. get cameras(): Camera[];
  65744. /**
  65745. * Initializes a PostProcessRenderPipeline
  65746. * @param engine engine to add the pipeline to
  65747. * @param name name of the pipeline
  65748. */
  65749. constructor(engine: Engine, name: string);
  65750. /**
  65751. * Gets the class name
  65752. * @returns "PostProcessRenderPipeline"
  65753. */
  65754. getClassName(): string;
  65755. /**
  65756. * If all the render effects in the pipeline are supported
  65757. */
  65758. get isSupported(): boolean;
  65759. /**
  65760. * Adds an effect to the pipeline
  65761. * @param renderEffect the effect to add
  65762. */
  65763. addEffect(renderEffect: PostProcessRenderEffect): void;
  65764. /** @hidden */
  65765. _rebuild(): void;
  65766. /** @hidden */
  65767. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65768. /** @hidden */
  65769. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65770. /** @hidden */
  65771. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65772. /** @hidden */
  65773. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65774. /** @hidden */
  65775. _attachCameras(cameras: Camera, unique: boolean): void;
  65776. /** @hidden */
  65777. _attachCameras(cameras: Camera[], unique: boolean): void;
  65778. /** @hidden */
  65779. _detachCameras(cameras: Camera): void;
  65780. /** @hidden */
  65781. _detachCameras(cameras: Nullable<Camera[]>): void;
  65782. /** @hidden */
  65783. _update(): void;
  65784. /** @hidden */
  65785. _reset(): void;
  65786. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65787. /**
  65788. * Disposes of the pipeline
  65789. */
  65790. dispose(): void;
  65791. }
  65792. }
  65793. declare module BABYLON {
  65794. /**
  65795. * PostProcessRenderPipelineManager class
  65796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65797. */
  65798. export class PostProcessRenderPipelineManager {
  65799. private _renderPipelines;
  65800. /**
  65801. * Initializes a PostProcessRenderPipelineManager
  65802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65803. */
  65804. constructor();
  65805. /**
  65806. * Gets the list of supported render pipelines
  65807. */
  65808. get supportedPipelines(): PostProcessRenderPipeline[];
  65809. /**
  65810. * Adds a pipeline to the manager
  65811. * @param renderPipeline The pipeline to add
  65812. */
  65813. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65814. /**
  65815. * Attaches a camera to the pipeline
  65816. * @param renderPipelineName The name of the pipeline to attach to
  65817. * @param cameras the camera to attach
  65818. * @param unique if the camera can be attached multiple times to the pipeline
  65819. */
  65820. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65821. /**
  65822. * Detaches a camera from the pipeline
  65823. * @param renderPipelineName The name of the pipeline to detach from
  65824. * @param cameras the camera to detach
  65825. */
  65826. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65827. /**
  65828. * Enables an effect by name on a pipeline
  65829. * @param renderPipelineName the name of the pipeline to enable the effect in
  65830. * @param renderEffectName the name of the effect to enable
  65831. * @param cameras the cameras that the effect should be enabled on
  65832. */
  65833. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65834. /**
  65835. * Disables an effect by name on a pipeline
  65836. * @param renderPipelineName the name of the pipeline to disable the effect in
  65837. * @param renderEffectName the name of the effect to disable
  65838. * @param cameras the cameras that the effect should be disabled on
  65839. */
  65840. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65841. /**
  65842. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65843. */
  65844. update(): void;
  65845. /** @hidden */
  65846. _rebuild(): void;
  65847. /**
  65848. * Disposes of the manager and pipelines
  65849. */
  65850. dispose(): void;
  65851. }
  65852. }
  65853. declare module BABYLON {
  65854. interface Scene {
  65855. /** @hidden (Backing field) */
  65856. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65857. /**
  65858. * Gets the postprocess render pipeline manager
  65859. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65860. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65861. */
  65862. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65863. }
  65864. /**
  65865. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65866. */
  65867. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65868. /**
  65869. * The component name helpfull to identify the component in the list of scene components.
  65870. */
  65871. readonly name: string;
  65872. /**
  65873. * The scene the component belongs to.
  65874. */
  65875. scene: Scene;
  65876. /**
  65877. * Creates a new instance of the component for the given scene
  65878. * @param scene Defines the scene to register the component in
  65879. */
  65880. constructor(scene: Scene);
  65881. /**
  65882. * Registers the component in a given scene
  65883. */
  65884. register(): void;
  65885. /**
  65886. * Rebuilds the elements related to this component in case of
  65887. * context lost for instance.
  65888. */
  65889. rebuild(): void;
  65890. /**
  65891. * Disposes the component and the associated ressources
  65892. */
  65893. dispose(): void;
  65894. private _gatherRenderTargets;
  65895. }
  65896. }
  65897. declare module BABYLON {
  65898. /**
  65899. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65900. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65901. */
  65902. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65903. private _scene;
  65904. private _camerasToBeAttached;
  65905. /**
  65906. * ID of the sharpen post process,
  65907. */
  65908. private readonly SharpenPostProcessId;
  65909. /**
  65910. * @ignore
  65911. * ID of the image processing post process;
  65912. */
  65913. readonly ImageProcessingPostProcessId: string;
  65914. /**
  65915. * @ignore
  65916. * ID of the Fast Approximate Anti-Aliasing post process;
  65917. */
  65918. readonly FxaaPostProcessId: string;
  65919. /**
  65920. * ID of the chromatic aberration post process,
  65921. */
  65922. private readonly ChromaticAberrationPostProcessId;
  65923. /**
  65924. * ID of the grain post process
  65925. */
  65926. private readonly GrainPostProcessId;
  65927. /**
  65928. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65929. */
  65930. sharpen: SharpenPostProcess;
  65931. private _sharpenEffect;
  65932. private bloom;
  65933. /**
  65934. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65935. */
  65936. depthOfField: DepthOfFieldEffect;
  65937. /**
  65938. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65939. */
  65940. fxaa: FxaaPostProcess;
  65941. /**
  65942. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65943. */
  65944. imageProcessing: ImageProcessingPostProcess;
  65945. /**
  65946. * Chromatic aberration post process which will shift rgb colors in the image
  65947. */
  65948. chromaticAberration: ChromaticAberrationPostProcess;
  65949. private _chromaticAberrationEffect;
  65950. /**
  65951. * Grain post process which add noise to the image
  65952. */
  65953. grain: GrainPostProcess;
  65954. private _grainEffect;
  65955. /**
  65956. * Glow post process which adds a glow to emissive areas of the image
  65957. */
  65958. private _glowLayer;
  65959. /**
  65960. * Animations which can be used to tweak settings over a period of time
  65961. */
  65962. animations: Animation[];
  65963. private _imageProcessingConfigurationObserver;
  65964. private _sharpenEnabled;
  65965. private _bloomEnabled;
  65966. private _depthOfFieldEnabled;
  65967. private _depthOfFieldBlurLevel;
  65968. private _fxaaEnabled;
  65969. private _imageProcessingEnabled;
  65970. private _defaultPipelineTextureType;
  65971. private _bloomScale;
  65972. private _chromaticAberrationEnabled;
  65973. private _grainEnabled;
  65974. private _buildAllowed;
  65975. /**
  65976. * Gets active scene
  65977. */
  65978. get scene(): Scene;
  65979. /**
  65980. * Enable or disable the sharpen process from the pipeline
  65981. */
  65982. set sharpenEnabled(enabled: boolean);
  65983. get sharpenEnabled(): boolean;
  65984. private _resizeObserver;
  65985. private _hardwareScaleLevel;
  65986. private _bloomKernel;
  65987. /**
  65988. * Specifies the size of the bloom blur kernel, relative to the final output size
  65989. */
  65990. get bloomKernel(): number;
  65991. set bloomKernel(value: number);
  65992. /**
  65993. * Specifies the weight of the bloom in the final rendering
  65994. */
  65995. private _bloomWeight;
  65996. /**
  65997. * Specifies the luma threshold for the area that will be blurred by the bloom
  65998. */
  65999. private _bloomThreshold;
  66000. private _hdr;
  66001. /**
  66002. * The strength of the bloom.
  66003. */
  66004. set bloomWeight(value: number);
  66005. get bloomWeight(): number;
  66006. /**
  66007. * The strength of the bloom.
  66008. */
  66009. set bloomThreshold(value: number);
  66010. get bloomThreshold(): number;
  66011. /**
  66012. * The scale of the bloom, lower value will provide better performance.
  66013. */
  66014. set bloomScale(value: number);
  66015. get bloomScale(): number;
  66016. /**
  66017. * Enable or disable the bloom from the pipeline
  66018. */
  66019. set bloomEnabled(enabled: boolean);
  66020. get bloomEnabled(): boolean;
  66021. private _rebuildBloom;
  66022. /**
  66023. * If the depth of field is enabled.
  66024. */
  66025. get depthOfFieldEnabled(): boolean;
  66026. set depthOfFieldEnabled(enabled: boolean);
  66027. /**
  66028. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66029. */
  66030. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66031. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66032. /**
  66033. * If the anti aliasing is enabled.
  66034. */
  66035. set fxaaEnabled(enabled: boolean);
  66036. get fxaaEnabled(): boolean;
  66037. private _samples;
  66038. /**
  66039. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66040. */
  66041. set samples(sampleCount: number);
  66042. get samples(): number;
  66043. /**
  66044. * If image processing is enabled.
  66045. */
  66046. set imageProcessingEnabled(enabled: boolean);
  66047. get imageProcessingEnabled(): boolean;
  66048. /**
  66049. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66050. */
  66051. set glowLayerEnabled(enabled: boolean);
  66052. get glowLayerEnabled(): boolean;
  66053. /**
  66054. * Gets the glow layer (or null if not defined)
  66055. */
  66056. get glowLayer(): Nullable<GlowLayer>;
  66057. /**
  66058. * Enable or disable the chromaticAberration process from the pipeline
  66059. */
  66060. set chromaticAberrationEnabled(enabled: boolean);
  66061. get chromaticAberrationEnabled(): boolean;
  66062. /**
  66063. * Enable or disable the grain process from the pipeline
  66064. */
  66065. set grainEnabled(enabled: boolean);
  66066. get grainEnabled(): boolean;
  66067. /**
  66068. * @constructor
  66069. * @param name - The rendering pipeline name (default: "")
  66070. * @param hdr - If high dynamic range textures should be used (default: true)
  66071. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66072. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66073. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66074. */
  66075. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66076. /**
  66077. * Get the class name
  66078. * @returns "DefaultRenderingPipeline"
  66079. */
  66080. getClassName(): string;
  66081. /**
  66082. * Force the compilation of the entire pipeline.
  66083. */
  66084. prepare(): void;
  66085. private _hasCleared;
  66086. private _prevPostProcess;
  66087. private _prevPrevPostProcess;
  66088. private _setAutoClearAndTextureSharing;
  66089. private _depthOfFieldSceneObserver;
  66090. private _buildPipeline;
  66091. private _disposePostProcesses;
  66092. /**
  66093. * Adds a camera to the pipeline
  66094. * @param camera the camera to be added
  66095. */
  66096. addCamera(camera: Camera): void;
  66097. /**
  66098. * Removes a camera from the pipeline
  66099. * @param camera the camera to remove
  66100. */
  66101. removeCamera(camera: Camera): void;
  66102. /**
  66103. * Dispose of the pipeline and stop all post processes
  66104. */
  66105. dispose(): void;
  66106. /**
  66107. * Serialize the rendering pipeline (Used when exporting)
  66108. * @returns the serialized object
  66109. */
  66110. serialize(): any;
  66111. /**
  66112. * Parse the serialized pipeline
  66113. * @param source Source pipeline.
  66114. * @param scene The scene to load the pipeline to.
  66115. * @param rootUrl The URL of the serialized pipeline.
  66116. * @returns An instantiated pipeline from the serialized object.
  66117. */
  66118. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66119. }
  66120. }
  66121. declare module BABYLON {
  66122. /** @hidden */
  66123. export var lensHighlightsPixelShader: {
  66124. name: string;
  66125. shader: string;
  66126. };
  66127. }
  66128. declare module BABYLON {
  66129. /** @hidden */
  66130. export var depthOfFieldPixelShader: {
  66131. name: string;
  66132. shader: string;
  66133. };
  66134. }
  66135. declare module BABYLON {
  66136. /**
  66137. * BABYLON.JS Chromatic Aberration GLSL Shader
  66138. * Author: Olivier Guyot
  66139. * Separates very slightly R, G and B colors on the edges of the screen
  66140. * Inspired by Francois Tarlier & Martins Upitis
  66141. */
  66142. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66143. /**
  66144. * @ignore
  66145. * The chromatic aberration PostProcess id in the pipeline
  66146. */
  66147. LensChromaticAberrationEffect: string;
  66148. /**
  66149. * @ignore
  66150. * The highlights enhancing PostProcess id in the pipeline
  66151. */
  66152. HighlightsEnhancingEffect: string;
  66153. /**
  66154. * @ignore
  66155. * The depth-of-field PostProcess id in the pipeline
  66156. */
  66157. LensDepthOfFieldEffect: string;
  66158. private _scene;
  66159. private _depthTexture;
  66160. private _grainTexture;
  66161. private _chromaticAberrationPostProcess;
  66162. private _highlightsPostProcess;
  66163. private _depthOfFieldPostProcess;
  66164. private _edgeBlur;
  66165. private _grainAmount;
  66166. private _chromaticAberration;
  66167. private _distortion;
  66168. private _highlightsGain;
  66169. private _highlightsThreshold;
  66170. private _dofDistance;
  66171. private _dofAperture;
  66172. private _dofDarken;
  66173. private _dofPentagon;
  66174. private _blurNoise;
  66175. /**
  66176. * @constructor
  66177. *
  66178. * Effect parameters are as follow:
  66179. * {
  66180. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66181. * edge_blur: number; // from 0 to x (1 for realism)
  66182. * distortion: number; // from 0 to x (1 for realism)
  66183. * grain_amount: number; // from 0 to 1
  66184. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66185. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66186. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66187. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66188. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66189. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66190. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66191. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66192. * }
  66193. * Note: if an effect parameter is unset, effect is disabled
  66194. *
  66195. * @param name The rendering pipeline name
  66196. * @param parameters - An object containing all parameters (see above)
  66197. * @param scene The scene linked to this pipeline
  66198. * @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)
  66199. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66200. */
  66201. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66202. /**
  66203. * Get the class name
  66204. * @returns "LensRenderingPipeline"
  66205. */
  66206. getClassName(): string;
  66207. /**
  66208. * Gets associated scene
  66209. */
  66210. get scene(): Scene;
  66211. /**
  66212. * Gets or sets the edge blur
  66213. */
  66214. get edgeBlur(): number;
  66215. set edgeBlur(value: number);
  66216. /**
  66217. * Gets or sets the grain amount
  66218. */
  66219. get grainAmount(): number;
  66220. set grainAmount(value: number);
  66221. /**
  66222. * Gets or sets the chromatic aberration amount
  66223. */
  66224. get chromaticAberration(): number;
  66225. set chromaticAberration(value: number);
  66226. /**
  66227. * Gets or sets the depth of field aperture
  66228. */
  66229. get dofAperture(): number;
  66230. set dofAperture(value: number);
  66231. /**
  66232. * Gets or sets the edge distortion
  66233. */
  66234. get edgeDistortion(): number;
  66235. set edgeDistortion(value: number);
  66236. /**
  66237. * Gets or sets the depth of field distortion
  66238. */
  66239. get dofDistortion(): number;
  66240. set dofDistortion(value: number);
  66241. /**
  66242. * Gets or sets the darken out of focus amount
  66243. */
  66244. get darkenOutOfFocus(): number;
  66245. set darkenOutOfFocus(value: number);
  66246. /**
  66247. * Gets or sets a boolean indicating if blur noise is enabled
  66248. */
  66249. get blurNoise(): boolean;
  66250. set blurNoise(value: boolean);
  66251. /**
  66252. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66253. */
  66254. get pentagonBokeh(): boolean;
  66255. set pentagonBokeh(value: boolean);
  66256. /**
  66257. * Gets or sets the highlight grain amount
  66258. */
  66259. get highlightsGain(): number;
  66260. set highlightsGain(value: number);
  66261. /**
  66262. * Gets or sets the highlight threshold
  66263. */
  66264. get highlightsThreshold(): number;
  66265. set highlightsThreshold(value: number);
  66266. /**
  66267. * Sets the amount of blur at the edges
  66268. * @param amount blur amount
  66269. */
  66270. setEdgeBlur(amount: number): void;
  66271. /**
  66272. * Sets edge blur to 0
  66273. */
  66274. disableEdgeBlur(): void;
  66275. /**
  66276. * Sets the amout of grain
  66277. * @param amount Amount of grain
  66278. */
  66279. setGrainAmount(amount: number): void;
  66280. /**
  66281. * Set grain amount to 0
  66282. */
  66283. disableGrain(): void;
  66284. /**
  66285. * Sets the chromatic aberration amount
  66286. * @param amount amount of chromatic aberration
  66287. */
  66288. setChromaticAberration(amount: number): void;
  66289. /**
  66290. * Sets chromatic aberration amount to 0
  66291. */
  66292. disableChromaticAberration(): void;
  66293. /**
  66294. * Sets the EdgeDistortion amount
  66295. * @param amount amount of EdgeDistortion
  66296. */
  66297. setEdgeDistortion(amount: number): void;
  66298. /**
  66299. * Sets edge distortion to 0
  66300. */
  66301. disableEdgeDistortion(): void;
  66302. /**
  66303. * Sets the FocusDistance amount
  66304. * @param amount amount of FocusDistance
  66305. */
  66306. setFocusDistance(amount: number): void;
  66307. /**
  66308. * Disables depth of field
  66309. */
  66310. disableDepthOfField(): void;
  66311. /**
  66312. * Sets the Aperture amount
  66313. * @param amount amount of Aperture
  66314. */
  66315. setAperture(amount: number): void;
  66316. /**
  66317. * Sets the DarkenOutOfFocus amount
  66318. * @param amount amount of DarkenOutOfFocus
  66319. */
  66320. setDarkenOutOfFocus(amount: number): void;
  66321. private _pentagonBokehIsEnabled;
  66322. /**
  66323. * Creates a pentagon bokeh effect
  66324. */
  66325. enablePentagonBokeh(): void;
  66326. /**
  66327. * Disables the pentagon bokeh effect
  66328. */
  66329. disablePentagonBokeh(): void;
  66330. /**
  66331. * Enables noise blur
  66332. */
  66333. enableNoiseBlur(): void;
  66334. /**
  66335. * Disables noise blur
  66336. */
  66337. disableNoiseBlur(): void;
  66338. /**
  66339. * Sets the HighlightsGain amount
  66340. * @param amount amount of HighlightsGain
  66341. */
  66342. setHighlightsGain(amount: number): void;
  66343. /**
  66344. * Sets the HighlightsThreshold amount
  66345. * @param amount amount of HighlightsThreshold
  66346. */
  66347. setHighlightsThreshold(amount: number): void;
  66348. /**
  66349. * Disables highlights
  66350. */
  66351. disableHighlights(): void;
  66352. /**
  66353. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66354. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66355. */
  66356. dispose(disableDepthRender?: boolean): void;
  66357. private _createChromaticAberrationPostProcess;
  66358. private _createHighlightsPostProcess;
  66359. private _createDepthOfFieldPostProcess;
  66360. private _createGrainTexture;
  66361. }
  66362. }
  66363. declare module BABYLON {
  66364. /** @hidden */
  66365. export var ssao2PixelShader: {
  66366. name: string;
  66367. shader: string;
  66368. };
  66369. }
  66370. declare module BABYLON {
  66371. /** @hidden */
  66372. export var ssaoCombinePixelShader: {
  66373. name: string;
  66374. shader: string;
  66375. };
  66376. }
  66377. declare module BABYLON {
  66378. /**
  66379. * Render pipeline to produce ssao effect
  66380. */
  66381. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66382. /**
  66383. * @ignore
  66384. * The PassPostProcess id in the pipeline that contains the original scene color
  66385. */
  66386. SSAOOriginalSceneColorEffect: string;
  66387. /**
  66388. * @ignore
  66389. * The SSAO PostProcess id in the pipeline
  66390. */
  66391. SSAORenderEffect: string;
  66392. /**
  66393. * @ignore
  66394. * The horizontal blur PostProcess id in the pipeline
  66395. */
  66396. SSAOBlurHRenderEffect: string;
  66397. /**
  66398. * @ignore
  66399. * The vertical blur PostProcess id in the pipeline
  66400. */
  66401. SSAOBlurVRenderEffect: string;
  66402. /**
  66403. * @ignore
  66404. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66405. */
  66406. SSAOCombineRenderEffect: string;
  66407. /**
  66408. * The output strength of the SSAO post-process. Default value is 1.0.
  66409. */
  66410. totalStrength: number;
  66411. /**
  66412. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66413. */
  66414. maxZ: number;
  66415. /**
  66416. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66417. */
  66418. minZAspect: number;
  66419. private _samples;
  66420. /**
  66421. * Number of samples used for the SSAO calculations. Default value is 8
  66422. */
  66423. set samples(n: number);
  66424. get samples(): number;
  66425. private _textureSamples;
  66426. /**
  66427. * Number of samples to use for antialiasing
  66428. */
  66429. set textureSamples(n: number);
  66430. get textureSamples(): number;
  66431. /**
  66432. * Ratio object used for SSAO ratio and blur ratio
  66433. */
  66434. private _ratio;
  66435. /**
  66436. * Dynamically generated sphere sampler.
  66437. */
  66438. private _sampleSphere;
  66439. /**
  66440. * Blur filter offsets
  66441. */
  66442. private _samplerOffsets;
  66443. private _expensiveBlur;
  66444. /**
  66445. * If bilateral blur should be used
  66446. */
  66447. set expensiveBlur(b: boolean);
  66448. get expensiveBlur(): boolean;
  66449. /**
  66450. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66451. */
  66452. radius: number;
  66453. /**
  66454. * The base color of the SSAO post-process
  66455. * The final result is "base + ssao" between [0, 1]
  66456. */
  66457. base: number;
  66458. /**
  66459. * Support test.
  66460. */
  66461. static get IsSupported(): boolean;
  66462. private _scene;
  66463. private _depthTexture;
  66464. private _normalTexture;
  66465. private _randomTexture;
  66466. private _originalColorPostProcess;
  66467. private _ssaoPostProcess;
  66468. private _blurHPostProcess;
  66469. private _blurVPostProcess;
  66470. private _ssaoCombinePostProcess;
  66471. /**
  66472. * Gets active scene
  66473. */
  66474. get scene(): Scene;
  66475. /**
  66476. * @constructor
  66477. * @param name The rendering pipeline name
  66478. * @param scene The scene linked to this pipeline
  66479. * @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 }
  66480. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66481. */
  66482. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66483. /**
  66484. * Get the class name
  66485. * @returns "SSAO2RenderingPipeline"
  66486. */
  66487. getClassName(): string;
  66488. /**
  66489. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66490. */
  66491. dispose(disableGeometryBufferRenderer?: boolean): void;
  66492. private _createBlurPostProcess;
  66493. /** @hidden */
  66494. _rebuild(): void;
  66495. private _bits;
  66496. private _radicalInverse_VdC;
  66497. private _hammersley;
  66498. private _hemisphereSample_uniform;
  66499. private _generateHemisphere;
  66500. private _createSSAOPostProcess;
  66501. private _createSSAOCombinePostProcess;
  66502. private _createRandomTexture;
  66503. /**
  66504. * Serialize the rendering pipeline (Used when exporting)
  66505. * @returns the serialized object
  66506. */
  66507. serialize(): any;
  66508. /**
  66509. * Parse the serialized pipeline
  66510. * @param source Source pipeline.
  66511. * @param scene The scene to load the pipeline to.
  66512. * @param rootUrl The URL of the serialized pipeline.
  66513. * @returns An instantiated pipeline from the serialized object.
  66514. */
  66515. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66516. }
  66517. }
  66518. declare module BABYLON {
  66519. /** @hidden */
  66520. export var ssaoPixelShader: {
  66521. name: string;
  66522. shader: string;
  66523. };
  66524. }
  66525. declare module BABYLON {
  66526. /**
  66527. * Render pipeline to produce ssao effect
  66528. */
  66529. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66530. /**
  66531. * @ignore
  66532. * The PassPostProcess id in the pipeline that contains the original scene color
  66533. */
  66534. SSAOOriginalSceneColorEffect: string;
  66535. /**
  66536. * @ignore
  66537. * The SSAO PostProcess id in the pipeline
  66538. */
  66539. SSAORenderEffect: string;
  66540. /**
  66541. * @ignore
  66542. * The horizontal blur PostProcess id in the pipeline
  66543. */
  66544. SSAOBlurHRenderEffect: string;
  66545. /**
  66546. * @ignore
  66547. * The vertical blur PostProcess id in the pipeline
  66548. */
  66549. SSAOBlurVRenderEffect: string;
  66550. /**
  66551. * @ignore
  66552. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66553. */
  66554. SSAOCombineRenderEffect: string;
  66555. /**
  66556. * The output strength of the SSAO post-process. Default value is 1.0.
  66557. */
  66558. totalStrength: number;
  66559. /**
  66560. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66561. */
  66562. radius: number;
  66563. /**
  66564. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66565. * Must not be equal to fallOff and superior to fallOff.
  66566. * Default value is 0.0075
  66567. */
  66568. area: number;
  66569. /**
  66570. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66571. * Must not be equal to area and inferior to area.
  66572. * Default value is 0.000001
  66573. */
  66574. fallOff: number;
  66575. /**
  66576. * The base color of the SSAO post-process
  66577. * The final result is "base + ssao" between [0, 1]
  66578. */
  66579. base: number;
  66580. private _scene;
  66581. private _depthTexture;
  66582. private _randomTexture;
  66583. private _originalColorPostProcess;
  66584. private _ssaoPostProcess;
  66585. private _blurHPostProcess;
  66586. private _blurVPostProcess;
  66587. private _ssaoCombinePostProcess;
  66588. private _firstUpdate;
  66589. /**
  66590. * Gets active scene
  66591. */
  66592. get scene(): Scene;
  66593. /**
  66594. * @constructor
  66595. * @param name - The rendering pipeline name
  66596. * @param scene - The scene linked to this pipeline
  66597. * @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 }
  66598. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66599. */
  66600. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66601. /**
  66602. * Get the class name
  66603. * @returns "SSAORenderingPipeline"
  66604. */
  66605. getClassName(): string;
  66606. /**
  66607. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66608. */
  66609. dispose(disableDepthRender?: boolean): void;
  66610. private _createBlurPostProcess;
  66611. /** @hidden */
  66612. _rebuild(): void;
  66613. private _createSSAOPostProcess;
  66614. private _createSSAOCombinePostProcess;
  66615. private _createRandomTexture;
  66616. }
  66617. }
  66618. declare module BABYLON {
  66619. /** @hidden */
  66620. export var screenSpaceReflectionPixelShader: {
  66621. name: string;
  66622. shader: string;
  66623. };
  66624. }
  66625. declare module BABYLON {
  66626. /**
  66627. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66628. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66629. */
  66630. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66631. /**
  66632. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66633. */
  66634. threshold: number;
  66635. /**
  66636. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66637. */
  66638. strength: number;
  66639. /**
  66640. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66641. */
  66642. reflectionSpecularFalloffExponent: number;
  66643. /**
  66644. * 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]
  66645. */
  66646. step: number;
  66647. /**
  66648. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66649. */
  66650. roughnessFactor: number;
  66651. private _geometryBufferRenderer;
  66652. private _enableSmoothReflections;
  66653. private _reflectionSamples;
  66654. private _smoothSteps;
  66655. /**
  66656. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66657. * @param name The name of the effect.
  66658. * @param scene The scene containing the objects to calculate reflections.
  66659. * @param options The required width/height ratio to downsize to before computing the render pass.
  66660. * @param camera The camera to apply the render pass to.
  66661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66662. * @param engine The engine which the post process will be applied. (default: current engine)
  66663. * @param reusable If the post process can be reused on the same frame. (default: false)
  66664. * @param textureType Type of textures used when performing the post process. (default: 0)
  66665. * @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)
  66666. */
  66667. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66668. /**
  66669. * Gets wether or not smoothing reflections is enabled.
  66670. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66671. */
  66672. get enableSmoothReflections(): boolean;
  66673. /**
  66674. * Sets wether or not smoothing reflections is enabled.
  66675. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66676. */
  66677. set enableSmoothReflections(enabled: boolean);
  66678. /**
  66679. * Gets the number of samples taken while computing reflections. More samples count is high,
  66680. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66681. */
  66682. get reflectionSamples(): number;
  66683. /**
  66684. * Sets the number of samples taken while computing reflections. More samples count is high,
  66685. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66686. */
  66687. set reflectionSamples(samples: number);
  66688. /**
  66689. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66690. * more the post-process will require GPU power and can generate a drop in FPS.
  66691. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66692. */
  66693. get smoothSteps(): number;
  66694. set smoothSteps(steps: number);
  66695. private _updateEffectDefines;
  66696. }
  66697. }
  66698. declare module BABYLON {
  66699. /** @hidden */
  66700. export var standardPixelShader: {
  66701. name: string;
  66702. shader: string;
  66703. };
  66704. }
  66705. declare module BABYLON {
  66706. /**
  66707. * Standard rendering pipeline
  66708. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66709. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66710. */
  66711. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66712. /**
  66713. * Public members
  66714. */
  66715. /**
  66716. * Post-process which contains the original scene color before the pipeline applies all the effects
  66717. */
  66718. originalPostProcess: Nullable<PostProcess>;
  66719. /**
  66720. * Post-process used to down scale an image x4
  66721. */
  66722. downSampleX4PostProcess: Nullable<PostProcess>;
  66723. /**
  66724. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66725. */
  66726. brightPassPostProcess: Nullable<PostProcess>;
  66727. /**
  66728. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66729. */
  66730. blurHPostProcesses: PostProcess[];
  66731. /**
  66732. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66733. */
  66734. blurVPostProcesses: PostProcess[];
  66735. /**
  66736. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66737. */
  66738. textureAdderPostProcess: Nullable<PostProcess>;
  66739. /**
  66740. * Post-process used to create volumetric lighting effect
  66741. */
  66742. volumetricLightPostProcess: Nullable<PostProcess>;
  66743. /**
  66744. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66745. */
  66746. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66747. /**
  66748. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66749. */
  66750. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66751. /**
  66752. * Post-process used to merge the volumetric light effect and the real scene color
  66753. */
  66754. volumetricLightMergePostProces: Nullable<PostProcess>;
  66755. /**
  66756. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66757. */
  66758. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66759. /**
  66760. * Base post-process used to calculate the average luminance of the final image for HDR
  66761. */
  66762. luminancePostProcess: Nullable<PostProcess>;
  66763. /**
  66764. * Post-processes used to create down sample post-processes in order to get
  66765. * the average luminance of the final image for HDR
  66766. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66767. */
  66768. luminanceDownSamplePostProcesses: PostProcess[];
  66769. /**
  66770. * Post-process used to create a HDR effect (light adaptation)
  66771. */
  66772. hdrPostProcess: Nullable<PostProcess>;
  66773. /**
  66774. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66775. */
  66776. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66777. /**
  66778. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66779. */
  66780. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66781. /**
  66782. * Post-process used to merge the final HDR post-process and the real scene color
  66783. */
  66784. hdrFinalPostProcess: Nullable<PostProcess>;
  66785. /**
  66786. * Post-process used to create a lens flare effect
  66787. */
  66788. lensFlarePostProcess: Nullable<PostProcess>;
  66789. /**
  66790. * Post-process that merges the result of the lens flare post-process and the real scene color
  66791. */
  66792. lensFlareComposePostProcess: Nullable<PostProcess>;
  66793. /**
  66794. * Post-process used to create a motion blur effect
  66795. */
  66796. motionBlurPostProcess: Nullable<PostProcess>;
  66797. /**
  66798. * Post-process used to create a depth of field effect
  66799. */
  66800. depthOfFieldPostProcess: Nullable<PostProcess>;
  66801. /**
  66802. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66803. */
  66804. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66805. /**
  66806. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66807. */
  66808. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66809. /**
  66810. * Represents the brightness threshold in order to configure the illuminated surfaces
  66811. */
  66812. brightThreshold: number;
  66813. /**
  66814. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66815. */
  66816. blurWidth: number;
  66817. /**
  66818. * Sets if the blur for highlighted surfaces must be only horizontal
  66819. */
  66820. horizontalBlur: boolean;
  66821. /**
  66822. * Gets the overall exposure used by the pipeline
  66823. */
  66824. get exposure(): number;
  66825. /**
  66826. * Sets the overall exposure used by the pipeline
  66827. */
  66828. set exposure(value: number);
  66829. /**
  66830. * Texture used typically to simulate "dirty" on camera lens
  66831. */
  66832. lensTexture: Nullable<Texture>;
  66833. /**
  66834. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66835. */
  66836. volumetricLightCoefficient: number;
  66837. /**
  66838. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66839. */
  66840. volumetricLightPower: number;
  66841. /**
  66842. * Used the set the blur intensity to smooth the volumetric lights
  66843. */
  66844. volumetricLightBlurScale: number;
  66845. /**
  66846. * Light (spot or directional) used to generate the volumetric lights rays
  66847. * The source light must have a shadow generate so the pipeline can get its
  66848. * depth map
  66849. */
  66850. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66851. /**
  66852. * For eye adaptation, represents the minimum luminance the eye can see
  66853. */
  66854. hdrMinimumLuminance: number;
  66855. /**
  66856. * For eye adaptation, represents the decrease luminance speed
  66857. */
  66858. hdrDecreaseRate: number;
  66859. /**
  66860. * For eye adaptation, represents the increase luminance speed
  66861. */
  66862. hdrIncreaseRate: number;
  66863. /**
  66864. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66865. */
  66866. get hdrAutoExposure(): boolean;
  66867. /**
  66868. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66869. */
  66870. set hdrAutoExposure(value: boolean);
  66871. /**
  66872. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66873. */
  66874. lensColorTexture: Nullable<Texture>;
  66875. /**
  66876. * The overall strengh for the lens flare effect
  66877. */
  66878. lensFlareStrength: number;
  66879. /**
  66880. * Dispersion coefficient for lens flare ghosts
  66881. */
  66882. lensFlareGhostDispersal: number;
  66883. /**
  66884. * Main lens flare halo width
  66885. */
  66886. lensFlareHaloWidth: number;
  66887. /**
  66888. * Based on the lens distortion effect, defines how much the lens flare result
  66889. * is distorted
  66890. */
  66891. lensFlareDistortionStrength: number;
  66892. /**
  66893. * Configures the blur intensity used for for lens flare (halo)
  66894. */
  66895. lensFlareBlurWidth: number;
  66896. /**
  66897. * Lens star texture must be used to simulate rays on the flares and is available
  66898. * in the documentation
  66899. */
  66900. lensStarTexture: Nullable<Texture>;
  66901. /**
  66902. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66903. * flare effect by taking account of the dirt texture
  66904. */
  66905. lensFlareDirtTexture: Nullable<Texture>;
  66906. /**
  66907. * Represents the focal length for the depth of field effect
  66908. */
  66909. depthOfFieldDistance: number;
  66910. /**
  66911. * Represents the blur intensity for the blurred part of the depth of field effect
  66912. */
  66913. depthOfFieldBlurWidth: number;
  66914. /**
  66915. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66916. */
  66917. get motionStrength(): number;
  66918. /**
  66919. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66920. */
  66921. set motionStrength(strength: number);
  66922. /**
  66923. * Gets wether or not the motion blur post-process is object based or screen based.
  66924. */
  66925. get objectBasedMotionBlur(): boolean;
  66926. /**
  66927. * Sets wether or not the motion blur post-process should be object based or screen based
  66928. */
  66929. set objectBasedMotionBlur(value: boolean);
  66930. /**
  66931. * List of animations for the pipeline (IAnimatable implementation)
  66932. */
  66933. animations: Animation[];
  66934. /**
  66935. * Private members
  66936. */
  66937. private _scene;
  66938. private _currentDepthOfFieldSource;
  66939. private _basePostProcess;
  66940. private _fixedExposure;
  66941. private _currentExposure;
  66942. private _hdrAutoExposure;
  66943. private _hdrCurrentLuminance;
  66944. private _motionStrength;
  66945. private _isObjectBasedMotionBlur;
  66946. private _floatTextureType;
  66947. private _camerasToBeAttached;
  66948. private _ratio;
  66949. private _bloomEnabled;
  66950. private _depthOfFieldEnabled;
  66951. private _vlsEnabled;
  66952. private _lensFlareEnabled;
  66953. private _hdrEnabled;
  66954. private _motionBlurEnabled;
  66955. private _fxaaEnabled;
  66956. private _screenSpaceReflectionsEnabled;
  66957. private _motionBlurSamples;
  66958. private _volumetricLightStepsCount;
  66959. private _samples;
  66960. /**
  66961. * @ignore
  66962. * Specifies if the bloom pipeline is enabled
  66963. */
  66964. get BloomEnabled(): boolean;
  66965. set BloomEnabled(enabled: boolean);
  66966. /**
  66967. * @ignore
  66968. * Specifies if the depth of field pipeline is enabed
  66969. */
  66970. get DepthOfFieldEnabled(): boolean;
  66971. set DepthOfFieldEnabled(enabled: boolean);
  66972. /**
  66973. * @ignore
  66974. * Specifies if the lens flare pipeline is enabed
  66975. */
  66976. get LensFlareEnabled(): boolean;
  66977. set LensFlareEnabled(enabled: boolean);
  66978. /**
  66979. * @ignore
  66980. * Specifies if the HDR pipeline is enabled
  66981. */
  66982. get HDREnabled(): boolean;
  66983. set HDREnabled(enabled: boolean);
  66984. /**
  66985. * @ignore
  66986. * Specifies if the volumetric lights scattering effect is enabled
  66987. */
  66988. get VLSEnabled(): boolean;
  66989. set VLSEnabled(enabled: boolean);
  66990. /**
  66991. * @ignore
  66992. * Specifies if the motion blur effect is enabled
  66993. */
  66994. get MotionBlurEnabled(): boolean;
  66995. set MotionBlurEnabled(enabled: boolean);
  66996. /**
  66997. * Specifies if anti-aliasing is enabled
  66998. */
  66999. get fxaaEnabled(): boolean;
  67000. set fxaaEnabled(enabled: boolean);
  67001. /**
  67002. * Specifies if screen space reflections are enabled.
  67003. */
  67004. get screenSpaceReflectionsEnabled(): boolean;
  67005. set screenSpaceReflectionsEnabled(enabled: boolean);
  67006. /**
  67007. * Specifies the number of steps used to calculate the volumetric lights
  67008. * Typically in interval [50, 200]
  67009. */
  67010. get volumetricLightStepsCount(): number;
  67011. set volumetricLightStepsCount(count: number);
  67012. /**
  67013. * Specifies the number of samples used for the motion blur effect
  67014. * Typically in interval [16, 64]
  67015. */
  67016. get motionBlurSamples(): number;
  67017. set motionBlurSamples(samples: number);
  67018. /**
  67019. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67020. */
  67021. get samples(): number;
  67022. set samples(sampleCount: number);
  67023. /**
  67024. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67025. * @constructor
  67026. * @param name The rendering pipeline name
  67027. * @param scene The scene linked to this pipeline
  67028. * @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)
  67029. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67030. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67031. */
  67032. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67033. private _buildPipeline;
  67034. private _createDownSampleX4PostProcess;
  67035. private _createBrightPassPostProcess;
  67036. private _createBlurPostProcesses;
  67037. private _createTextureAdderPostProcess;
  67038. private _createVolumetricLightPostProcess;
  67039. private _createLuminancePostProcesses;
  67040. private _createHdrPostProcess;
  67041. private _createLensFlarePostProcess;
  67042. private _createDepthOfFieldPostProcess;
  67043. private _createMotionBlurPostProcess;
  67044. private _getDepthTexture;
  67045. private _disposePostProcesses;
  67046. /**
  67047. * Dispose of the pipeline and stop all post processes
  67048. */
  67049. dispose(): void;
  67050. /**
  67051. * Serialize the rendering pipeline (Used when exporting)
  67052. * @returns the serialized object
  67053. */
  67054. serialize(): any;
  67055. /**
  67056. * Parse the serialized pipeline
  67057. * @param source Source pipeline.
  67058. * @param scene The scene to load the pipeline to.
  67059. * @param rootUrl The URL of the serialized pipeline.
  67060. * @returns An instantiated pipeline from the serialized object.
  67061. */
  67062. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67063. /**
  67064. * Luminance steps
  67065. */
  67066. static LuminanceSteps: number;
  67067. }
  67068. }
  67069. declare module BABYLON {
  67070. /** @hidden */
  67071. export var tonemapPixelShader: {
  67072. name: string;
  67073. shader: string;
  67074. };
  67075. }
  67076. declare module BABYLON {
  67077. /** Defines operator used for tonemapping */
  67078. export enum TonemappingOperator {
  67079. /** Hable */
  67080. Hable = 0,
  67081. /** Reinhard */
  67082. Reinhard = 1,
  67083. /** HejiDawson */
  67084. HejiDawson = 2,
  67085. /** Photographic */
  67086. Photographic = 3
  67087. }
  67088. /**
  67089. * Defines a post process to apply tone mapping
  67090. */
  67091. export class TonemapPostProcess extends PostProcess {
  67092. private _operator;
  67093. /** Defines the required exposure adjustement */
  67094. exposureAdjustment: number;
  67095. /**
  67096. * Creates a new TonemapPostProcess
  67097. * @param name defines the name of the postprocess
  67098. * @param _operator defines the operator to use
  67099. * @param exposureAdjustment defines the required exposure adjustement
  67100. * @param camera defines the camera to use (can be null)
  67101. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67102. * @param engine defines the hosting engine (can be ignore if camera is set)
  67103. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67104. */
  67105. constructor(name: string, _operator: TonemappingOperator,
  67106. /** Defines the required exposure adjustement */
  67107. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67108. }
  67109. }
  67110. declare module BABYLON {
  67111. /** @hidden */
  67112. export var volumetricLightScatteringPixelShader: {
  67113. name: string;
  67114. shader: string;
  67115. };
  67116. }
  67117. declare module BABYLON {
  67118. /** @hidden */
  67119. export var volumetricLightScatteringPassVertexShader: {
  67120. name: string;
  67121. shader: string;
  67122. };
  67123. }
  67124. declare module BABYLON {
  67125. /** @hidden */
  67126. export var volumetricLightScatteringPassPixelShader: {
  67127. name: string;
  67128. shader: string;
  67129. };
  67130. }
  67131. declare module BABYLON {
  67132. /**
  67133. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67134. */
  67135. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67136. private _volumetricLightScatteringPass;
  67137. private _volumetricLightScatteringRTT;
  67138. private _viewPort;
  67139. private _screenCoordinates;
  67140. private _cachedDefines;
  67141. /**
  67142. * If not undefined, the mesh position is computed from the attached node position
  67143. */
  67144. attachedNode: {
  67145. position: Vector3;
  67146. };
  67147. /**
  67148. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67149. */
  67150. customMeshPosition: Vector3;
  67151. /**
  67152. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67153. */
  67154. useCustomMeshPosition: boolean;
  67155. /**
  67156. * If the post-process should inverse the light scattering direction
  67157. */
  67158. invert: boolean;
  67159. /**
  67160. * The internal mesh used by the post-process
  67161. */
  67162. mesh: Mesh;
  67163. /**
  67164. * @hidden
  67165. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67166. */
  67167. get useDiffuseColor(): boolean;
  67168. set useDiffuseColor(useDiffuseColor: boolean);
  67169. /**
  67170. * Array containing the excluded meshes not rendered in the internal pass
  67171. */
  67172. excludedMeshes: AbstractMesh[];
  67173. /**
  67174. * Controls the overall intensity of the post-process
  67175. */
  67176. exposure: number;
  67177. /**
  67178. * Dissipates each sample's contribution in range [0, 1]
  67179. */
  67180. decay: number;
  67181. /**
  67182. * Controls the overall intensity of each sample
  67183. */
  67184. weight: number;
  67185. /**
  67186. * Controls the density of each sample
  67187. */
  67188. density: number;
  67189. /**
  67190. * @constructor
  67191. * @param name The post-process name
  67192. * @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)
  67193. * @param camera The camera that the post-process will be attached to
  67194. * @param mesh The mesh used to create the light scattering
  67195. * @param samples The post-process quality, default 100
  67196. * @param samplingModeThe post-process filtering mode
  67197. * @param engine The babylon engine
  67198. * @param reusable If the post-process is reusable
  67199. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67200. */
  67201. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67202. /**
  67203. * Returns the string "VolumetricLightScatteringPostProcess"
  67204. * @returns "VolumetricLightScatteringPostProcess"
  67205. */
  67206. getClassName(): string;
  67207. private _isReady;
  67208. /**
  67209. * Sets the new light position for light scattering effect
  67210. * @param position The new custom light position
  67211. */
  67212. setCustomMeshPosition(position: Vector3): void;
  67213. /**
  67214. * Returns the light position for light scattering effect
  67215. * @return Vector3 The custom light position
  67216. */
  67217. getCustomMeshPosition(): Vector3;
  67218. /**
  67219. * Disposes the internal assets and detaches the post-process from the camera
  67220. */
  67221. dispose(camera: Camera): void;
  67222. /**
  67223. * Returns the render target texture used by the post-process
  67224. * @return the render target texture used by the post-process
  67225. */
  67226. getPass(): RenderTargetTexture;
  67227. private _meshExcluded;
  67228. private _createPass;
  67229. private _updateMeshScreenCoordinates;
  67230. /**
  67231. * Creates a default mesh for the Volumeric Light Scattering post-process
  67232. * @param name The mesh name
  67233. * @param scene The scene where to create the mesh
  67234. * @return the default mesh
  67235. */
  67236. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67237. }
  67238. }
  67239. declare module BABYLON {
  67240. interface Scene {
  67241. /** @hidden (Backing field) */
  67242. _boundingBoxRenderer: BoundingBoxRenderer;
  67243. /** @hidden (Backing field) */
  67244. _forceShowBoundingBoxes: boolean;
  67245. /**
  67246. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67247. */
  67248. forceShowBoundingBoxes: boolean;
  67249. /**
  67250. * Gets the bounding box renderer associated with the scene
  67251. * @returns a BoundingBoxRenderer
  67252. */
  67253. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67254. }
  67255. interface AbstractMesh {
  67256. /** @hidden (Backing field) */
  67257. _showBoundingBox: boolean;
  67258. /**
  67259. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67260. */
  67261. showBoundingBox: boolean;
  67262. }
  67263. /**
  67264. * Component responsible of rendering the bounding box of the meshes in a scene.
  67265. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67266. */
  67267. export class BoundingBoxRenderer implements ISceneComponent {
  67268. /**
  67269. * The component name helpfull to identify the component in the list of scene components.
  67270. */
  67271. readonly name: string;
  67272. /**
  67273. * The scene the component belongs to.
  67274. */
  67275. scene: Scene;
  67276. /**
  67277. * Color of the bounding box lines placed in front of an object
  67278. */
  67279. frontColor: Color3;
  67280. /**
  67281. * Color of the bounding box lines placed behind an object
  67282. */
  67283. backColor: Color3;
  67284. /**
  67285. * Defines if the renderer should show the back lines or not
  67286. */
  67287. showBackLines: boolean;
  67288. /**
  67289. * @hidden
  67290. */
  67291. renderList: SmartArray<BoundingBox>;
  67292. private _colorShader;
  67293. private _vertexBuffers;
  67294. private _indexBuffer;
  67295. private _fillIndexBuffer;
  67296. private _fillIndexData;
  67297. /**
  67298. * Instantiates a new bounding box renderer in a scene.
  67299. * @param scene the scene the renderer renders in
  67300. */
  67301. constructor(scene: Scene);
  67302. /**
  67303. * Registers the component in a given scene
  67304. */
  67305. register(): void;
  67306. private _evaluateSubMesh;
  67307. private _activeMesh;
  67308. private _prepareRessources;
  67309. private _createIndexBuffer;
  67310. /**
  67311. * Rebuilds the elements related to this component in case of
  67312. * context lost for instance.
  67313. */
  67314. rebuild(): void;
  67315. /**
  67316. * @hidden
  67317. */
  67318. reset(): void;
  67319. /**
  67320. * Render the bounding boxes of a specific rendering group
  67321. * @param renderingGroupId defines the rendering group to render
  67322. */
  67323. render(renderingGroupId: number): void;
  67324. /**
  67325. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67326. * @param mesh Define the mesh to render the occlusion bounding box for
  67327. */
  67328. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67329. /**
  67330. * Dispose and release the resources attached to this renderer.
  67331. */
  67332. dispose(): void;
  67333. }
  67334. }
  67335. declare module BABYLON {
  67336. interface Scene {
  67337. /** @hidden (Backing field) */
  67338. _depthRenderer: {
  67339. [id: string]: DepthRenderer;
  67340. };
  67341. /**
  67342. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67343. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67344. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67345. * @returns the created depth renderer
  67346. */
  67347. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67348. /**
  67349. * Disables a depth renderer for a given camera
  67350. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67351. */
  67352. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67353. }
  67354. /**
  67355. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67356. * in several rendering techniques.
  67357. */
  67358. export class DepthRendererSceneComponent implements ISceneComponent {
  67359. /**
  67360. * The component name helpfull to identify the component in the list of scene components.
  67361. */
  67362. readonly name: string;
  67363. /**
  67364. * The scene the component belongs to.
  67365. */
  67366. scene: Scene;
  67367. /**
  67368. * Creates a new instance of the component for the given scene
  67369. * @param scene Defines the scene to register the component in
  67370. */
  67371. constructor(scene: Scene);
  67372. /**
  67373. * Registers the component in a given scene
  67374. */
  67375. register(): void;
  67376. /**
  67377. * Rebuilds the elements related to this component in case of
  67378. * context lost for instance.
  67379. */
  67380. rebuild(): void;
  67381. /**
  67382. * Disposes the component and the associated ressources
  67383. */
  67384. dispose(): void;
  67385. private _gatherRenderTargets;
  67386. private _gatherActiveCameraRenderTargets;
  67387. }
  67388. }
  67389. declare module BABYLON {
  67390. /** @hidden */
  67391. export var outlinePixelShader: {
  67392. name: string;
  67393. shader: string;
  67394. };
  67395. }
  67396. declare module BABYLON {
  67397. /** @hidden */
  67398. export var outlineVertexShader: {
  67399. name: string;
  67400. shader: string;
  67401. };
  67402. }
  67403. declare module BABYLON {
  67404. interface Scene {
  67405. /** @hidden */
  67406. _outlineRenderer: OutlineRenderer;
  67407. /**
  67408. * Gets the outline renderer associated with the scene
  67409. * @returns a OutlineRenderer
  67410. */
  67411. getOutlineRenderer(): OutlineRenderer;
  67412. }
  67413. interface AbstractMesh {
  67414. /** @hidden (Backing field) */
  67415. _renderOutline: boolean;
  67416. /**
  67417. * Gets or sets a boolean indicating if the outline must be rendered as well
  67418. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67419. */
  67420. renderOutline: boolean;
  67421. /** @hidden (Backing field) */
  67422. _renderOverlay: boolean;
  67423. /**
  67424. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67425. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67426. */
  67427. renderOverlay: boolean;
  67428. }
  67429. /**
  67430. * This class is responsible to draw bothe outline/overlay of meshes.
  67431. * It should not be used directly but through the available method on mesh.
  67432. */
  67433. export class OutlineRenderer implements ISceneComponent {
  67434. /**
  67435. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67436. */
  67437. private static _StencilReference;
  67438. /**
  67439. * The name of the component. Each component must have a unique name.
  67440. */
  67441. name: string;
  67442. /**
  67443. * The scene the component belongs to.
  67444. */
  67445. scene: Scene;
  67446. /**
  67447. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67448. */
  67449. zOffset: number;
  67450. private _engine;
  67451. private _effect;
  67452. private _cachedDefines;
  67453. private _savedDepthWrite;
  67454. /**
  67455. * Instantiates a new outline renderer. (There could be only one per scene).
  67456. * @param scene Defines the scene it belongs to
  67457. */
  67458. constructor(scene: Scene);
  67459. /**
  67460. * Register the component to one instance of a scene.
  67461. */
  67462. register(): void;
  67463. /**
  67464. * Rebuilds the elements related to this component in case of
  67465. * context lost for instance.
  67466. */
  67467. rebuild(): void;
  67468. /**
  67469. * Disposes the component and the associated ressources.
  67470. */
  67471. dispose(): void;
  67472. /**
  67473. * Renders the outline in the canvas.
  67474. * @param subMesh Defines the sumesh to render
  67475. * @param batch Defines the batch of meshes in case of instances
  67476. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67477. */
  67478. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67479. /**
  67480. * Returns whether or not the outline renderer is ready for a given submesh.
  67481. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67482. * @param subMesh Defines the submesh to check readyness for
  67483. * @param useInstances Defines wheter wee are trying to render instances or not
  67484. * @returns true if ready otherwise false
  67485. */
  67486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67487. private _beforeRenderingMesh;
  67488. private _afterRenderingMesh;
  67489. }
  67490. }
  67491. declare module BABYLON {
  67492. /**
  67493. * Defines the basic options interface of a Sprite Frame Source Size.
  67494. */
  67495. export interface ISpriteJSONSpriteSourceSize {
  67496. /**
  67497. * number of the original width of the Frame
  67498. */
  67499. w: number;
  67500. /**
  67501. * number of the original height of the Frame
  67502. */
  67503. h: number;
  67504. }
  67505. /**
  67506. * Defines the basic options interface of a Sprite Frame Data.
  67507. */
  67508. export interface ISpriteJSONSpriteFrameData {
  67509. /**
  67510. * number of the x offset of the Frame
  67511. */
  67512. x: number;
  67513. /**
  67514. * number of the y offset of the Frame
  67515. */
  67516. y: number;
  67517. /**
  67518. * number of the width of the Frame
  67519. */
  67520. w: number;
  67521. /**
  67522. * number of the height of the Frame
  67523. */
  67524. h: number;
  67525. }
  67526. /**
  67527. * Defines the basic options interface of a JSON Sprite.
  67528. */
  67529. export interface ISpriteJSONSprite {
  67530. /**
  67531. * string name of the Frame
  67532. */
  67533. filename: string;
  67534. /**
  67535. * ISpriteJSONSpriteFrame basic object of the frame data
  67536. */
  67537. frame: ISpriteJSONSpriteFrameData;
  67538. /**
  67539. * boolean to flag is the frame was rotated.
  67540. */
  67541. rotated: boolean;
  67542. /**
  67543. * boolean to flag is the frame was trimmed.
  67544. */
  67545. trimmed: boolean;
  67546. /**
  67547. * ISpriteJSONSpriteFrame basic object of the source data
  67548. */
  67549. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67550. /**
  67551. * ISpriteJSONSpriteFrame basic object of the source data
  67552. */
  67553. sourceSize: ISpriteJSONSpriteSourceSize;
  67554. }
  67555. /**
  67556. * Defines the basic options interface of a JSON atlas.
  67557. */
  67558. export interface ISpriteJSONAtlas {
  67559. /**
  67560. * Array of objects that contain the frame data.
  67561. */
  67562. frames: Array<ISpriteJSONSprite>;
  67563. /**
  67564. * object basic object containing the sprite meta data.
  67565. */
  67566. meta?: object;
  67567. }
  67568. }
  67569. declare module BABYLON {
  67570. /** @hidden */
  67571. export var spriteMapPixelShader: {
  67572. name: string;
  67573. shader: string;
  67574. };
  67575. }
  67576. declare module BABYLON {
  67577. /** @hidden */
  67578. export var spriteMapVertexShader: {
  67579. name: string;
  67580. shader: string;
  67581. };
  67582. }
  67583. declare module BABYLON {
  67584. /**
  67585. * Defines the basic options interface of a SpriteMap
  67586. */
  67587. export interface ISpriteMapOptions {
  67588. /**
  67589. * Vector2 of the number of cells in the grid.
  67590. */
  67591. stageSize?: Vector2;
  67592. /**
  67593. * Vector2 of the size of the output plane in World Units.
  67594. */
  67595. outputSize?: Vector2;
  67596. /**
  67597. * Vector3 of the position of the output plane in World Units.
  67598. */
  67599. outputPosition?: Vector3;
  67600. /**
  67601. * Vector3 of the rotation of the output plane.
  67602. */
  67603. outputRotation?: Vector3;
  67604. /**
  67605. * number of layers that the system will reserve in resources.
  67606. */
  67607. layerCount?: number;
  67608. /**
  67609. * number of max animation frames a single cell will reserve in resources.
  67610. */
  67611. maxAnimationFrames?: number;
  67612. /**
  67613. * number cell index of the base tile when the system compiles.
  67614. */
  67615. baseTile?: number;
  67616. /**
  67617. * boolean flip the sprite after its been repositioned by the framing data.
  67618. */
  67619. flipU?: boolean;
  67620. /**
  67621. * Vector3 scalar of the global RGB values of the SpriteMap.
  67622. */
  67623. colorMultiply?: Vector3;
  67624. }
  67625. /**
  67626. * Defines the IDisposable interface in order to be cleanable from resources.
  67627. */
  67628. export interface ISpriteMap extends IDisposable {
  67629. /**
  67630. * String name of the SpriteMap.
  67631. */
  67632. name: string;
  67633. /**
  67634. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67635. */
  67636. atlasJSON: ISpriteJSONAtlas;
  67637. /**
  67638. * Texture of the SpriteMap.
  67639. */
  67640. spriteSheet: Texture;
  67641. /**
  67642. * The parameters to initialize the SpriteMap with.
  67643. */
  67644. options: ISpriteMapOptions;
  67645. }
  67646. /**
  67647. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67648. */
  67649. export class SpriteMap implements ISpriteMap {
  67650. /** The Name of the spriteMap */
  67651. name: string;
  67652. /** The JSON file with the frame and meta data */
  67653. atlasJSON: ISpriteJSONAtlas;
  67654. /** The systems Sprite Sheet Texture */
  67655. spriteSheet: Texture;
  67656. /** Arguments passed with the Constructor */
  67657. options: ISpriteMapOptions;
  67658. /** Public Sprite Storage array, parsed from atlasJSON */
  67659. sprites: Array<ISpriteJSONSprite>;
  67660. /** Returns the Number of Sprites in the System */
  67661. get spriteCount(): number;
  67662. /** Returns the Position of Output Plane*/
  67663. get position(): Vector3;
  67664. /** Returns the Position of Output Plane*/
  67665. set position(v: Vector3);
  67666. /** Returns the Rotation of Output Plane*/
  67667. get rotation(): Vector3;
  67668. /** Returns the Rotation of Output Plane*/
  67669. set rotation(v: Vector3);
  67670. /** Sets the AnimationMap*/
  67671. get animationMap(): RawTexture;
  67672. /** Sets the AnimationMap*/
  67673. set animationMap(v: RawTexture);
  67674. /** Scene that the SpriteMap was created in */
  67675. private _scene;
  67676. /** Texture Buffer of Float32 that holds tile frame data*/
  67677. private _frameMap;
  67678. /** Texture Buffers of Float32 that holds tileMap data*/
  67679. private _tileMaps;
  67680. /** Texture Buffer of Float32 that holds Animation Data*/
  67681. private _animationMap;
  67682. /** Custom ShaderMaterial Central to the System*/
  67683. private _material;
  67684. /** Custom ShaderMaterial Central to the System*/
  67685. private _output;
  67686. /** Systems Time Ticker*/
  67687. private _time;
  67688. /**
  67689. * Creates a new SpriteMap
  67690. * @param name defines the SpriteMaps Name
  67691. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67692. * @param spriteSheet is the Texture that the Sprites are on.
  67693. * @param options a basic deployment configuration
  67694. * @param scene The Scene that the map is deployed on
  67695. */
  67696. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67697. /**
  67698. * Returns tileID location
  67699. * @returns Vector2 the cell position ID
  67700. */
  67701. getTileID(): Vector2;
  67702. /**
  67703. * Gets the UV location of the mouse over the SpriteMap.
  67704. * @returns Vector2 the UV position of the mouse interaction
  67705. */
  67706. getMousePosition(): Vector2;
  67707. /**
  67708. * Creates the "frame" texture Buffer
  67709. * -------------------------------------
  67710. * Structure of frames
  67711. * "filename": "Falling-Water-2.png",
  67712. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67713. * "rotated": true,
  67714. * "trimmed": true,
  67715. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67716. * "sourceSize": {"w":32,"h":32}
  67717. * @returns RawTexture of the frameMap
  67718. */
  67719. private _createFrameBuffer;
  67720. /**
  67721. * Creates the tileMap texture Buffer
  67722. * @param buffer normally and array of numbers, or a false to generate from scratch
  67723. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67724. * @returns RawTexture of the tileMap
  67725. */
  67726. private _createTileBuffer;
  67727. /**
  67728. * Modifies the data of the tileMaps
  67729. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67730. * @param pos is the iVector2 Coordinates of the Tile
  67731. * @param tile The SpriteIndex of the new Tile
  67732. */
  67733. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67734. /**
  67735. * Creates the animationMap texture Buffer
  67736. * @param buffer normally and array of numbers, or a false to generate from scratch
  67737. * @returns RawTexture of the animationMap
  67738. */
  67739. private _createTileAnimationBuffer;
  67740. /**
  67741. * Modifies the data of the animationMap
  67742. * @param cellID is the Index of the Sprite
  67743. * @param _frame is the target Animation frame
  67744. * @param toCell is the Target Index of the next frame of the animation
  67745. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67746. * @param speed is a global scalar of the time variable on the map.
  67747. */
  67748. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67749. /**
  67750. * Exports the .tilemaps file
  67751. */
  67752. saveTileMaps(): void;
  67753. /**
  67754. * Imports the .tilemaps file
  67755. * @param url of the .tilemaps file
  67756. */
  67757. loadTileMaps(url: string): void;
  67758. /**
  67759. * Release associated resources
  67760. */
  67761. dispose(): void;
  67762. }
  67763. }
  67764. declare module BABYLON {
  67765. /**
  67766. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67767. * @see http://doc.babylonjs.com/babylon101/sprites
  67768. */
  67769. export class SpritePackedManager extends SpriteManager {
  67770. /** defines the packed manager's name */
  67771. name: string;
  67772. /**
  67773. * Creates a new sprite manager from a packed sprite sheet
  67774. * @param name defines the manager's name
  67775. * @param imgUrl defines the sprite sheet url
  67776. * @param capacity defines the maximum allowed number of sprites
  67777. * @param scene defines the hosting scene
  67778. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67779. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67780. * @param samplingMode defines the smapling mode to use with spritesheet
  67781. * @param fromPacked set to true; do not alter
  67782. */
  67783. constructor(
  67784. /** defines the packed manager's name */
  67785. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67786. }
  67787. }
  67788. declare module BABYLON {
  67789. /**
  67790. * Defines the list of states available for a task inside a AssetsManager
  67791. */
  67792. export enum AssetTaskState {
  67793. /**
  67794. * Initialization
  67795. */
  67796. INIT = 0,
  67797. /**
  67798. * Running
  67799. */
  67800. RUNNING = 1,
  67801. /**
  67802. * Done
  67803. */
  67804. DONE = 2,
  67805. /**
  67806. * Error
  67807. */
  67808. ERROR = 3
  67809. }
  67810. /**
  67811. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67812. */
  67813. export abstract class AbstractAssetTask {
  67814. /**
  67815. * Task name
  67816. */ name: string;
  67817. /**
  67818. * Callback called when the task is successful
  67819. */
  67820. onSuccess: (task: any) => void;
  67821. /**
  67822. * Callback called when the task is not successful
  67823. */
  67824. onError: (task: any, message?: string, exception?: any) => void;
  67825. /**
  67826. * Creates a new AssetsManager
  67827. * @param name defines the name of the task
  67828. */
  67829. constructor(
  67830. /**
  67831. * Task name
  67832. */ name: string);
  67833. private _isCompleted;
  67834. private _taskState;
  67835. private _errorObject;
  67836. /**
  67837. * Get if the task is completed
  67838. */
  67839. get isCompleted(): boolean;
  67840. /**
  67841. * Gets the current state of the task
  67842. */
  67843. get taskState(): AssetTaskState;
  67844. /**
  67845. * Gets the current error object (if task is in error)
  67846. */
  67847. get errorObject(): {
  67848. message?: string;
  67849. exception?: any;
  67850. };
  67851. /**
  67852. * Internal only
  67853. * @hidden
  67854. */
  67855. _setErrorObject(message?: string, exception?: any): void;
  67856. /**
  67857. * Execute the current task
  67858. * @param scene defines the scene where you want your assets to be loaded
  67859. * @param onSuccess is a callback called when the task is successfully executed
  67860. * @param onError is a callback called if an error occurs
  67861. */
  67862. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67863. /**
  67864. * Execute the current task
  67865. * @param scene defines the scene where you want your assets to be loaded
  67866. * @param onSuccess is a callback called when the task is successfully executed
  67867. * @param onError is a callback called if an error occurs
  67868. */
  67869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67870. /**
  67871. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67872. * This can be used with failed tasks that have the reason for failure fixed.
  67873. */
  67874. reset(): void;
  67875. private onErrorCallback;
  67876. private onDoneCallback;
  67877. }
  67878. /**
  67879. * Define the interface used by progress events raised during assets loading
  67880. */
  67881. export interface IAssetsProgressEvent {
  67882. /**
  67883. * Defines the number of remaining tasks to process
  67884. */
  67885. remainingCount: number;
  67886. /**
  67887. * Defines the total number of tasks
  67888. */
  67889. totalCount: number;
  67890. /**
  67891. * Defines the task that was just processed
  67892. */
  67893. task: AbstractAssetTask;
  67894. }
  67895. /**
  67896. * Class used to share progress information about assets loading
  67897. */
  67898. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67899. /**
  67900. * Defines the number of remaining tasks to process
  67901. */
  67902. remainingCount: number;
  67903. /**
  67904. * Defines the total number of tasks
  67905. */
  67906. totalCount: number;
  67907. /**
  67908. * Defines the task that was just processed
  67909. */
  67910. task: AbstractAssetTask;
  67911. /**
  67912. * Creates a AssetsProgressEvent
  67913. * @param remainingCount defines the number of remaining tasks to process
  67914. * @param totalCount defines the total number of tasks
  67915. * @param task defines the task that was just processed
  67916. */
  67917. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67918. }
  67919. /**
  67920. * Define a task used by AssetsManager to load meshes
  67921. */
  67922. export class MeshAssetTask extends AbstractAssetTask {
  67923. /**
  67924. * Defines the name of the task
  67925. */
  67926. name: string;
  67927. /**
  67928. * Defines the list of mesh's names you want to load
  67929. */
  67930. meshesNames: any;
  67931. /**
  67932. * Defines the root url to use as a base to load your meshes and associated resources
  67933. */
  67934. rootUrl: string;
  67935. /**
  67936. * Defines the filename of the scene to load from
  67937. */
  67938. sceneFilename: string;
  67939. /**
  67940. * Gets the list of loaded meshes
  67941. */
  67942. loadedMeshes: Array<AbstractMesh>;
  67943. /**
  67944. * Gets the list of loaded particle systems
  67945. */
  67946. loadedParticleSystems: Array<IParticleSystem>;
  67947. /**
  67948. * Gets the list of loaded skeletons
  67949. */
  67950. loadedSkeletons: Array<Skeleton>;
  67951. /**
  67952. * Gets the list of loaded animation groups
  67953. */
  67954. loadedAnimationGroups: Array<AnimationGroup>;
  67955. /**
  67956. * Callback called when the task is successful
  67957. */
  67958. onSuccess: (task: MeshAssetTask) => void;
  67959. /**
  67960. * Callback called when the task is successful
  67961. */
  67962. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67963. /**
  67964. * Creates a new MeshAssetTask
  67965. * @param name defines the name of the task
  67966. * @param meshesNames defines the list of mesh's names you want to load
  67967. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67968. * @param sceneFilename defines the filename of the scene to load from
  67969. */
  67970. constructor(
  67971. /**
  67972. * Defines the name of the task
  67973. */
  67974. name: string,
  67975. /**
  67976. * Defines the list of mesh's names you want to load
  67977. */
  67978. meshesNames: any,
  67979. /**
  67980. * Defines the root url to use as a base to load your meshes and associated resources
  67981. */
  67982. rootUrl: string,
  67983. /**
  67984. * Defines the filename of the scene to load from
  67985. */
  67986. sceneFilename: string);
  67987. /**
  67988. * Execute the current task
  67989. * @param scene defines the scene where you want your assets to be loaded
  67990. * @param onSuccess is a callback called when the task is successfully executed
  67991. * @param onError is a callback called if an error occurs
  67992. */
  67993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67994. }
  67995. /**
  67996. * Define a task used by AssetsManager to load text content
  67997. */
  67998. export class TextFileAssetTask extends AbstractAssetTask {
  67999. /**
  68000. * Defines the name of the task
  68001. */
  68002. name: string;
  68003. /**
  68004. * Defines the location of the file to load
  68005. */
  68006. url: string;
  68007. /**
  68008. * Gets the loaded text string
  68009. */
  68010. text: string;
  68011. /**
  68012. * Callback called when the task is successful
  68013. */
  68014. onSuccess: (task: TextFileAssetTask) => void;
  68015. /**
  68016. * Callback called when the task is successful
  68017. */
  68018. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68019. /**
  68020. * Creates a new TextFileAssetTask object
  68021. * @param name defines the name of the task
  68022. * @param url defines the location of the file to load
  68023. */
  68024. constructor(
  68025. /**
  68026. * Defines the name of the task
  68027. */
  68028. name: string,
  68029. /**
  68030. * Defines the location of the file to load
  68031. */
  68032. url: string);
  68033. /**
  68034. * Execute the current task
  68035. * @param scene defines the scene where you want your assets to be loaded
  68036. * @param onSuccess is a callback called when the task is successfully executed
  68037. * @param onError is a callback called if an error occurs
  68038. */
  68039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68040. }
  68041. /**
  68042. * Define a task used by AssetsManager to load binary data
  68043. */
  68044. export class BinaryFileAssetTask extends AbstractAssetTask {
  68045. /**
  68046. * Defines the name of the task
  68047. */
  68048. name: string;
  68049. /**
  68050. * Defines the location of the file to load
  68051. */
  68052. url: string;
  68053. /**
  68054. * Gets the lodaded data (as an array buffer)
  68055. */
  68056. data: ArrayBuffer;
  68057. /**
  68058. * Callback called when the task is successful
  68059. */
  68060. onSuccess: (task: BinaryFileAssetTask) => void;
  68061. /**
  68062. * Callback called when the task is successful
  68063. */
  68064. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68065. /**
  68066. * Creates a new BinaryFileAssetTask object
  68067. * @param name defines the name of the new task
  68068. * @param url defines the location of the file to load
  68069. */
  68070. constructor(
  68071. /**
  68072. * Defines the name of the task
  68073. */
  68074. name: string,
  68075. /**
  68076. * Defines the location of the file to load
  68077. */
  68078. url: string);
  68079. /**
  68080. * Execute the current task
  68081. * @param scene defines the scene where you want your assets to be loaded
  68082. * @param onSuccess is a callback called when the task is successfully executed
  68083. * @param onError is a callback called if an error occurs
  68084. */
  68085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68086. }
  68087. /**
  68088. * Define a task used by AssetsManager to load images
  68089. */
  68090. export class ImageAssetTask extends AbstractAssetTask {
  68091. /**
  68092. * Defines the name of the task
  68093. */
  68094. name: string;
  68095. /**
  68096. * Defines the location of the image to load
  68097. */
  68098. url: string;
  68099. /**
  68100. * Gets the loaded images
  68101. */
  68102. image: HTMLImageElement;
  68103. /**
  68104. * Callback called when the task is successful
  68105. */
  68106. onSuccess: (task: ImageAssetTask) => void;
  68107. /**
  68108. * Callback called when the task is successful
  68109. */
  68110. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68111. /**
  68112. * Creates a new ImageAssetTask
  68113. * @param name defines the name of the task
  68114. * @param url defines the location of the image to load
  68115. */
  68116. constructor(
  68117. /**
  68118. * Defines the name of the task
  68119. */
  68120. name: string,
  68121. /**
  68122. * Defines the location of the image to load
  68123. */
  68124. url: string);
  68125. /**
  68126. * Execute the current task
  68127. * @param scene defines the scene where you want your assets to be loaded
  68128. * @param onSuccess is a callback called when the task is successfully executed
  68129. * @param onError is a callback called if an error occurs
  68130. */
  68131. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68132. }
  68133. /**
  68134. * Defines the interface used by texture loading tasks
  68135. */
  68136. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68137. /**
  68138. * Gets the loaded texture
  68139. */
  68140. texture: TEX;
  68141. }
  68142. /**
  68143. * Define a task used by AssetsManager to load 2D textures
  68144. */
  68145. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68146. /**
  68147. * Defines the name of the task
  68148. */
  68149. name: string;
  68150. /**
  68151. * Defines the location of the file to load
  68152. */
  68153. url: string;
  68154. /**
  68155. * Defines if mipmap should not be generated (default is false)
  68156. */
  68157. noMipmap?: boolean | undefined;
  68158. /**
  68159. * Defines if texture must be inverted on Y axis (default is true)
  68160. */
  68161. invertY: boolean;
  68162. /**
  68163. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68164. */
  68165. samplingMode: number;
  68166. /**
  68167. * Gets the loaded texture
  68168. */
  68169. texture: Texture;
  68170. /**
  68171. * Callback called when the task is successful
  68172. */
  68173. onSuccess: (task: TextureAssetTask) => void;
  68174. /**
  68175. * Callback called when the task is successful
  68176. */
  68177. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68178. /**
  68179. * Creates a new TextureAssetTask object
  68180. * @param name defines the name of the task
  68181. * @param url defines the location of the file to load
  68182. * @param noMipmap defines if mipmap should not be generated (default is false)
  68183. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68184. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68185. */
  68186. constructor(
  68187. /**
  68188. * Defines the name of the task
  68189. */
  68190. name: string,
  68191. /**
  68192. * Defines the location of the file to load
  68193. */
  68194. url: string,
  68195. /**
  68196. * Defines if mipmap should not be generated (default is false)
  68197. */
  68198. noMipmap?: boolean | undefined,
  68199. /**
  68200. * Defines if texture must be inverted on Y axis (default is true)
  68201. */
  68202. invertY?: boolean,
  68203. /**
  68204. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68205. */
  68206. samplingMode?: number);
  68207. /**
  68208. * Execute the current task
  68209. * @param scene defines the scene where you want your assets to be loaded
  68210. * @param onSuccess is a callback called when the task is successfully executed
  68211. * @param onError is a callback called if an error occurs
  68212. */
  68213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68214. }
  68215. /**
  68216. * Define a task used by AssetsManager to load cube textures
  68217. */
  68218. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68219. /**
  68220. * Defines the name of the task
  68221. */
  68222. name: string;
  68223. /**
  68224. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68225. */
  68226. url: string;
  68227. /**
  68228. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68229. */
  68230. extensions?: string[] | undefined;
  68231. /**
  68232. * Defines if mipmaps should not be generated (default is false)
  68233. */
  68234. noMipmap?: boolean | undefined;
  68235. /**
  68236. * Defines the explicit list of files (undefined by default)
  68237. */
  68238. files?: string[] | undefined;
  68239. /**
  68240. * Gets the loaded texture
  68241. */
  68242. texture: CubeTexture;
  68243. /**
  68244. * Callback called when the task is successful
  68245. */
  68246. onSuccess: (task: CubeTextureAssetTask) => void;
  68247. /**
  68248. * Callback called when the task is successful
  68249. */
  68250. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68251. /**
  68252. * Creates a new CubeTextureAssetTask
  68253. * @param name defines the name of the task
  68254. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68255. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68256. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68257. * @param files defines the explicit list of files (undefined by default)
  68258. */
  68259. constructor(
  68260. /**
  68261. * Defines the name of the task
  68262. */
  68263. name: string,
  68264. /**
  68265. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68266. */
  68267. url: string,
  68268. /**
  68269. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68270. */
  68271. extensions?: string[] | undefined,
  68272. /**
  68273. * Defines if mipmaps should not be generated (default is false)
  68274. */
  68275. noMipmap?: boolean | undefined,
  68276. /**
  68277. * Defines the explicit list of files (undefined by default)
  68278. */
  68279. files?: string[] | undefined);
  68280. /**
  68281. * Execute the current task
  68282. * @param scene defines the scene where you want your assets to be loaded
  68283. * @param onSuccess is a callback called when the task is successfully executed
  68284. * @param onError is a callback called if an error occurs
  68285. */
  68286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68287. }
  68288. /**
  68289. * Define a task used by AssetsManager to load HDR cube textures
  68290. */
  68291. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68292. /**
  68293. * Defines the name of the task
  68294. */
  68295. name: string;
  68296. /**
  68297. * Defines the location of the file to load
  68298. */
  68299. url: string;
  68300. /**
  68301. * Defines the desired size (the more it increases the longer the generation will be)
  68302. */
  68303. size: number;
  68304. /**
  68305. * Defines if mipmaps should not be generated (default is false)
  68306. */
  68307. noMipmap: boolean;
  68308. /**
  68309. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68310. */
  68311. generateHarmonics: boolean;
  68312. /**
  68313. * 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)
  68314. */
  68315. gammaSpace: boolean;
  68316. /**
  68317. * Internal Use Only
  68318. */
  68319. reserved: boolean;
  68320. /**
  68321. * Gets the loaded texture
  68322. */
  68323. texture: HDRCubeTexture;
  68324. /**
  68325. * Callback called when the task is successful
  68326. */
  68327. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68328. /**
  68329. * Callback called when the task is successful
  68330. */
  68331. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68332. /**
  68333. * Creates a new HDRCubeTextureAssetTask object
  68334. * @param name defines the name of the task
  68335. * @param url defines the location of the file to load
  68336. * @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.
  68337. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68338. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68339. * @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)
  68340. * @param reserved Internal use only
  68341. */
  68342. constructor(
  68343. /**
  68344. * Defines the name of the task
  68345. */
  68346. name: string,
  68347. /**
  68348. * Defines the location of the file to load
  68349. */
  68350. url: string,
  68351. /**
  68352. * Defines the desired size (the more it increases the longer the generation will be)
  68353. */
  68354. size: number,
  68355. /**
  68356. * Defines if mipmaps should not be generated (default is false)
  68357. */
  68358. noMipmap?: boolean,
  68359. /**
  68360. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68361. */
  68362. generateHarmonics?: boolean,
  68363. /**
  68364. * 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)
  68365. */
  68366. gammaSpace?: boolean,
  68367. /**
  68368. * Internal Use Only
  68369. */
  68370. reserved?: boolean);
  68371. /**
  68372. * Execute the current task
  68373. * @param scene defines the scene where you want your assets to be loaded
  68374. * @param onSuccess is a callback called when the task is successfully executed
  68375. * @param onError is a callback called if an error occurs
  68376. */
  68377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68378. }
  68379. /**
  68380. * Define a task used by AssetsManager to load Equirectangular cube textures
  68381. */
  68382. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68383. /**
  68384. * Defines the name of the task
  68385. */
  68386. name: string;
  68387. /**
  68388. * Defines the location of the file to load
  68389. */
  68390. url: string;
  68391. /**
  68392. * Defines the desired size (the more it increases the longer the generation will be)
  68393. */
  68394. size: number;
  68395. /**
  68396. * Defines if mipmaps should not be generated (default is false)
  68397. */
  68398. noMipmap: boolean;
  68399. /**
  68400. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68401. * but the standard material would require them in Gamma space) (default is true)
  68402. */
  68403. gammaSpace: boolean;
  68404. /**
  68405. * Gets the loaded texture
  68406. */
  68407. texture: EquiRectangularCubeTexture;
  68408. /**
  68409. * Callback called when the task is successful
  68410. */
  68411. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68412. /**
  68413. * Callback called when the task is successful
  68414. */
  68415. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68416. /**
  68417. * Creates a new EquiRectangularCubeTextureAssetTask object
  68418. * @param name defines the name of the task
  68419. * @param url defines the location of the file to load
  68420. * @param size defines the desired size (the more it increases the longer the generation will be)
  68421. * If the size is omitted this implies you are using a preprocessed cubemap.
  68422. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68423. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68424. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68425. * (default is true)
  68426. */
  68427. constructor(
  68428. /**
  68429. * Defines the name of the task
  68430. */
  68431. name: string,
  68432. /**
  68433. * Defines the location of the file to load
  68434. */
  68435. url: string,
  68436. /**
  68437. * Defines the desired size (the more it increases the longer the generation will be)
  68438. */
  68439. size: number,
  68440. /**
  68441. * Defines if mipmaps should not be generated (default is false)
  68442. */
  68443. noMipmap?: boolean,
  68444. /**
  68445. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68446. * but the standard material would require them in Gamma space) (default is true)
  68447. */
  68448. gammaSpace?: boolean);
  68449. /**
  68450. * Execute the current task
  68451. * @param scene defines the scene where you want your assets to be loaded
  68452. * @param onSuccess is a callback called when the task is successfully executed
  68453. * @param onError is a callback called if an error occurs
  68454. */
  68455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68456. }
  68457. /**
  68458. * This class can be used to easily import assets into a scene
  68459. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68460. */
  68461. export class AssetsManager {
  68462. private _scene;
  68463. private _isLoading;
  68464. protected _tasks: AbstractAssetTask[];
  68465. protected _waitingTasksCount: number;
  68466. protected _totalTasksCount: number;
  68467. /**
  68468. * Callback called when all tasks are processed
  68469. */
  68470. onFinish: (tasks: AbstractAssetTask[]) => void;
  68471. /**
  68472. * Callback called when a task is successful
  68473. */
  68474. onTaskSuccess: (task: AbstractAssetTask) => void;
  68475. /**
  68476. * Callback called when a task had an error
  68477. */
  68478. onTaskError: (task: AbstractAssetTask) => void;
  68479. /**
  68480. * Callback called when a task is done (whatever the result is)
  68481. */
  68482. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68483. /**
  68484. * Observable called when all tasks are processed
  68485. */
  68486. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68487. /**
  68488. * Observable called when a task had an error
  68489. */
  68490. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68491. /**
  68492. * Observable called when all tasks were executed
  68493. */
  68494. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68495. /**
  68496. * Observable called when a task is done (whatever the result is)
  68497. */
  68498. onProgressObservable: Observable<IAssetsProgressEvent>;
  68499. /**
  68500. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68501. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68502. */
  68503. useDefaultLoadingScreen: boolean;
  68504. /**
  68505. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68506. * when all assets have been downloaded.
  68507. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68508. */
  68509. autoHideLoadingUI: boolean;
  68510. /**
  68511. * Creates a new AssetsManager
  68512. * @param scene defines the scene to work on
  68513. */
  68514. constructor(scene: Scene);
  68515. /**
  68516. * Add a MeshAssetTask to the list of active tasks
  68517. * @param taskName defines the name of the new task
  68518. * @param meshesNames defines the name of meshes to load
  68519. * @param rootUrl defines the root url to use to locate files
  68520. * @param sceneFilename defines the filename of the scene file
  68521. * @returns a new MeshAssetTask object
  68522. */
  68523. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68524. /**
  68525. * Add a TextFileAssetTask to the list of active tasks
  68526. * @param taskName defines the name of the new task
  68527. * @param url defines the url of the file to load
  68528. * @returns a new TextFileAssetTask object
  68529. */
  68530. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68531. /**
  68532. * Add a BinaryFileAssetTask to the list of active tasks
  68533. * @param taskName defines the name of the new task
  68534. * @param url defines the url of the file to load
  68535. * @returns a new BinaryFileAssetTask object
  68536. */
  68537. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68538. /**
  68539. * Add a ImageAssetTask to the list of active tasks
  68540. * @param taskName defines the name of the new task
  68541. * @param url defines the url of the file to load
  68542. * @returns a new ImageAssetTask object
  68543. */
  68544. addImageTask(taskName: string, url: string): ImageAssetTask;
  68545. /**
  68546. * Add a TextureAssetTask to the list of active tasks
  68547. * @param taskName defines the name of the new task
  68548. * @param url defines the url of the file to load
  68549. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68550. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68551. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68552. * @returns a new TextureAssetTask object
  68553. */
  68554. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68555. /**
  68556. * Add a CubeTextureAssetTask to the list of active tasks
  68557. * @param taskName defines the name of the new task
  68558. * @param url defines the url of the file to load
  68559. * @param extensions defines the extension to use to load the cube map (can be null)
  68560. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68561. * @param files defines the list of files to load (can be null)
  68562. * @returns a new CubeTextureAssetTask object
  68563. */
  68564. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68565. /**
  68566. *
  68567. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68568. * @param taskName defines the name of the new task
  68569. * @param url defines the url of the file to load
  68570. * @param size defines the size you want for the cubemap (can be null)
  68571. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68572. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68573. * @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)
  68574. * @param reserved Internal use only
  68575. * @returns a new HDRCubeTextureAssetTask object
  68576. */
  68577. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68578. /**
  68579. *
  68580. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68581. * @param taskName defines the name of the new task
  68582. * @param url defines the url of the file to load
  68583. * @param size defines the size you want for the cubemap (can be null)
  68584. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68585. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68586. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68587. * @returns a new EquiRectangularCubeTextureAssetTask object
  68588. */
  68589. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68590. /**
  68591. * Remove a task from the assets manager.
  68592. * @param task the task to remove
  68593. */
  68594. removeTask(task: AbstractAssetTask): void;
  68595. private _decreaseWaitingTasksCount;
  68596. private _runTask;
  68597. /**
  68598. * Reset the AssetsManager and remove all tasks
  68599. * @return the current instance of the AssetsManager
  68600. */
  68601. reset(): AssetsManager;
  68602. /**
  68603. * Start the loading process
  68604. * @return the current instance of the AssetsManager
  68605. */
  68606. load(): AssetsManager;
  68607. /**
  68608. * Start the loading process as an async operation
  68609. * @return a promise returning the list of failed tasks
  68610. */
  68611. loadAsync(): Promise<void>;
  68612. }
  68613. }
  68614. declare module BABYLON {
  68615. /**
  68616. * Wrapper class for promise with external resolve and reject.
  68617. */
  68618. export class Deferred<T> {
  68619. /**
  68620. * The promise associated with this deferred object.
  68621. */
  68622. readonly promise: Promise<T>;
  68623. private _resolve;
  68624. private _reject;
  68625. /**
  68626. * The resolve method of the promise associated with this deferred object.
  68627. */
  68628. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68629. /**
  68630. * The reject method of the promise associated with this deferred object.
  68631. */
  68632. get reject(): (reason?: any) => void;
  68633. /**
  68634. * Constructor for this deferred object.
  68635. */
  68636. constructor();
  68637. }
  68638. }
  68639. declare module BABYLON {
  68640. /**
  68641. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68642. */
  68643. export class MeshExploder {
  68644. private _centerMesh;
  68645. private _meshes;
  68646. private _meshesOrigins;
  68647. private _toCenterVectors;
  68648. private _scaledDirection;
  68649. private _newPosition;
  68650. private _centerPosition;
  68651. /**
  68652. * Explodes meshes from a center mesh.
  68653. * @param meshes The meshes to explode.
  68654. * @param centerMesh The mesh to be center of explosion.
  68655. */
  68656. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68657. private _setCenterMesh;
  68658. /**
  68659. * Get class name
  68660. * @returns "MeshExploder"
  68661. */
  68662. getClassName(): string;
  68663. /**
  68664. * "Exploded meshes"
  68665. * @returns Array of meshes with the centerMesh at index 0.
  68666. */
  68667. getMeshes(): Array<Mesh>;
  68668. /**
  68669. * Explodes meshes giving a specific direction
  68670. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68671. */
  68672. explode(direction?: number): void;
  68673. }
  68674. }
  68675. declare module BABYLON {
  68676. /**
  68677. * Class used to help managing file picking and drag'n'drop
  68678. */
  68679. export class FilesInput {
  68680. /**
  68681. * List of files ready to be loaded
  68682. */
  68683. static get FilesToLoad(): {
  68684. [key: string]: File;
  68685. };
  68686. /**
  68687. * Callback called when a file is processed
  68688. */
  68689. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68690. private _engine;
  68691. private _currentScene;
  68692. private _sceneLoadedCallback;
  68693. private _progressCallback;
  68694. private _additionalRenderLoopLogicCallback;
  68695. private _textureLoadingCallback;
  68696. private _startingProcessingFilesCallback;
  68697. private _onReloadCallback;
  68698. private _errorCallback;
  68699. private _elementToMonitor;
  68700. private _sceneFileToLoad;
  68701. private _filesToLoad;
  68702. /**
  68703. * Creates a new FilesInput
  68704. * @param engine defines the rendering engine
  68705. * @param scene defines the hosting scene
  68706. * @param sceneLoadedCallback callback called when scene is loaded
  68707. * @param progressCallback callback called to track progress
  68708. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68709. * @param textureLoadingCallback callback called when a texture is loading
  68710. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68711. * @param onReloadCallback callback called when a reload is requested
  68712. * @param errorCallback callback call if an error occurs
  68713. */
  68714. 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);
  68715. private _dragEnterHandler;
  68716. private _dragOverHandler;
  68717. private _dropHandler;
  68718. /**
  68719. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68720. * @param elementToMonitor defines the DOM element to track
  68721. */
  68722. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68723. /**
  68724. * Release all associated resources
  68725. */
  68726. dispose(): void;
  68727. private renderFunction;
  68728. private drag;
  68729. private drop;
  68730. private _traverseFolder;
  68731. private _processFiles;
  68732. /**
  68733. * Load files from a drop event
  68734. * @param event defines the drop event to use as source
  68735. */
  68736. loadFiles(event: any): void;
  68737. private _processReload;
  68738. /**
  68739. * Reload the current scene from the loaded files
  68740. */
  68741. reload(): void;
  68742. }
  68743. }
  68744. declare module BABYLON {
  68745. /**
  68746. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68748. */
  68749. export class SceneOptimization {
  68750. /**
  68751. * Defines the priority of this optimization (0 by default which means first in the list)
  68752. */
  68753. priority: number;
  68754. /**
  68755. * Gets a string describing the action executed by the current optimization
  68756. * @returns description string
  68757. */
  68758. getDescription(): string;
  68759. /**
  68760. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68761. * @param scene defines the current scene where to apply this optimization
  68762. * @param optimizer defines the current optimizer
  68763. * @returns true if everything that can be done was applied
  68764. */
  68765. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68766. /**
  68767. * Creates the SceneOptimization object
  68768. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68769. * @param desc defines the description associated with the optimization
  68770. */
  68771. constructor(
  68772. /**
  68773. * Defines the priority of this optimization (0 by default which means first in the list)
  68774. */
  68775. priority?: number);
  68776. }
  68777. /**
  68778. * Defines an optimization used to reduce the size of render target textures
  68779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68780. */
  68781. export class TextureOptimization extends SceneOptimization {
  68782. /**
  68783. * Defines the priority of this optimization (0 by default which means first in the list)
  68784. */
  68785. priority: number;
  68786. /**
  68787. * 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
  68788. */
  68789. maximumSize: number;
  68790. /**
  68791. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68792. */
  68793. step: number;
  68794. /**
  68795. * Gets a string describing the action executed by the current optimization
  68796. * @returns description string
  68797. */
  68798. getDescription(): string;
  68799. /**
  68800. * Creates the TextureOptimization object
  68801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68802. * @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
  68803. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68804. */
  68805. constructor(
  68806. /**
  68807. * Defines the priority of this optimization (0 by default which means first in the list)
  68808. */
  68809. priority?: number,
  68810. /**
  68811. * 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
  68812. */
  68813. maximumSize?: number,
  68814. /**
  68815. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68816. */
  68817. step?: number);
  68818. /**
  68819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68820. * @param scene defines the current scene where to apply this optimization
  68821. * @param optimizer defines the current optimizer
  68822. * @returns true if everything that can be done was applied
  68823. */
  68824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68825. }
  68826. /**
  68827. * Defines an optimization used to increase or decrease the rendering resolution
  68828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68829. */
  68830. export class HardwareScalingOptimization extends SceneOptimization {
  68831. /**
  68832. * Defines the priority of this optimization (0 by default which means first in the list)
  68833. */
  68834. priority: number;
  68835. /**
  68836. * Defines the maximum scale to use (2 by default)
  68837. */
  68838. maximumScale: number;
  68839. /**
  68840. * Defines the step to use between two passes (0.5 by default)
  68841. */
  68842. step: number;
  68843. private _currentScale;
  68844. private _directionOffset;
  68845. /**
  68846. * Gets a string describing the action executed by the current optimization
  68847. * @return description string
  68848. */
  68849. getDescription(): string;
  68850. /**
  68851. * Creates the HardwareScalingOptimization object
  68852. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68853. * @param maximumScale defines the maximum scale to use (2 by default)
  68854. * @param step defines the step to use between two passes (0.5 by default)
  68855. */
  68856. constructor(
  68857. /**
  68858. * Defines the priority of this optimization (0 by default which means first in the list)
  68859. */
  68860. priority?: number,
  68861. /**
  68862. * Defines the maximum scale to use (2 by default)
  68863. */
  68864. maximumScale?: number,
  68865. /**
  68866. * Defines the step to use between two passes (0.5 by default)
  68867. */
  68868. step?: number);
  68869. /**
  68870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68871. * @param scene defines the current scene where to apply this optimization
  68872. * @param optimizer defines the current optimizer
  68873. * @returns true if everything that can be done was applied
  68874. */
  68875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68876. }
  68877. /**
  68878. * Defines an optimization used to remove shadows
  68879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68880. */
  68881. export class ShadowsOptimization extends SceneOptimization {
  68882. /**
  68883. * Gets a string describing the action executed by the current optimization
  68884. * @return description string
  68885. */
  68886. getDescription(): string;
  68887. /**
  68888. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68889. * @param scene defines the current scene where to apply this optimization
  68890. * @param optimizer defines the current optimizer
  68891. * @returns true if everything that can be done was applied
  68892. */
  68893. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68894. }
  68895. /**
  68896. * Defines an optimization used to turn post-processes off
  68897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68898. */
  68899. export class PostProcessesOptimization extends SceneOptimization {
  68900. /**
  68901. * Gets a string describing the action executed by the current optimization
  68902. * @return description string
  68903. */
  68904. getDescription(): string;
  68905. /**
  68906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68907. * @param scene defines the current scene where to apply this optimization
  68908. * @param optimizer defines the current optimizer
  68909. * @returns true if everything that can be done was applied
  68910. */
  68911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68912. }
  68913. /**
  68914. * Defines an optimization used to turn lens flares off
  68915. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68916. */
  68917. export class LensFlaresOptimization extends SceneOptimization {
  68918. /**
  68919. * Gets a string describing the action executed by the current optimization
  68920. * @return description string
  68921. */
  68922. getDescription(): string;
  68923. /**
  68924. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68925. * @param scene defines the current scene where to apply this optimization
  68926. * @param optimizer defines the current optimizer
  68927. * @returns true if everything that can be done was applied
  68928. */
  68929. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68930. }
  68931. /**
  68932. * Defines an optimization based on user defined callback.
  68933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68934. */
  68935. export class CustomOptimization extends SceneOptimization {
  68936. /**
  68937. * Callback called to apply the custom optimization.
  68938. */
  68939. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68940. /**
  68941. * Callback called to get custom description
  68942. */
  68943. onGetDescription: () => string;
  68944. /**
  68945. * Gets a string describing the action executed by the current optimization
  68946. * @returns description string
  68947. */
  68948. getDescription(): string;
  68949. /**
  68950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68951. * @param scene defines the current scene where to apply this optimization
  68952. * @param optimizer defines the current optimizer
  68953. * @returns true if everything that can be done was applied
  68954. */
  68955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68956. }
  68957. /**
  68958. * Defines an optimization used to turn particles off
  68959. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68960. */
  68961. export class ParticlesOptimization extends SceneOptimization {
  68962. /**
  68963. * Gets a string describing the action executed by the current optimization
  68964. * @return description string
  68965. */
  68966. getDescription(): string;
  68967. /**
  68968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68969. * @param scene defines the current scene where to apply this optimization
  68970. * @param optimizer defines the current optimizer
  68971. * @returns true if everything that can be done was applied
  68972. */
  68973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68974. }
  68975. /**
  68976. * Defines an optimization used to turn render targets off
  68977. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68978. */
  68979. export class RenderTargetsOptimization extends SceneOptimization {
  68980. /**
  68981. * Gets a string describing the action executed by the current optimization
  68982. * @return description string
  68983. */
  68984. getDescription(): string;
  68985. /**
  68986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68987. * @param scene defines the current scene where to apply this optimization
  68988. * @param optimizer defines the current optimizer
  68989. * @returns true if everything that can be done was applied
  68990. */
  68991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68992. }
  68993. /**
  68994. * Defines an optimization used to merge meshes with compatible materials
  68995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68996. */
  68997. export class MergeMeshesOptimization extends SceneOptimization {
  68998. private static _UpdateSelectionTree;
  68999. /**
  69000. * Gets or sets a boolean which defines if optimization octree has to be updated
  69001. */
  69002. static get UpdateSelectionTree(): boolean;
  69003. /**
  69004. * Gets or sets a boolean which defines if optimization octree has to be updated
  69005. */
  69006. static set UpdateSelectionTree(value: boolean);
  69007. /**
  69008. * Gets a string describing the action executed by the current optimization
  69009. * @return description string
  69010. */
  69011. getDescription(): string;
  69012. private _canBeMerged;
  69013. /**
  69014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69015. * @param scene defines the current scene where to apply this optimization
  69016. * @param optimizer defines the current optimizer
  69017. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69018. * @returns true if everything that can be done was applied
  69019. */
  69020. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69021. }
  69022. /**
  69023. * Defines a list of options used by SceneOptimizer
  69024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69025. */
  69026. export class SceneOptimizerOptions {
  69027. /**
  69028. * Defines the target frame rate to reach (60 by default)
  69029. */
  69030. targetFrameRate: number;
  69031. /**
  69032. * Defines the interval between two checkes (2000ms by default)
  69033. */
  69034. trackerDuration: number;
  69035. /**
  69036. * Gets the list of optimizations to apply
  69037. */
  69038. optimizations: SceneOptimization[];
  69039. /**
  69040. * Creates a new list of options used by SceneOptimizer
  69041. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69042. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69043. */
  69044. constructor(
  69045. /**
  69046. * Defines the target frame rate to reach (60 by default)
  69047. */
  69048. targetFrameRate?: number,
  69049. /**
  69050. * Defines the interval between two checkes (2000ms by default)
  69051. */
  69052. trackerDuration?: number);
  69053. /**
  69054. * Add a new optimization
  69055. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69056. * @returns the current SceneOptimizerOptions
  69057. */
  69058. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69059. /**
  69060. * Add a new custom optimization
  69061. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69062. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69063. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69064. * @returns the current SceneOptimizerOptions
  69065. */
  69066. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69067. /**
  69068. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69069. * @param targetFrameRate defines the target frame rate (60 by default)
  69070. * @returns a SceneOptimizerOptions object
  69071. */
  69072. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69073. /**
  69074. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69075. * @param targetFrameRate defines the target frame rate (60 by default)
  69076. * @returns a SceneOptimizerOptions object
  69077. */
  69078. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69079. /**
  69080. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69081. * @param targetFrameRate defines the target frame rate (60 by default)
  69082. * @returns a SceneOptimizerOptions object
  69083. */
  69084. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69085. }
  69086. /**
  69087. * Class used to run optimizations in order to reach a target frame rate
  69088. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69089. */
  69090. export class SceneOptimizer implements IDisposable {
  69091. private _isRunning;
  69092. private _options;
  69093. private _scene;
  69094. private _currentPriorityLevel;
  69095. private _targetFrameRate;
  69096. private _trackerDuration;
  69097. private _currentFrameRate;
  69098. private _sceneDisposeObserver;
  69099. private _improvementMode;
  69100. /**
  69101. * Defines an observable called when the optimizer reaches the target frame rate
  69102. */
  69103. onSuccessObservable: Observable<SceneOptimizer>;
  69104. /**
  69105. * Defines an observable called when the optimizer enables an optimization
  69106. */
  69107. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69108. /**
  69109. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69110. */
  69111. onFailureObservable: Observable<SceneOptimizer>;
  69112. /**
  69113. * Gets a boolean indicating if the optimizer is in improvement mode
  69114. */
  69115. get isInImprovementMode(): boolean;
  69116. /**
  69117. * Gets the current priority level (0 at start)
  69118. */
  69119. get currentPriorityLevel(): number;
  69120. /**
  69121. * Gets the current frame rate checked by the SceneOptimizer
  69122. */
  69123. get currentFrameRate(): number;
  69124. /**
  69125. * Gets or sets the current target frame rate (60 by default)
  69126. */
  69127. get targetFrameRate(): number;
  69128. /**
  69129. * Gets or sets the current target frame rate (60 by default)
  69130. */
  69131. set targetFrameRate(value: number);
  69132. /**
  69133. * Gets or sets the current interval between two checks (every 2000ms by default)
  69134. */
  69135. get trackerDuration(): number;
  69136. /**
  69137. * Gets or sets the current interval between two checks (every 2000ms by default)
  69138. */
  69139. set trackerDuration(value: number);
  69140. /**
  69141. * Gets the list of active optimizations
  69142. */
  69143. get optimizations(): SceneOptimization[];
  69144. /**
  69145. * Creates a new SceneOptimizer
  69146. * @param scene defines the scene to work on
  69147. * @param options defines the options to use with the SceneOptimizer
  69148. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69149. * @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)
  69150. */
  69151. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69152. /**
  69153. * Stops the current optimizer
  69154. */
  69155. stop(): void;
  69156. /**
  69157. * Reset the optimizer to initial step (current priority level = 0)
  69158. */
  69159. reset(): void;
  69160. /**
  69161. * Start the optimizer. By default it will try to reach a specific framerate
  69162. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69163. */
  69164. start(): void;
  69165. private _checkCurrentState;
  69166. /**
  69167. * Release all resources
  69168. */
  69169. dispose(): void;
  69170. /**
  69171. * Helper function to create a SceneOptimizer with one single line of code
  69172. * @param scene defines the scene to work on
  69173. * @param options defines the options to use with the SceneOptimizer
  69174. * @param onSuccess defines a callback to call on success
  69175. * @param onFailure defines a callback to call on failure
  69176. * @returns the new SceneOptimizer object
  69177. */
  69178. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69179. }
  69180. }
  69181. declare module BABYLON {
  69182. /**
  69183. * Class used to serialize a scene into a string
  69184. */
  69185. export class SceneSerializer {
  69186. /**
  69187. * Clear cache used by a previous serialization
  69188. */
  69189. static ClearCache(): void;
  69190. /**
  69191. * Serialize a scene into a JSON compatible object
  69192. * @param scene defines the scene to serialize
  69193. * @returns a JSON compatible object
  69194. */
  69195. static Serialize(scene: Scene): any;
  69196. /**
  69197. * Serialize a mesh into a JSON compatible object
  69198. * @param toSerialize defines the mesh to serialize
  69199. * @param withParents defines if parents must be serialized as well
  69200. * @param withChildren defines if children must be serialized as well
  69201. * @returns a JSON compatible object
  69202. */
  69203. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69204. }
  69205. }
  69206. declare module BABYLON {
  69207. /**
  69208. * Class used to host texture specific utilities
  69209. */
  69210. export class TextureTools {
  69211. /**
  69212. * Uses the GPU to create a copy texture rescaled at a given size
  69213. * @param texture Texture to copy from
  69214. * @param width defines the desired width
  69215. * @param height defines the desired height
  69216. * @param useBilinearMode defines if bilinear mode has to be used
  69217. * @return the generated texture
  69218. */
  69219. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69220. }
  69221. }
  69222. declare module BABYLON {
  69223. /**
  69224. * This represents the different options available for the video capture.
  69225. */
  69226. export interface VideoRecorderOptions {
  69227. /** Defines the mime type of the video. */
  69228. mimeType: string;
  69229. /** Defines the FPS the video should be recorded at. */
  69230. fps: number;
  69231. /** Defines the chunk size for the recording data. */
  69232. recordChunckSize: number;
  69233. /** The audio tracks to attach to the recording. */
  69234. audioTracks?: MediaStreamTrack[];
  69235. }
  69236. /**
  69237. * This can help with recording videos from BabylonJS.
  69238. * This is based on the available WebRTC functionalities of the browser.
  69239. *
  69240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69241. */
  69242. export class VideoRecorder {
  69243. private static readonly _defaultOptions;
  69244. /**
  69245. * Returns whether or not the VideoRecorder is available in your browser.
  69246. * @param engine Defines the Babylon Engine.
  69247. * @returns true if supported otherwise false.
  69248. */
  69249. static IsSupported(engine: Engine): boolean;
  69250. private readonly _options;
  69251. private _canvas;
  69252. private _mediaRecorder;
  69253. private _recordedChunks;
  69254. private _fileName;
  69255. private _resolve;
  69256. private _reject;
  69257. /**
  69258. * True when a recording is already in progress.
  69259. */
  69260. get isRecording(): boolean;
  69261. /**
  69262. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69263. * @param engine Defines the BabylonJS Engine you wish to record.
  69264. * @param options Defines options that can be used to customize the capture.
  69265. */
  69266. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69267. /**
  69268. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69269. */
  69270. stopRecording(): void;
  69271. /**
  69272. * Starts recording the canvas for a max duration specified in parameters.
  69273. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69274. * If null no automatic download will start and you can rely on the promise to get the data back.
  69275. * @param maxDuration Defines the maximum recording time in seconds.
  69276. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69277. * @return A promise callback at the end of the recording with the video data in Blob.
  69278. */
  69279. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69280. /**
  69281. * Releases internal resources used during the recording.
  69282. */
  69283. dispose(): void;
  69284. private _handleDataAvailable;
  69285. private _handleError;
  69286. private _handleStop;
  69287. }
  69288. }
  69289. declare module BABYLON {
  69290. /**
  69291. * Class containing a set of static utilities functions for screenshots
  69292. */
  69293. export class ScreenshotTools {
  69294. /**
  69295. * Captures a screenshot of the current rendering
  69296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69297. * @param engine defines the rendering engine
  69298. * @param camera defines the source camera
  69299. * @param size This parameter can be set to a single number or to an object with the
  69300. * following (optional) properties: precision, width, height. If a single number is passed,
  69301. * it will be used for both width and height. If an object is passed, the screenshot size
  69302. * will be derived from the parameters. The precision property is a multiplier allowing
  69303. * rendering at a higher or lower resolution
  69304. * @param successCallback defines the callback receives a single parameter which contains the
  69305. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69306. * src parameter of an <img> to display it
  69307. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69308. * Check your browser for supported MIME types
  69309. */
  69310. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69311. /**
  69312. * Captures a screenshot of the current rendering
  69313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69314. * @param engine defines the rendering engine
  69315. * @param camera defines the source camera
  69316. * @param size This parameter can be set to a single number or to an object with the
  69317. * following (optional) properties: precision, width, height. If a single number is passed,
  69318. * it will be used for both width and height. If an object is passed, the screenshot size
  69319. * will be derived from the parameters. The precision property is a multiplier allowing
  69320. * rendering at a higher or lower resolution
  69321. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69322. * Check your browser for supported MIME types
  69323. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69324. * to the src parameter of an <img> to display it
  69325. */
  69326. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69327. /**
  69328. * Generates an image screenshot from the specified camera.
  69329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69330. * @param engine The engine to use for rendering
  69331. * @param camera The camera to use for rendering
  69332. * @param size This parameter can be set to a single number or to an object with the
  69333. * following (optional) properties: precision, width, height. If a single number is passed,
  69334. * it will be used for both width and height. If an object is passed, the screenshot size
  69335. * will be derived from the parameters. The precision property is a multiplier allowing
  69336. * rendering at a higher or lower resolution
  69337. * @param successCallback The callback receives a single parameter which contains the
  69338. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69339. * src parameter of an <img> to display it
  69340. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69341. * Check your browser for supported MIME types
  69342. * @param samples Texture samples (default: 1)
  69343. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69344. * @param fileName A name for for the downloaded file.
  69345. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69346. */
  69347. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69348. /**
  69349. * Generates an image screenshot from the specified camera.
  69350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69351. * @param engine The engine to use for rendering
  69352. * @param camera The camera to use for rendering
  69353. * @param size This parameter can be set to a single number or to an object with the
  69354. * following (optional) properties: precision, width, height. If a single number is passed,
  69355. * it will be used for both width and height. If an object is passed, the screenshot size
  69356. * will be derived from the parameters. The precision property is a multiplier allowing
  69357. * rendering at a higher or lower resolution
  69358. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69359. * Check your browser for supported MIME types
  69360. * @param samples Texture samples (default: 1)
  69361. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69362. * @param fileName A name for for the downloaded file.
  69363. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69364. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69365. * to the src parameter of an <img> to display it
  69366. */
  69367. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69368. /**
  69369. * Gets height and width for screenshot size
  69370. * @private
  69371. */
  69372. private static _getScreenshotSize;
  69373. }
  69374. }
  69375. declare module BABYLON {
  69376. /**
  69377. * Interface for a data buffer
  69378. */
  69379. export interface IDataBuffer {
  69380. /**
  69381. * Reads bytes from the data buffer.
  69382. * @param byteOffset The byte offset to read
  69383. * @param byteLength The byte length to read
  69384. * @returns A promise that resolves when the bytes are read
  69385. */
  69386. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69387. /**
  69388. * The byte length of the buffer.
  69389. */
  69390. readonly byteLength: number;
  69391. }
  69392. /**
  69393. * Utility class for reading from a data buffer
  69394. */
  69395. export class DataReader {
  69396. /**
  69397. * The data buffer associated with this data reader.
  69398. */
  69399. readonly buffer: IDataBuffer;
  69400. /**
  69401. * The current byte offset from the beginning of the data buffer.
  69402. */
  69403. byteOffset: number;
  69404. private _dataView;
  69405. private _dataByteOffset;
  69406. /**
  69407. * Constructor
  69408. * @param buffer The buffer to read
  69409. */
  69410. constructor(buffer: IDataBuffer);
  69411. /**
  69412. * Loads the given byte length.
  69413. * @param byteLength The byte length to load
  69414. * @returns A promise that resolves when the load is complete
  69415. */
  69416. loadAsync(byteLength: number): Promise<void>;
  69417. /**
  69418. * Read a unsigned 32-bit integer from the currently loaded data range.
  69419. * @returns The 32-bit integer read
  69420. */
  69421. readUint32(): number;
  69422. /**
  69423. * Read a byte array from the currently loaded data range.
  69424. * @param byteLength The byte length to read
  69425. * @returns The byte array read
  69426. */
  69427. readUint8Array(byteLength: number): Uint8Array;
  69428. /**
  69429. * Read a string from the currently loaded data range.
  69430. * @param byteLength The byte length to read
  69431. * @returns The string read
  69432. */
  69433. readString(byteLength: number): string;
  69434. /**
  69435. * Skips the given byte length the currently loaded data range.
  69436. * @param byteLength The byte length to skip
  69437. */
  69438. skipBytes(byteLength: number): void;
  69439. }
  69440. }
  69441. declare module BABYLON {
  69442. /**
  69443. * Class for storing data to local storage if available or in-memory storage otherwise
  69444. */
  69445. export class DataStorage {
  69446. private static _Storage;
  69447. private static _GetStorage;
  69448. /**
  69449. * Reads a string from the data storage
  69450. * @param key The key to read
  69451. * @param defaultValue The value if the key doesn't exist
  69452. * @returns The string value
  69453. */
  69454. static ReadString(key: string, defaultValue: string): string;
  69455. /**
  69456. * Writes a string to the data storage
  69457. * @param key The key to write
  69458. * @param value The value to write
  69459. */
  69460. static WriteString(key: string, value: string): void;
  69461. /**
  69462. * Reads a boolean from the data storage
  69463. * @param key The key to read
  69464. * @param defaultValue The value if the key doesn't exist
  69465. * @returns The boolean value
  69466. */
  69467. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69468. /**
  69469. * Writes a boolean to the data storage
  69470. * @param key The key to write
  69471. * @param value The value to write
  69472. */
  69473. static WriteBoolean(key: string, value: boolean): void;
  69474. /**
  69475. * Reads a number from the data storage
  69476. * @param key The key to read
  69477. * @param defaultValue The value if the key doesn't exist
  69478. * @returns The number value
  69479. */
  69480. static ReadNumber(key: string, defaultValue: number): number;
  69481. /**
  69482. * Writes a number to the data storage
  69483. * @param key The key to write
  69484. * @param value The value to write
  69485. */
  69486. static WriteNumber(key: string, value: number): void;
  69487. }
  69488. }
  69489. declare module BABYLON {
  69490. /**
  69491. * Options used for hit testing
  69492. */
  69493. export interface IWebXRLegacyHitTestOptions {
  69494. /**
  69495. * Only test when user interacted with the scene. Default - hit test every frame
  69496. */
  69497. testOnPointerDownOnly?: boolean;
  69498. /**
  69499. * The node to use to transform the local results to world coordinates
  69500. */
  69501. worldParentNode?: TransformNode;
  69502. }
  69503. /**
  69504. * Interface defining the babylon result of raycasting/hit-test
  69505. */
  69506. export interface IWebXRLegacyHitResult {
  69507. /**
  69508. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69509. */
  69510. transformationMatrix: Matrix;
  69511. /**
  69512. * The native hit test result
  69513. */
  69514. xrHitResult: XRHitResult | XRHitTestResult;
  69515. }
  69516. /**
  69517. * The currently-working hit-test module.
  69518. * Hit test (or Ray-casting) is used to interact with the real world.
  69519. * For further information read here - https://github.com/immersive-web/hit-test
  69520. */
  69521. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69522. /**
  69523. * options to use when constructing this feature
  69524. */
  69525. readonly options: IWebXRLegacyHitTestOptions;
  69526. private _direction;
  69527. private _mat;
  69528. private _onSelectEnabled;
  69529. private _origin;
  69530. /**
  69531. * The module's name
  69532. */
  69533. static readonly Name: string;
  69534. /**
  69535. * The (Babylon) version of this module.
  69536. * This is an integer representing the implementation version.
  69537. * This number does not correspond to the WebXR specs version
  69538. */
  69539. static readonly Version: number;
  69540. /**
  69541. * Populated with the last native XR Hit Results
  69542. */
  69543. lastNativeXRHitResults: XRHitResult[];
  69544. /**
  69545. * Triggered when new babylon (transformed) hit test results are available
  69546. */
  69547. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69548. /**
  69549. * Creates a new instance of the (legacy version) hit test feature
  69550. * @param _xrSessionManager an instance of WebXRSessionManager
  69551. * @param options options to use when constructing this feature
  69552. */
  69553. constructor(_xrSessionManager: WebXRSessionManager,
  69554. /**
  69555. * options to use when constructing this feature
  69556. */
  69557. options?: IWebXRLegacyHitTestOptions);
  69558. /**
  69559. * execute a hit test with an XR Ray
  69560. *
  69561. * @param xrSession a native xrSession that will execute this hit test
  69562. * @param xrRay the ray (position and direction) to use for ray-casting
  69563. * @param referenceSpace native XR reference space to use for the hit-test
  69564. * @param filter filter function that will filter the results
  69565. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69566. */
  69567. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69568. /**
  69569. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69570. * @param event the (select) event to use to select with
  69571. * @param referenceSpace the reference space to use for this hit test
  69572. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69573. */
  69574. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69575. /**
  69576. * attach this feature
  69577. * Will usually be called by the features manager
  69578. *
  69579. * @returns true if successful.
  69580. */
  69581. attach(): boolean;
  69582. /**
  69583. * detach this feature.
  69584. * Will usually be called by the features manager
  69585. *
  69586. * @returns true if successful.
  69587. */
  69588. detach(): boolean;
  69589. /**
  69590. * Dispose this feature and all of the resources attached
  69591. */
  69592. dispose(): void;
  69593. protected _onXRFrame(frame: XRFrame): void;
  69594. private _onHitTestResults;
  69595. private _onSelect;
  69596. }
  69597. }
  69598. declare module BABYLON {
  69599. /**
  69600. * Options used in the plane detector module
  69601. */
  69602. export interface IWebXRPlaneDetectorOptions {
  69603. /**
  69604. * The node to use to transform the local results to world coordinates
  69605. */
  69606. worldParentNode?: TransformNode;
  69607. }
  69608. /**
  69609. * A babylon interface for a WebXR plane.
  69610. * A Plane is actually a polygon, built from N points in space
  69611. *
  69612. * Supported in chrome 79, not supported in canary 81 ATM
  69613. */
  69614. export interface IWebXRPlane {
  69615. /**
  69616. * a babylon-assigned ID for this polygon
  69617. */
  69618. id: number;
  69619. /**
  69620. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69621. */
  69622. polygonDefinition: Array<Vector3>;
  69623. /**
  69624. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69625. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69626. */
  69627. transformationMatrix: Matrix;
  69628. /**
  69629. * the native xr-plane object
  69630. */
  69631. xrPlane: XRPlane;
  69632. }
  69633. /**
  69634. * The plane detector is used to detect planes in the real world when in AR
  69635. * For more information see https://github.com/immersive-web/real-world-geometry/
  69636. */
  69637. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69638. private _options;
  69639. private _detectedPlanes;
  69640. private _enabled;
  69641. private _lastFrameDetected;
  69642. /**
  69643. * The module's name
  69644. */
  69645. static readonly Name: string;
  69646. /**
  69647. * The (Babylon) version of this module.
  69648. * This is an integer representing the implementation version.
  69649. * This number does not correspond to the WebXR specs version
  69650. */
  69651. static readonly Version: number;
  69652. /**
  69653. * Observers registered here will be executed when a new plane was added to the session
  69654. */
  69655. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69656. /**
  69657. * Observers registered here will be executed when a plane is no longer detected in the session
  69658. */
  69659. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69660. /**
  69661. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69662. * This can execute N times every frame
  69663. */
  69664. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69665. /**
  69666. * construct a new Plane Detector
  69667. * @param _xrSessionManager an instance of xr Session manager
  69668. * @param _options configuration to use when constructing this feature
  69669. */
  69670. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69671. /**
  69672. * Dispose this feature and all of the resources attached
  69673. */
  69674. dispose(): void;
  69675. protected _onXRFrame(frame: XRFrame): void;
  69676. private _init;
  69677. private _updatePlaneWithXRPlane;
  69678. /**
  69679. * avoiding using Array.find for global support.
  69680. * @param xrPlane the plane to find in the array
  69681. */
  69682. private findIndexInPlaneArray;
  69683. }
  69684. }
  69685. declare module BABYLON {
  69686. /**
  69687. * Configuration options of the anchor system
  69688. */
  69689. export interface IWebXRAnchorSystemOptions {
  69690. /**
  69691. * Should a new anchor be added every time a select event is triggered
  69692. */
  69693. addAnchorOnSelect?: boolean;
  69694. /**
  69695. * should the anchor system use plane detection.
  69696. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69697. */
  69698. usePlaneDetection?: boolean;
  69699. /**
  69700. * a node that will be used to convert local to world coordinates
  69701. */
  69702. worldParentNode?: TransformNode;
  69703. }
  69704. /**
  69705. * A babylon container for an XR Anchor
  69706. */
  69707. export interface IWebXRAnchor {
  69708. /**
  69709. * A babylon-assigned ID for this anchor
  69710. */
  69711. id: number;
  69712. /**
  69713. * Transformation matrix to apply to an object attached to this anchor
  69714. */
  69715. transformationMatrix: Matrix;
  69716. /**
  69717. * The native anchor object
  69718. */
  69719. xrAnchor: XRAnchor;
  69720. }
  69721. /**
  69722. * An implementation of the anchor system of WebXR.
  69723. * Note that the current documented implementation is not available in any browser. Future implementations
  69724. * will use the frame to create an anchor and not the session or a detected plane
  69725. * For further information see https://github.com/immersive-web/anchors/
  69726. */
  69727. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69728. private _options;
  69729. private _enabled;
  69730. private _hitTestModule;
  69731. private _lastFrameDetected;
  69732. private _onSelect;
  69733. private _planeDetector;
  69734. private _trackedAnchors;
  69735. /**
  69736. * The module's name
  69737. */
  69738. static readonly Name: string;
  69739. /**
  69740. * The (Babylon) version of this module.
  69741. * This is an integer representing the implementation version.
  69742. * This number does not correspond to the WebXR specs version
  69743. */
  69744. static readonly Version: number;
  69745. /**
  69746. * Observers registered here will be executed when a new anchor was added to the session
  69747. */
  69748. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69749. /**
  69750. * Observers registered here will be executed when an anchor was removed from the session
  69751. */
  69752. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69753. /**
  69754. * Observers registered here will be executed when an existing anchor updates
  69755. * This can execute N times every frame
  69756. */
  69757. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69758. /**
  69759. * constructs a new anchor system
  69760. * @param _xrSessionManager an instance of WebXRSessionManager
  69761. * @param _options configuration object for this feature
  69762. */
  69763. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69764. /**
  69765. * Add anchor at a specific XR point.
  69766. *
  69767. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69768. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69769. * @returns a promise the fulfills when the anchor was created
  69770. */
  69771. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69772. /**
  69773. * attach this feature
  69774. * Will usually be called by the features manager
  69775. *
  69776. * @returns true if successful.
  69777. */
  69778. attach(): boolean;
  69779. /**
  69780. * detach this feature.
  69781. * Will usually be called by the features manager
  69782. *
  69783. * @returns true if successful.
  69784. */
  69785. detach(): boolean;
  69786. /**
  69787. * Dispose this feature and all of the resources attached
  69788. */
  69789. dispose(): void;
  69790. /**
  69791. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69792. * @param hitTestModule the hit-test module to use.
  69793. */
  69794. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69795. /**
  69796. * set the plane detector to use in order to create anchors from frames
  69797. * @param planeDetector the plane-detector module to use
  69798. * @param enable enable plane-anchors. default is true
  69799. */
  69800. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69801. protected _onXRFrame(frame: XRFrame): void;
  69802. /**
  69803. * avoiding using Array.find for global support.
  69804. * @param xrAnchor the plane to find in the array
  69805. */
  69806. private _findIndexInAnchorArray;
  69807. private _updateAnchorWithXRFrame;
  69808. }
  69809. }
  69810. declare module BABYLON {
  69811. /**
  69812. * Options interface for the background remover plugin
  69813. */
  69814. export interface IWebXRBackgroundRemoverOptions {
  69815. /**
  69816. * Further background meshes to disable when entering AR
  69817. */
  69818. backgroundMeshes?: AbstractMesh[];
  69819. /**
  69820. * flags to configure the removal of the environment helper.
  69821. * If not set, the entire background will be removed. If set, flags should be set as well.
  69822. */
  69823. environmentHelperRemovalFlags?: {
  69824. /**
  69825. * Should the skybox be removed (default false)
  69826. */
  69827. skyBox?: boolean;
  69828. /**
  69829. * Should the ground be removed (default false)
  69830. */
  69831. ground?: boolean;
  69832. };
  69833. /**
  69834. * don't disable the environment helper
  69835. */
  69836. ignoreEnvironmentHelper?: boolean;
  69837. }
  69838. /**
  69839. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69840. */
  69841. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69842. /**
  69843. * read-only options to be used in this module
  69844. */
  69845. readonly options: IWebXRBackgroundRemoverOptions;
  69846. /**
  69847. * The module's name
  69848. */
  69849. static readonly Name: string;
  69850. /**
  69851. * The (Babylon) version of this module.
  69852. * This is an integer representing the implementation version.
  69853. * This number does not correspond to the WebXR specs version
  69854. */
  69855. static readonly Version: number;
  69856. /**
  69857. * registered observers will be triggered when the background state changes
  69858. */
  69859. onBackgroundStateChangedObservable: Observable<boolean>;
  69860. /**
  69861. * constructs a new background remover module
  69862. * @param _xrSessionManager the session manager for this module
  69863. * @param options read-only options to be used in this module
  69864. */
  69865. constructor(_xrSessionManager: WebXRSessionManager,
  69866. /**
  69867. * read-only options to be used in this module
  69868. */
  69869. options?: IWebXRBackgroundRemoverOptions);
  69870. /**
  69871. * attach this feature
  69872. * Will usually be called by the features manager
  69873. *
  69874. * @returns true if successful.
  69875. */
  69876. attach(): boolean;
  69877. /**
  69878. * detach this feature.
  69879. * Will usually be called by the features manager
  69880. *
  69881. * @returns true if successful.
  69882. */
  69883. detach(): boolean;
  69884. /**
  69885. * Dispose this feature and all of the resources attached
  69886. */
  69887. dispose(): void;
  69888. protected _onXRFrame(_xrFrame: XRFrame): void;
  69889. private _setBackgroundState;
  69890. }
  69891. }
  69892. declare module BABYLON {
  69893. /**
  69894. * Options for the controller physics feature
  69895. */
  69896. export class IWebXRControllerPhysicsOptions {
  69897. /**
  69898. * Should the headset get its own impostor
  69899. */
  69900. enableHeadsetImpostor?: boolean;
  69901. /**
  69902. * Optional parameters for the headset impostor
  69903. */
  69904. headsetImpostorParams?: {
  69905. /**
  69906. * The type of impostor to create. Default is sphere
  69907. */
  69908. impostorType: number;
  69909. /**
  69910. * the size of the impostor. Defaults to 10cm
  69911. */
  69912. impostorSize?: number | {
  69913. width: number;
  69914. height: number;
  69915. depth: number;
  69916. };
  69917. /**
  69918. * Friction definitions
  69919. */
  69920. friction?: number;
  69921. /**
  69922. * Restitution
  69923. */
  69924. restitution?: number;
  69925. };
  69926. /**
  69927. * The physics properties of the future impostors
  69928. */
  69929. physicsProperties?: {
  69930. /**
  69931. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69932. * Note that this requires a physics engine that supports mesh impostors!
  69933. */
  69934. useControllerMesh?: boolean;
  69935. /**
  69936. * The type of impostor to create. Default is sphere
  69937. */
  69938. impostorType?: number;
  69939. /**
  69940. * the size of the impostor. Defaults to 10cm
  69941. */
  69942. impostorSize?: number | {
  69943. width: number;
  69944. height: number;
  69945. depth: number;
  69946. };
  69947. /**
  69948. * Friction definitions
  69949. */
  69950. friction?: number;
  69951. /**
  69952. * Restitution
  69953. */
  69954. restitution?: number;
  69955. };
  69956. /**
  69957. * the xr input to use with this pointer selection
  69958. */
  69959. xrInput: WebXRInput;
  69960. }
  69961. /**
  69962. * Add physics impostor to your webxr controllers,
  69963. * including naive calculation of their linear and angular velocity
  69964. */
  69965. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69966. private readonly _options;
  69967. private _attachController;
  69968. private _controllers;
  69969. private _debugMode;
  69970. private _delta;
  69971. private _headsetImpostor?;
  69972. private _headsetMesh?;
  69973. private _lastTimestamp;
  69974. private _tmpQuaternion;
  69975. private _tmpVector;
  69976. /**
  69977. * The module's name
  69978. */
  69979. static readonly Name: string;
  69980. /**
  69981. * The (Babylon) version of this module.
  69982. * This is an integer representing the implementation version.
  69983. * This number does not correspond to the webxr specs version
  69984. */
  69985. static readonly Version: number;
  69986. /**
  69987. * Construct a new Controller Physics Feature
  69988. * @param _xrSessionManager the corresponding xr session manager
  69989. * @param _options options to create this feature with
  69990. */
  69991. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69992. /**
  69993. * @hidden
  69994. * enable debugging - will show console outputs and the impostor mesh
  69995. */
  69996. _enablePhysicsDebug(): void;
  69997. /**
  69998. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69999. * @param xrController the controller to add
  70000. */
  70001. addController(xrController: WebXRInputSource): void;
  70002. /**
  70003. * attach this feature
  70004. * Will usually be called by the features manager
  70005. *
  70006. * @returns true if successful.
  70007. */
  70008. attach(): boolean;
  70009. /**
  70010. * detach this feature.
  70011. * Will usually be called by the features manager
  70012. *
  70013. * @returns true if successful.
  70014. */
  70015. detach(): boolean;
  70016. /**
  70017. * Get the headset impostor, if enabled
  70018. * @returns the impostor
  70019. */
  70020. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70021. /**
  70022. * Get the physics impostor of a specific controller.
  70023. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70024. * @param controller the controller or the controller id of which to get the impostor
  70025. * @returns the impostor or null
  70026. */
  70027. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70028. /**
  70029. * Update the physics properties provided in the constructor
  70030. * @param newProperties the new properties object
  70031. */
  70032. setPhysicsProperties(newProperties: {
  70033. impostorType?: number;
  70034. impostorSize?: number | {
  70035. width: number;
  70036. height: number;
  70037. depth: number;
  70038. };
  70039. friction?: number;
  70040. restitution?: number;
  70041. }): void;
  70042. protected _onXRFrame(_xrFrame: any): void;
  70043. private _detachController;
  70044. }
  70045. }
  70046. declare module BABYLON {
  70047. /**
  70048. * Options used for hit testing (version 2)
  70049. */
  70050. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70051. /**
  70052. * Do not create a permanent hit test. Will usually be used when only
  70053. * transient inputs are needed.
  70054. */
  70055. disablePermanentHitTest?: boolean;
  70056. /**
  70057. * Enable transient (for example touch-based) hit test inspections
  70058. */
  70059. enableTransientHitTest?: boolean;
  70060. /**
  70061. * Offset ray for the permanent hit test
  70062. */
  70063. offsetRay?: Vector3;
  70064. /**
  70065. * Offset ray for the transient hit test
  70066. */
  70067. transientOffsetRay?: Vector3;
  70068. /**
  70069. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70070. */
  70071. useReferenceSpace?: boolean;
  70072. }
  70073. /**
  70074. * Interface defining the babylon result of hit-test
  70075. */
  70076. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70077. /**
  70078. * The input source that generated this hit test (if transient)
  70079. */
  70080. inputSource?: XRInputSource;
  70081. /**
  70082. * Is this a transient hit test
  70083. */
  70084. isTransient?: boolean;
  70085. /**
  70086. * Position of the hit test result
  70087. */
  70088. position: Vector3;
  70089. /**
  70090. * Rotation of the hit test result
  70091. */
  70092. rotationQuaternion: Quaternion;
  70093. }
  70094. /**
  70095. * The currently-working hit-test module.
  70096. * Hit test (or Ray-casting) is used to interact with the real world.
  70097. * For further information read here - https://github.com/immersive-web/hit-test
  70098. *
  70099. * Tested on chrome (mobile) 80.
  70100. */
  70101. export class WebXRHitTest extends WebXRAbstractFeature {
  70102. /**
  70103. * options to use when constructing this feature
  70104. */
  70105. readonly options: IWebXRHitTestOptions;
  70106. private _tmpMat;
  70107. private _tmpPos;
  70108. private _tmpQuat;
  70109. private _transientXrHitTestSource;
  70110. private _xrHitTestSource;
  70111. private initHitTestSource;
  70112. /**
  70113. * The module's name
  70114. */
  70115. static readonly Name: string;
  70116. /**
  70117. * The (Babylon) version of this module.
  70118. * This is an integer representing the implementation version.
  70119. * This number does not correspond to the WebXR specs version
  70120. */
  70121. static readonly Version: number;
  70122. /**
  70123. * When set to true, each hit test will have its own position/rotation objects
  70124. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70125. * the developers will clone them or copy them as they see fit.
  70126. */
  70127. autoCloneTransformation: boolean;
  70128. /**
  70129. * Populated with the last native XR Hit Results
  70130. */
  70131. lastNativeXRHitResults: XRHitResult[];
  70132. /**
  70133. * Triggered when new babylon (transformed) hit test results are available
  70134. */
  70135. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70136. /**
  70137. * Use this to temporarily pause hit test checks.
  70138. */
  70139. paused: boolean;
  70140. /**
  70141. * Creates a new instance of the hit test feature
  70142. * @param _xrSessionManager an instance of WebXRSessionManager
  70143. * @param options options to use when constructing this feature
  70144. */
  70145. constructor(_xrSessionManager: WebXRSessionManager,
  70146. /**
  70147. * options to use when constructing this feature
  70148. */
  70149. options?: IWebXRHitTestOptions);
  70150. /**
  70151. * attach this feature
  70152. * Will usually be called by the features manager
  70153. *
  70154. * @returns true if successful.
  70155. */
  70156. attach(): boolean;
  70157. /**
  70158. * detach this feature.
  70159. * Will usually be called by the features manager
  70160. *
  70161. * @returns true if successful.
  70162. */
  70163. detach(): boolean;
  70164. /**
  70165. * Dispose this feature and all of the resources attached
  70166. */
  70167. dispose(): void;
  70168. protected _onXRFrame(frame: XRFrame): void;
  70169. private _processWebXRHitTestResult;
  70170. }
  70171. }
  70172. declare module BABYLON {
  70173. /**
  70174. * The motion controller class for all microsoft mixed reality controllers
  70175. */
  70176. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70177. protected readonly _mapping: {
  70178. defaultButton: {
  70179. valueNodeName: string;
  70180. unpressedNodeName: string;
  70181. pressedNodeName: string;
  70182. };
  70183. defaultAxis: {
  70184. valueNodeName: string;
  70185. minNodeName: string;
  70186. maxNodeName: string;
  70187. };
  70188. buttons: {
  70189. "xr-standard-trigger": {
  70190. rootNodeName: string;
  70191. componentProperty: string;
  70192. states: string[];
  70193. };
  70194. "xr-standard-squeeze": {
  70195. rootNodeName: string;
  70196. componentProperty: string;
  70197. states: string[];
  70198. };
  70199. "xr-standard-touchpad": {
  70200. rootNodeName: string;
  70201. labelAnchorNodeName: string;
  70202. touchPointNodeName: string;
  70203. };
  70204. "xr-standard-thumbstick": {
  70205. rootNodeName: string;
  70206. componentProperty: string;
  70207. states: string[];
  70208. };
  70209. };
  70210. axes: {
  70211. "xr-standard-touchpad": {
  70212. "x-axis": {
  70213. rootNodeName: string;
  70214. };
  70215. "y-axis": {
  70216. rootNodeName: string;
  70217. };
  70218. };
  70219. "xr-standard-thumbstick": {
  70220. "x-axis": {
  70221. rootNodeName: string;
  70222. };
  70223. "y-axis": {
  70224. rootNodeName: string;
  70225. };
  70226. };
  70227. };
  70228. };
  70229. /**
  70230. * The base url used to load the left and right controller models
  70231. */
  70232. static MODEL_BASE_URL: string;
  70233. /**
  70234. * The name of the left controller model file
  70235. */
  70236. static MODEL_LEFT_FILENAME: string;
  70237. /**
  70238. * The name of the right controller model file
  70239. */
  70240. static MODEL_RIGHT_FILENAME: string;
  70241. profileId: string;
  70242. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70243. protected _getFilenameAndPath(): {
  70244. filename: string;
  70245. path: string;
  70246. };
  70247. protected _getModelLoadingConstraints(): boolean;
  70248. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70249. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70250. protected _updateModel(): void;
  70251. }
  70252. }
  70253. declare module BABYLON {
  70254. /**
  70255. * The motion controller class for oculus touch (quest, rift).
  70256. * This class supports legacy mapping as well the standard xr mapping
  70257. */
  70258. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70259. private _forceLegacyControllers;
  70260. private _modelRootNode;
  70261. /**
  70262. * The base url used to load the left and right controller models
  70263. */
  70264. static MODEL_BASE_URL: string;
  70265. /**
  70266. * The name of the left controller model file
  70267. */
  70268. static MODEL_LEFT_FILENAME: string;
  70269. /**
  70270. * The name of the right controller model file
  70271. */
  70272. static MODEL_RIGHT_FILENAME: string;
  70273. /**
  70274. * Base Url for the Quest controller model.
  70275. */
  70276. static QUEST_MODEL_BASE_URL: string;
  70277. profileId: string;
  70278. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70279. protected _getFilenameAndPath(): {
  70280. filename: string;
  70281. path: string;
  70282. };
  70283. protected _getModelLoadingConstraints(): boolean;
  70284. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70285. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70286. protected _updateModel(): void;
  70287. /**
  70288. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70289. * between the touch and touch 2.
  70290. */
  70291. private _isQuest;
  70292. }
  70293. }
  70294. declare module BABYLON {
  70295. /**
  70296. * The motion controller class for the standard HTC-Vive controllers
  70297. */
  70298. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70299. private _modelRootNode;
  70300. /**
  70301. * The base url used to load the left and right controller models
  70302. */
  70303. static MODEL_BASE_URL: string;
  70304. /**
  70305. * File name for the controller model.
  70306. */
  70307. static MODEL_FILENAME: string;
  70308. profileId: string;
  70309. /**
  70310. * Create a new Vive motion controller object
  70311. * @param scene the scene to use to create this controller
  70312. * @param gamepadObject the corresponding gamepad object
  70313. * @param handness the handness of the controller
  70314. */
  70315. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70316. protected _getFilenameAndPath(): {
  70317. filename: string;
  70318. path: string;
  70319. };
  70320. protected _getModelLoadingConstraints(): boolean;
  70321. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70322. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70323. protected _updateModel(): void;
  70324. }
  70325. }
  70326. declare module BABYLON {
  70327. /**
  70328. * A cursor which tracks a point on a path
  70329. */
  70330. export class PathCursor {
  70331. private path;
  70332. /**
  70333. * Stores path cursor callbacks for when an onchange event is triggered
  70334. */
  70335. private _onchange;
  70336. /**
  70337. * The value of the path cursor
  70338. */
  70339. value: number;
  70340. /**
  70341. * The animation array of the path cursor
  70342. */
  70343. animations: Animation[];
  70344. /**
  70345. * Initializes the path cursor
  70346. * @param path The path to track
  70347. */
  70348. constructor(path: Path2);
  70349. /**
  70350. * Gets the cursor point on the path
  70351. * @returns A point on the path cursor at the cursor location
  70352. */
  70353. getPoint(): Vector3;
  70354. /**
  70355. * Moves the cursor ahead by the step amount
  70356. * @param step The amount to move the cursor forward
  70357. * @returns This path cursor
  70358. */
  70359. moveAhead(step?: number): PathCursor;
  70360. /**
  70361. * Moves the cursor behind by the step amount
  70362. * @param step The amount to move the cursor back
  70363. * @returns This path cursor
  70364. */
  70365. moveBack(step?: number): PathCursor;
  70366. /**
  70367. * Moves the cursor by the step amount
  70368. * If the step amount is greater than one, an exception is thrown
  70369. * @param step The amount to move the cursor
  70370. * @returns This path cursor
  70371. */
  70372. move(step: number): PathCursor;
  70373. /**
  70374. * Ensures that the value is limited between zero and one
  70375. * @returns This path cursor
  70376. */
  70377. private ensureLimits;
  70378. /**
  70379. * Runs onchange callbacks on change (used by the animation engine)
  70380. * @returns This path cursor
  70381. */
  70382. private raiseOnChange;
  70383. /**
  70384. * Executes a function on change
  70385. * @param f A path cursor onchange callback
  70386. * @returns This path cursor
  70387. */
  70388. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70389. }
  70390. }
  70391. declare module BABYLON {
  70392. /** @hidden */
  70393. export var blurPixelShader: {
  70394. name: string;
  70395. shader: string;
  70396. };
  70397. }
  70398. declare module BABYLON {
  70399. /** @hidden */
  70400. export var pointCloudVertexDeclaration: {
  70401. name: string;
  70402. shader: string;
  70403. };
  70404. }
  70405. // Mixins
  70406. interface Window {
  70407. mozIndexedDB: IDBFactory;
  70408. webkitIndexedDB: IDBFactory;
  70409. msIndexedDB: IDBFactory;
  70410. webkitURL: typeof URL;
  70411. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70412. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70413. WebGLRenderingContext: WebGLRenderingContext;
  70414. MSGesture: MSGesture;
  70415. CANNON: any;
  70416. AudioContext: AudioContext;
  70417. webkitAudioContext: AudioContext;
  70418. PointerEvent: any;
  70419. Math: Math;
  70420. Uint8Array: Uint8ArrayConstructor;
  70421. Float32Array: Float32ArrayConstructor;
  70422. mozURL: typeof URL;
  70423. msURL: typeof URL;
  70424. VRFrameData: any; // WebVR, from specs 1.1
  70425. DracoDecoderModule: any;
  70426. setImmediate(handler: (...args: any[]) => void): number;
  70427. }
  70428. interface HTMLCanvasElement {
  70429. requestPointerLock(): void;
  70430. msRequestPointerLock?(): void;
  70431. mozRequestPointerLock?(): void;
  70432. webkitRequestPointerLock?(): void;
  70433. /** Track wether a record is in progress */
  70434. isRecording: boolean;
  70435. /** Capture Stream method defined by some browsers */
  70436. captureStream(fps?: number): MediaStream;
  70437. }
  70438. interface CanvasRenderingContext2D {
  70439. msImageSmoothingEnabled: boolean;
  70440. }
  70441. interface MouseEvent {
  70442. mozMovementX: number;
  70443. mozMovementY: number;
  70444. webkitMovementX: number;
  70445. webkitMovementY: number;
  70446. msMovementX: number;
  70447. msMovementY: number;
  70448. }
  70449. interface Navigator {
  70450. mozGetVRDevices: (any: any) => any;
  70451. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70452. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70453. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70454. webkitGetGamepads(): Gamepad[];
  70455. msGetGamepads(): Gamepad[];
  70456. webkitGamepads(): Gamepad[];
  70457. }
  70458. interface HTMLVideoElement {
  70459. mozSrcObject: any;
  70460. }
  70461. interface Math {
  70462. fround(x: number): number;
  70463. imul(a: number, b: number): number;
  70464. }
  70465. interface WebGLRenderingContext {
  70466. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70467. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70468. vertexAttribDivisor(index: number, divisor: number): void;
  70469. createVertexArray(): any;
  70470. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70471. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70472. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70473. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70474. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70475. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70476. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70477. // Queries
  70478. createQuery(): WebGLQuery;
  70479. deleteQuery(query: WebGLQuery): void;
  70480. beginQuery(target: number, query: WebGLQuery): void;
  70481. endQuery(target: number): void;
  70482. getQueryParameter(query: WebGLQuery, pname: number): any;
  70483. getQuery(target: number, pname: number): any;
  70484. MAX_SAMPLES: number;
  70485. RGBA8: number;
  70486. READ_FRAMEBUFFER: number;
  70487. DRAW_FRAMEBUFFER: number;
  70488. UNIFORM_BUFFER: number;
  70489. HALF_FLOAT_OES: number;
  70490. RGBA16F: number;
  70491. RGBA32F: number;
  70492. R32F: number;
  70493. RG32F: number;
  70494. RGB32F: number;
  70495. R16F: number;
  70496. RG16F: number;
  70497. RGB16F: number;
  70498. RED: number;
  70499. RG: number;
  70500. R8: number;
  70501. RG8: number;
  70502. UNSIGNED_INT_24_8: number;
  70503. DEPTH24_STENCIL8: number;
  70504. MIN: number;
  70505. MAX: number;
  70506. /* Multiple Render Targets */
  70507. drawBuffers(buffers: number[]): void;
  70508. readBuffer(src: number): void;
  70509. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70510. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70511. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70512. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70513. // Occlusion Query
  70514. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70515. ANY_SAMPLES_PASSED: number;
  70516. QUERY_RESULT_AVAILABLE: number;
  70517. QUERY_RESULT: number;
  70518. }
  70519. interface WebGLProgram {
  70520. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70521. }
  70522. interface EXT_disjoint_timer_query {
  70523. QUERY_COUNTER_BITS_EXT: number;
  70524. TIME_ELAPSED_EXT: number;
  70525. TIMESTAMP_EXT: number;
  70526. GPU_DISJOINT_EXT: number;
  70527. QUERY_RESULT_EXT: number;
  70528. QUERY_RESULT_AVAILABLE_EXT: number;
  70529. queryCounterEXT(query: WebGLQuery, target: number): void;
  70530. createQueryEXT(): WebGLQuery;
  70531. beginQueryEXT(target: number, query: WebGLQuery): void;
  70532. endQueryEXT(target: number): void;
  70533. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70534. deleteQueryEXT(query: WebGLQuery): void;
  70535. }
  70536. interface WebGLUniformLocation {
  70537. _currentState: any;
  70538. }
  70539. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70540. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70541. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70542. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70543. interface WebGLRenderingContext {
  70544. readonly RASTERIZER_DISCARD: number;
  70545. readonly DEPTH_COMPONENT24: number;
  70546. readonly TEXTURE_3D: number;
  70547. readonly TEXTURE_2D_ARRAY: number;
  70548. readonly TEXTURE_COMPARE_FUNC: number;
  70549. readonly TEXTURE_COMPARE_MODE: number;
  70550. readonly COMPARE_REF_TO_TEXTURE: number;
  70551. readonly TEXTURE_WRAP_R: number;
  70552. readonly HALF_FLOAT: number;
  70553. readonly RGB8: number;
  70554. readonly RED_INTEGER: number;
  70555. readonly RG_INTEGER: number;
  70556. readonly RGB_INTEGER: number;
  70557. readonly RGBA_INTEGER: number;
  70558. readonly R8_SNORM: number;
  70559. readonly RG8_SNORM: number;
  70560. readonly RGB8_SNORM: number;
  70561. readonly RGBA8_SNORM: number;
  70562. readonly R8I: number;
  70563. readonly RG8I: number;
  70564. readonly RGB8I: number;
  70565. readonly RGBA8I: number;
  70566. readonly R8UI: number;
  70567. readonly RG8UI: number;
  70568. readonly RGB8UI: number;
  70569. readonly RGBA8UI: number;
  70570. readonly R16I: number;
  70571. readonly RG16I: number;
  70572. readonly RGB16I: number;
  70573. readonly RGBA16I: number;
  70574. readonly R16UI: number;
  70575. readonly RG16UI: number;
  70576. readonly RGB16UI: number;
  70577. readonly RGBA16UI: number;
  70578. readonly R32I: number;
  70579. readonly RG32I: number;
  70580. readonly RGB32I: number;
  70581. readonly RGBA32I: number;
  70582. readonly R32UI: number;
  70583. readonly RG32UI: number;
  70584. readonly RGB32UI: number;
  70585. readonly RGBA32UI: number;
  70586. readonly RGB10_A2UI: number;
  70587. readonly R11F_G11F_B10F: number;
  70588. readonly RGB9_E5: number;
  70589. readonly RGB10_A2: number;
  70590. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70591. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70592. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70593. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70594. readonly DEPTH_COMPONENT32F: number;
  70595. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70596. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70597. 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;
  70598. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70599. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70600. readonly TRANSFORM_FEEDBACK: number;
  70601. readonly INTERLEAVED_ATTRIBS: number;
  70602. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70603. createTransformFeedback(): WebGLTransformFeedback;
  70604. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70605. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70606. beginTransformFeedback(primitiveMode: number): void;
  70607. endTransformFeedback(): void;
  70608. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70609. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70610. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70611. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70612. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70613. }
  70614. interface ImageBitmap {
  70615. readonly width: number;
  70616. readonly height: number;
  70617. close(): void;
  70618. }
  70619. interface WebGLQuery extends WebGLObject {
  70620. }
  70621. declare var WebGLQuery: {
  70622. prototype: WebGLQuery;
  70623. new(): WebGLQuery;
  70624. };
  70625. interface WebGLSampler extends WebGLObject {
  70626. }
  70627. declare var WebGLSampler: {
  70628. prototype: WebGLSampler;
  70629. new(): WebGLSampler;
  70630. };
  70631. interface WebGLSync extends WebGLObject {
  70632. }
  70633. declare var WebGLSync: {
  70634. prototype: WebGLSync;
  70635. new(): WebGLSync;
  70636. };
  70637. interface WebGLTransformFeedback extends WebGLObject {
  70638. }
  70639. declare var WebGLTransformFeedback: {
  70640. prototype: WebGLTransformFeedback;
  70641. new(): WebGLTransformFeedback;
  70642. };
  70643. interface WebGLVertexArrayObject extends WebGLObject {
  70644. }
  70645. declare var WebGLVertexArrayObject: {
  70646. prototype: WebGLVertexArrayObject;
  70647. new(): WebGLVertexArrayObject;
  70648. };
  70649. // Type definitions for WebVR API
  70650. // Project: https://w3c.github.io/webvr/
  70651. // Definitions by: six a <https://github.com/lostfictions>
  70652. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70653. interface VRDisplay extends EventTarget {
  70654. /**
  70655. * Dictionary of capabilities describing the VRDisplay.
  70656. */
  70657. readonly capabilities: VRDisplayCapabilities;
  70658. /**
  70659. * z-depth defining the far plane of the eye view frustum
  70660. * enables mapping of values in the render target depth
  70661. * attachment to scene coordinates. Initially set to 10000.0.
  70662. */
  70663. depthFar: number;
  70664. /**
  70665. * z-depth defining the near plane of the eye view frustum
  70666. * enables mapping of values in the render target depth
  70667. * attachment to scene coordinates. Initially set to 0.01.
  70668. */
  70669. depthNear: number;
  70670. /**
  70671. * An identifier for this distinct VRDisplay. Used as an
  70672. * association point in the Gamepad API.
  70673. */
  70674. readonly displayId: number;
  70675. /**
  70676. * A display name, a user-readable name identifying it.
  70677. */
  70678. readonly displayName: string;
  70679. readonly isConnected: boolean;
  70680. readonly isPresenting: boolean;
  70681. /**
  70682. * If this VRDisplay supports room-scale experiences, the optional
  70683. * stage attribute contains details on the room-scale parameters.
  70684. */
  70685. readonly stageParameters: VRStageParameters | null;
  70686. /**
  70687. * Passing the value returned by `requestAnimationFrame` to
  70688. * `cancelAnimationFrame` will unregister the callback.
  70689. * @param handle Define the hanle of the request to cancel
  70690. */
  70691. cancelAnimationFrame(handle: number): void;
  70692. /**
  70693. * Stops presenting to the VRDisplay.
  70694. * @returns a promise to know when it stopped
  70695. */
  70696. exitPresent(): Promise<void>;
  70697. /**
  70698. * Return the current VREyeParameters for the given eye.
  70699. * @param whichEye Define the eye we want the parameter for
  70700. * @returns the eye parameters
  70701. */
  70702. getEyeParameters(whichEye: string): VREyeParameters;
  70703. /**
  70704. * Populates the passed VRFrameData with the information required to render
  70705. * the current frame.
  70706. * @param frameData Define the data structure to populate
  70707. * @returns true if ok otherwise false
  70708. */
  70709. getFrameData(frameData: VRFrameData): boolean;
  70710. /**
  70711. * Get the layers currently being presented.
  70712. * @returns the list of VR layers
  70713. */
  70714. getLayers(): VRLayer[];
  70715. /**
  70716. * Return a VRPose containing the future predicted pose of the VRDisplay
  70717. * when the current frame will be presented. The value returned will not
  70718. * change until JavaScript has returned control to the browser.
  70719. *
  70720. * The VRPose will contain the position, orientation, velocity,
  70721. * and acceleration of each of these properties.
  70722. * @returns the pose object
  70723. */
  70724. getPose(): VRPose;
  70725. /**
  70726. * Return the current instantaneous pose of the VRDisplay, with no
  70727. * prediction applied.
  70728. * @returns the current instantaneous pose
  70729. */
  70730. getImmediatePose(): VRPose;
  70731. /**
  70732. * The callback passed to `requestAnimationFrame` will be called
  70733. * any time a new frame should be rendered. When the VRDisplay is
  70734. * presenting the callback will be called at the native refresh
  70735. * rate of the HMD. When not presenting this function acts
  70736. * identically to how window.requestAnimationFrame acts. Content should
  70737. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70738. * asynchronously from other displays and at differing refresh rates.
  70739. * @param callback Define the eaction to run next frame
  70740. * @returns the request handle it
  70741. */
  70742. requestAnimationFrame(callback: FrameRequestCallback): number;
  70743. /**
  70744. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70745. * Repeat calls while already presenting will update the VRLayers being displayed.
  70746. * @param layers Define the list of layer to present
  70747. * @returns a promise to know when the request has been fulfilled
  70748. */
  70749. requestPresent(layers: VRLayer[]): Promise<void>;
  70750. /**
  70751. * Reset the pose for this display, treating its current position and
  70752. * orientation as the "origin/zero" values. VRPose.position,
  70753. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70754. * updated when calling resetPose(). This should be called in only
  70755. * sitting-space experiences.
  70756. */
  70757. resetPose(): void;
  70758. /**
  70759. * The VRLayer provided to the VRDisplay will be captured and presented
  70760. * in the HMD. Calling this function has the same effect on the source
  70761. * canvas as any other operation that uses its source image, and canvases
  70762. * created without preserveDrawingBuffer set to true will be cleared.
  70763. * @param pose Define the pose to submit
  70764. */
  70765. submitFrame(pose?: VRPose): void;
  70766. }
  70767. declare var VRDisplay: {
  70768. prototype: VRDisplay;
  70769. new(): VRDisplay;
  70770. };
  70771. interface VRLayer {
  70772. leftBounds?: number[] | Float32Array | null;
  70773. rightBounds?: number[] | Float32Array | null;
  70774. source?: HTMLCanvasElement | null;
  70775. }
  70776. interface VRDisplayCapabilities {
  70777. readonly canPresent: boolean;
  70778. readonly hasExternalDisplay: boolean;
  70779. readonly hasOrientation: boolean;
  70780. readonly hasPosition: boolean;
  70781. readonly maxLayers: number;
  70782. }
  70783. interface VREyeParameters {
  70784. /** @deprecated */
  70785. readonly fieldOfView: VRFieldOfView;
  70786. readonly offset: Float32Array;
  70787. readonly renderHeight: number;
  70788. readonly renderWidth: number;
  70789. }
  70790. interface VRFieldOfView {
  70791. readonly downDegrees: number;
  70792. readonly leftDegrees: number;
  70793. readonly rightDegrees: number;
  70794. readonly upDegrees: number;
  70795. }
  70796. interface VRFrameData {
  70797. readonly leftProjectionMatrix: Float32Array;
  70798. readonly leftViewMatrix: Float32Array;
  70799. readonly pose: VRPose;
  70800. readonly rightProjectionMatrix: Float32Array;
  70801. readonly rightViewMatrix: Float32Array;
  70802. readonly timestamp: number;
  70803. }
  70804. interface VRPose {
  70805. readonly angularAcceleration: Float32Array | null;
  70806. readonly angularVelocity: Float32Array | null;
  70807. readonly linearAcceleration: Float32Array | null;
  70808. readonly linearVelocity: Float32Array | null;
  70809. readonly orientation: Float32Array | null;
  70810. readonly position: Float32Array | null;
  70811. readonly timestamp: number;
  70812. }
  70813. interface VRStageParameters {
  70814. sittingToStandingTransform?: Float32Array;
  70815. sizeX?: number;
  70816. sizeY?: number;
  70817. }
  70818. interface Navigator {
  70819. getVRDisplays(): Promise<VRDisplay[]>;
  70820. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70821. }
  70822. interface Window {
  70823. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70824. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70825. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70826. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70827. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70828. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70829. }
  70830. interface Gamepad {
  70831. readonly displayId: number;
  70832. }
  70833. type XRSessionMode =
  70834. | "inline"
  70835. | "immersive-vr"
  70836. | "immersive-ar";
  70837. type XRReferenceSpaceType =
  70838. | "viewer"
  70839. | "local"
  70840. | "local-floor"
  70841. | "bounded-floor"
  70842. | "unbounded";
  70843. type XREnvironmentBlendMode =
  70844. | "opaque"
  70845. | "additive"
  70846. | "alpha-blend";
  70847. type XRVisibilityState =
  70848. | "visible"
  70849. | "visible-blurred"
  70850. | "hidden";
  70851. type XRHandedness =
  70852. | "none"
  70853. | "left"
  70854. | "right";
  70855. type XRTargetRayMode =
  70856. | "gaze"
  70857. | "tracked-pointer"
  70858. | "screen";
  70859. type XREye =
  70860. | "none"
  70861. | "left"
  70862. | "right";
  70863. interface XRSpace extends EventTarget {
  70864. }
  70865. interface XRRenderState {
  70866. depthNear?: number;
  70867. depthFar?: number;
  70868. inlineVerticalFieldOfView?: number;
  70869. baseLayer?: XRWebGLLayer;
  70870. }
  70871. interface XRInputSource {
  70872. handedness: XRHandedness;
  70873. targetRayMode: XRTargetRayMode;
  70874. targetRaySpace: XRSpace;
  70875. gripSpace: XRSpace | undefined;
  70876. gamepad: Gamepad | undefined;
  70877. profiles: Array<string>;
  70878. }
  70879. interface XRSessionInit {
  70880. optionalFeatures?: XRReferenceSpaceType[];
  70881. requiredFeatures?: XRReferenceSpaceType[];
  70882. }
  70883. interface XRSession extends XRAnchorCreator {
  70884. addEventListener: Function;
  70885. removeEventListener: Function;
  70886. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70887. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70888. requestAnimationFrame: Function;
  70889. end(): Promise<void>;
  70890. renderState: XRRenderState;
  70891. inputSources: Array<XRInputSource>;
  70892. // hit test
  70893. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70894. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70895. // legacy AR hit test
  70896. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70897. // legacy plane detection
  70898. updateWorldTrackingState(options: {
  70899. planeDetectionState?: { enabled: boolean; }
  70900. }): void;
  70901. }
  70902. interface XRReferenceSpace extends XRSpace {
  70903. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70904. onreset: any;
  70905. }
  70906. type XRPlaneSet = Set<XRPlane>;
  70907. type XRAnchorSet = Set<XRAnchor>;
  70908. interface XRFrame {
  70909. session: XRSession;
  70910. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70911. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70912. // AR
  70913. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70914. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70915. // Anchors
  70916. trackedAnchors?: XRAnchorSet;
  70917. // Planes
  70918. worldInformation: {
  70919. detectedPlanes?: XRPlaneSet;
  70920. };
  70921. }
  70922. interface XRViewerPose extends XRPose {
  70923. views: Array<XRView>;
  70924. }
  70925. interface XRPose {
  70926. transform: XRRigidTransform;
  70927. emulatedPosition: boolean;
  70928. }
  70929. interface XRWebGLLayerOptions {
  70930. antialias?: boolean;
  70931. depth?: boolean;
  70932. stencil?: boolean;
  70933. alpha?: boolean;
  70934. multiview?: boolean;
  70935. framebufferScaleFactor?: number;
  70936. }
  70937. declare var XRWebGLLayer: {
  70938. prototype: XRWebGLLayer;
  70939. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70940. };
  70941. interface XRWebGLLayer {
  70942. framebuffer: WebGLFramebuffer;
  70943. framebufferWidth: number;
  70944. framebufferHeight: number;
  70945. getViewport: Function;
  70946. }
  70947. declare class XRRigidTransform {
  70948. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70949. position: DOMPointReadOnly;
  70950. orientation: DOMPointReadOnly;
  70951. matrix: Float32Array;
  70952. inverse: XRRigidTransform;
  70953. }
  70954. interface XRView {
  70955. eye: XREye;
  70956. projectionMatrix: Float32Array;
  70957. transform: XRRigidTransform;
  70958. }
  70959. interface XRInputSourceChangeEvent {
  70960. session: XRSession;
  70961. removed: Array<XRInputSource>;
  70962. added: Array<XRInputSource>;
  70963. }
  70964. interface XRInputSourceEvent extends Event {
  70965. readonly frame: XRFrame;
  70966. readonly inputSource: XRInputSource;
  70967. }
  70968. // Experimental(er) features
  70969. declare class XRRay {
  70970. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70971. origin: DOMPointReadOnly;
  70972. direction: DOMPointReadOnly;
  70973. matrix: Float32Array;
  70974. }
  70975. declare enum XRHitTestTrackableType {
  70976. "point",
  70977. "plane"
  70978. }
  70979. interface XRHitResult {
  70980. hitMatrix: Float32Array;
  70981. }
  70982. interface XRTransientInputHitTestResult {
  70983. readonly inputSource: XRInputSource;
  70984. readonly results: Array<XRHitTestResult>;
  70985. }
  70986. interface XRHitTestResult {
  70987. getPose(baseSpace: XRSpace): XRPose | undefined;
  70988. }
  70989. interface XRHitTestSource {
  70990. cancel(): void;
  70991. }
  70992. interface XRTransientInputHitTestSource {
  70993. cancel(): void;
  70994. }
  70995. interface XRHitTestOptionsInit {
  70996. space: XRSpace;
  70997. entityTypes?: Array<XRHitTestTrackableType>;
  70998. offsetRay?: XRRay;
  70999. }
  71000. interface XRTransientInputHitTestOptionsInit {
  71001. profile: string;
  71002. entityTypes?: Array<XRHitTestTrackableType>;
  71003. offsetRay?: XRRay;
  71004. }
  71005. interface XRAnchor {
  71006. // remove?
  71007. id?: string;
  71008. anchorSpace: XRSpace;
  71009. lastChangedTime: number;
  71010. detach(): void;
  71011. }
  71012. interface XRPlane extends XRAnchorCreator {
  71013. orientation: "Horizontal" | "Vertical";
  71014. planeSpace: XRSpace;
  71015. polygon: Array<DOMPointReadOnly>;
  71016. lastChangedTime: number;
  71017. }
  71018. interface XRAnchorCreator {
  71019. // AR Anchors
  71020. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71021. }
  71022. /**
  71023. * @ignore
  71024. */
  71025. declare module BABYLON.GLTF2.Exporter {
  71026. }
  71027. /**
  71028. * @ignore
  71029. */
  71030. declare module BABYLON.GLTF1 {
  71031. }
  71032. declare module BABYLON.GUI {
  71033. /**
  71034. * Class used to specific a value and its associated unit
  71035. */
  71036. export class ValueAndUnit {
  71037. /** defines the unit to store */
  71038. unit: number;
  71039. /** defines a boolean indicating if the value can be negative */
  71040. negativeValueAllowed: boolean;
  71041. private _value;
  71042. private _originalUnit;
  71043. /**
  71044. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71045. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71046. */
  71047. ignoreAdaptiveScaling: boolean;
  71048. /**
  71049. * Creates a new ValueAndUnit
  71050. * @param value defines the value to store
  71051. * @param unit defines the unit to store
  71052. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71053. */
  71054. constructor(value: number,
  71055. /** defines the unit to store */
  71056. unit?: number,
  71057. /** defines a boolean indicating if the value can be negative */
  71058. negativeValueAllowed?: boolean);
  71059. /** Gets a boolean indicating if the value is a percentage */
  71060. get isPercentage(): boolean;
  71061. /** Gets a boolean indicating if the value is store as pixel */
  71062. get isPixel(): boolean;
  71063. /** Gets direct internal value */
  71064. get internalValue(): number;
  71065. /**
  71066. * Gets value as pixel
  71067. * @param host defines the root host
  71068. * @param refValue defines the reference value for percentages
  71069. * @returns the value as pixel
  71070. */
  71071. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71072. /**
  71073. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71074. * @param value defines the value to store
  71075. * @param unit defines the unit to store
  71076. * @returns the current ValueAndUnit
  71077. */
  71078. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71079. /**
  71080. * Gets the value accordingly to its unit
  71081. * @param host defines the root host
  71082. * @returns the value
  71083. */
  71084. getValue(host: AdvancedDynamicTexture): number;
  71085. /**
  71086. * Gets a string representation of the value
  71087. * @param host defines the root host
  71088. * @param decimals defines an optional number of decimals to display
  71089. * @returns a string
  71090. */
  71091. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71092. /**
  71093. * Store a value parsed from a string
  71094. * @param source defines the source string
  71095. * @returns true if the value was successfully parsed
  71096. */
  71097. fromString(source: string | number): boolean;
  71098. private static _Regex;
  71099. private static _UNITMODE_PERCENTAGE;
  71100. private static _UNITMODE_PIXEL;
  71101. /** UNITMODE_PERCENTAGE */
  71102. static get UNITMODE_PERCENTAGE(): number;
  71103. /** UNITMODE_PIXEL */
  71104. static get UNITMODE_PIXEL(): number;
  71105. }
  71106. }
  71107. declare module BABYLON.GUI {
  71108. /**
  71109. * Define a style used by control to automatically setup properties based on a template.
  71110. * Only support font related properties so far
  71111. */
  71112. export class Style implements BABYLON.IDisposable {
  71113. private _fontFamily;
  71114. private _fontStyle;
  71115. private _fontWeight;
  71116. /** @hidden */
  71117. _host: AdvancedDynamicTexture;
  71118. /** @hidden */
  71119. _fontSize: ValueAndUnit;
  71120. /**
  71121. * BABYLON.Observable raised when the style values are changed
  71122. */
  71123. onChangedObservable: BABYLON.Observable<Style>;
  71124. /**
  71125. * Creates a new style object
  71126. * @param host defines the AdvancedDynamicTexture which hosts this style
  71127. */
  71128. constructor(host: AdvancedDynamicTexture);
  71129. /**
  71130. * Gets or sets the font size
  71131. */
  71132. get fontSize(): string | number;
  71133. set fontSize(value: string | number);
  71134. /**
  71135. * Gets or sets the font family
  71136. */
  71137. get fontFamily(): string;
  71138. set fontFamily(value: string);
  71139. /**
  71140. * Gets or sets the font style
  71141. */
  71142. get fontStyle(): string;
  71143. set fontStyle(value: string);
  71144. /** Gets or sets font weight */
  71145. get fontWeight(): string;
  71146. set fontWeight(value: string);
  71147. /** Dispose all associated resources */
  71148. dispose(): void;
  71149. }
  71150. }
  71151. declare module BABYLON.GUI {
  71152. /**
  71153. * Class used to transport BABYLON.Vector2 information for pointer events
  71154. */
  71155. export class Vector2WithInfo extends BABYLON.Vector2 {
  71156. /** defines the current mouse button index */
  71157. buttonIndex: number;
  71158. /**
  71159. * Creates a new Vector2WithInfo
  71160. * @param source defines the vector2 data to transport
  71161. * @param buttonIndex defines the current mouse button index
  71162. */
  71163. constructor(source: BABYLON.Vector2,
  71164. /** defines the current mouse button index */
  71165. buttonIndex?: number);
  71166. }
  71167. /** Class used to provide 2D matrix features */
  71168. export class Matrix2D {
  71169. /** Gets the internal array of 6 floats used to store matrix data */
  71170. m: Float32Array;
  71171. /**
  71172. * Creates a new matrix
  71173. * @param m00 defines value for (0, 0)
  71174. * @param m01 defines value for (0, 1)
  71175. * @param m10 defines value for (1, 0)
  71176. * @param m11 defines value for (1, 1)
  71177. * @param m20 defines value for (2, 0)
  71178. * @param m21 defines value for (2, 1)
  71179. */
  71180. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71181. /**
  71182. * Fills the matrix from direct values
  71183. * @param m00 defines value for (0, 0)
  71184. * @param m01 defines value for (0, 1)
  71185. * @param m10 defines value for (1, 0)
  71186. * @param m11 defines value for (1, 1)
  71187. * @param m20 defines value for (2, 0)
  71188. * @param m21 defines value for (2, 1)
  71189. * @returns the current modified matrix
  71190. */
  71191. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71192. /**
  71193. * Gets matrix determinant
  71194. * @returns the determinant
  71195. */
  71196. determinant(): number;
  71197. /**
  71198. * Inverses the matrix and stores it in a target matrix
  71199. * @param result defines the target matrix
  71200. * @returns the current matrix
  71201. */
  71202. invertToRef(result: Matrix2D): Matrix2D;
  71203. /**
  71204. * Multiplies the current matrix with another one
  71205. * @param other defines the second operand
  71206. * @param result defines the target matrix
  71207. * @returns the current matrix
  71208. */
  71209. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71210. /**
  71211. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71212. * @param x defines the x coordinate to transform
  71213. * @param y defines the x coordinate to transform
  71214. * @param result defines the target vector2
  71215. * @returns the current matrix
  71216. */
  71217. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71218. /**
  71219. * Creates an identity matrix
  71220. * @returns a new matrix
  71221. */
  71222. static Identity(): Matrix2D;
  71223. /**
  71224. * Creates a translation matrix and stores it in a target matrix
  71225. * @param x defines the x coordinate of the translation
  71226. * @param y defines the y coordinate of the translation
  71227. * @param result defines the target matrix
  71228. */
  71229. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71230. /**
  71231. * Creates a scaling matrix and stores it in a target matrix
  71232. * @param x defines the x coordinate of the scaling
  71233. * @param y defines the y coordinate of the scaling
  71234. * @param result defines the target matrix
  71235. */
  71236. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71237. /**
  71238. * Creates a rotation matrix and stores it in a target matrix
  71239. * @param angle defines the rotation angle
  71240. * @param result defines the target matrix
  71241. */
  71242. static RotationToRef(angle: number, result: Matrix2D): void;
  71243. private static _TempPreTranslationMatrix;
  71244. private static _TempPostTranslationMatrix;
  71245. private static _TempRotationMatrix;
  71246. private static _TempScalingMatrix;
  71247. private static _TempCompose0;
  71248. private static _TempCompose1;
  71249. private static _TempCompose2;
  71250. /**
  71251. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71252. * @param tx defines the x coordinate of the translation
  71253. * @param ty defines the y coordinate of the translation
  71254. * @param angle defines the rotation angle
  71255. * @param scaleX defines the x coordinate of the scaling
  71256. * @param scaleY defines the y coordinate of the scaling
  71257. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71258. * @param result defines the target matrix
  71259. */
  71260. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71261. }
  71262. }
  71263. declare module BABYLON.GUI {
  71264. /**
  71265. * Class used to store 2D control sizes
  71266. */
  71267. export class Measure {
  71268. /** defines left coordinate */
  71269. left: number;
  71270. /** defines top coordinate */
  71271. top: number;
  71272. /** defines width dimension */
  71273. width: number;
  71274. /** defines height dimension */
  71275. height: number;
  71276. /**
  71277. * Creates a new measure
  71278. * @param left defines left coordinate
  71279. * @param top defines top coordinate
  71280. * @param width defines width dimension
  71281. * @param height defines height dimension
  71282. */
  71283. constructor(
  71284. /** defines left coordinate */
  71285. left: number,
  71286. /** defines top coordinate */
  71287. top: number,
  71288. /** defines width dimension */
  71289. width: number,
  71290. /** defines height dimension */
  71291. height: number);
  71292. /**
  71293. * Copy from another measure
  71294. * @param other defines the other measure to copy from
  71295. */
  71296. copyFrom(other: Measure): void;
  71297. /**
  71298. * Copy from a group of 4 floats
  71299. * @param left defines left coordinate
  71300. * @param top defines top coordinate
  71301. * @param width defines width dimension
  71302. * @param height defines height dimension
  71303. */
  71304. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71305. /**
  71306. * Computes the axis aligned bounding box measure for two given measures
  71307. * @param a Input measure
  71308. * @param b Input measure
  71309. * @param result the resulting bounding measure
  71310. */
  71311. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71312. /**
  71313. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71314. * @param transform the matrix to transform the measure before computing the AABB
  71315. * @param result the resulting AABB
  71316. */
  71317. transformToRef(transform: Matrix2D, result: Measure): void;
  71318. /**
  71319. * Check equality between this measure and another one
  71320. * @param other defines the other measures
  71321. * @returns true if both measures are equals
  71322. */
  71323. isEqualsTo(other: Measure): boolean;
  71324. /**
  71325. * Creates an empty measure
  71326. * @returns a new measure
  71327. */
  71328. static Empty(): Measure;
  71329. }
  71330. }
  71331. declare module BABYLON.GUI {
  71332. /**
  71333. * Interface used to define a control that can receive focus
  71334. */
  71335. export interface IFocusableControl {
  71336. /**
  71337. * Function called when the control receives the focus
  71338. */
  71339. onFocus(): void;
  71340. /**
  71341. * Function called when the control loses the focus
  71342. */
  71343. onBlur(): void;
  71344. /**
  71345. * Function called to let the control handle keyboard events
  71346. * @param evt defines the current keyboard event
  71347. */
  71348. processKeyboard(evt: KeyboardEvent): void;
  71349. /**
  71350. * Function called to get the list of controls that should not steal the focus from this control
  71351. * @returns an array of controls
  71352. */
  71353. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71354. }
  71355. /**
  71356. * Class used to create texture to support 2D GUI elements
  71357. * @see http://doc.babylonjs.com/how_to/gui
  71358. */
  71359. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71360. private _isDirty;
  71361. private _renderObserver;
  71362. private _resizeObserver;
  71363. private _preKeyboardObserver;
  71364. private _pointerMoveObserver;
  71365. private _pointerObserver;
  71366. private _canvasPointerOutObserver;
  71367. private _background;
  71368. /** @hidden */
  71369. _rootContainer: Container;
  71370. /** @hidden */
  71371. _lastPickedControl: Control;
  71372. /** @hidden */
  71373. _lastControlOver: {
  71374. [pointerId: number]: Control;
  71375. };
  71376. /** @hidden */
  71377. _lastControlDown: {
  71378. [pointerId: number]: Control;
  71379. };
  71380. /** @hidden */
  71381. _capturingControl: {
  71382. [pointerId: number]: Control;
  71383. };
  71384. /** @hidden */
  71385. _shouldBlockPointer: boolean;
  71386. /** @hidden */
  71387. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71388. /** @hidden */
  71389. _linkedControls: Control[];
  71390. private _isFullscreen;
  71391. private _fullscreenViewport;
  71392. private _idealWidth;
  71393. private _idealHeight;
  71394. private _useSmallestIdeal;
  71395. private _renderAtIdealSize;
  71396. private _focusedControl;
  71397. private _blockNextFocusCheck;
  71398. private _renderScale;
  71399. private _rootElement;
  71400. private _cursorChanged;
  71401. private _defaultMousePointerId;
  71402. /** @hidden */
  71403. _numLayoutCalls: number;
  71404. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71405. get numLayoutCalls(): number;
  71406. /** @hidden */
  71407. _numRenderCalls: number;
  71408. /** Gets the number of render calls made the last time the ADT has been rendered */
  71409. get numRenderCalls(): number;
  71410. /**
  71411. * Define type to string to ensure compatibility across browsers
  71412. * Safari doesn't support DataTransfer constructor
  71413. */
  71414. private _clipboardData;
  71415. /**
  71416. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71417. */
  71418. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71419. /**
  71420. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71421. */
  71422. onControlPickedObservable: BABYLON.Observable<Control>;
  71423. /**
  71424. * BABYLON.Observable event triggered before layout is evaluated
  71425. */
  71426. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71427. /**
  71428. * BABYLON.Observable event triggered after the layout was evaluated
  71429. */
  71430. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71431. /**
  71432. * BABYLON.Observable event triggered before the texture is rendered
  71433. */
  71434. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71435. /**
  71436. * BABYLON.Observable event triggered after the texture was rendered
  71437. */
  71438. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71439. /**
  71440. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71441. */
  71442. premulAlpha: boolean;
  71443. /**
  71444. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71445. * Useful when you want more antialiasing
  71446. */
  71447. get renderScale(): number;
  71448. set renderScale(value: number);
  71449. /** Gets or sets the background color */
  71450. get background(): string;
  71451. set background(value: string);
  71452. /**
  71453. * Gets or sets the ideal width used to design controls.
  71454. * The GUI will then rescale everything accordingly
  71455. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71456. */
  71457. get idealWidth(): number;
  71458. set idealWidth(value: number);
  71459. /**
  71460. * Gets or sets the ideal height used to design controls.
  71461. * The GUI will then rescale everything accordingly
  71462. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71463. */
  71464. get idealHeight(): number;
  71465. set idealHeight(value: number);
  71466. /**
  71467. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71468. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71469. */
  71470. get useSmallestIdeal(): boolean;
  71471. set useSmallestIdeal(value: boolean);
  71472. /**
  71473. * Gets or sets a boolean indicating if adaptive scaling must be used
  71474. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71475. */
  71476. get renderAtIdealSize(): boolean;
  71477. set renderAtIdealSize(value: boolean);
  71478. /**
  71479. * Gets the ratio used when in "ideal mode"
  71480. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71481. * */
  71482. get idealRatio(): number;
  71483. /**
  71484. * Gets the underlying layer used to render the texture when in fullscreen mode
  71485. */
  71486. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71487. /**
  71488. * Gets the root container control
  71489. */
  71490. get rootContainer(): Container;
  71491. /**
  71492. * Returns an array containing the root container.
  71493. * This is mostly used to let the Inspector introspects the ADT
  71494. * @returns an array containing the rootContainer
  71495. */
  71496. getChildren(): Array<Container>;
  71497. /**
  71498. * Will return all controls that are inside this texture
  71499. * @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
  71500. * @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
  71501. * @return all child controls
  71502. */
  71503. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71504. /**
  71505. * Gets or sets the current focused control
  71506. */
  71507. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71508. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71509. /**
  71510. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71511. */
  71512. get isForeground(): boolean;
  71513. set isForeground(value: boolean);
  71514. /**
  71515. * Gets or set information about clipboardData
  71516. */
  71517. get clipboardData(): string;
  71518. set clipboardData(value: string);
  71519. /**
  71520. * Creates a new AdvancedDynamicTexture
  71521. * @param name defines the name of the texture
  71522. * @param width defines the width of the texture
  71523. * @param height defines the height of the texture
  71524. * @param scene defines the hosting scene
  71525. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71526. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71527. */
  71528. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71529. /**
  71530. * Get the current class name of the texture useful for serialization or dynamic coding.
  71531. * @returns "AdvancedDynamicTexture"
  71532. */
  71533. getClassName(): string;
  71534. /**
  71535. * Function used to execute a function on all controls
  71536. * @param func defines the function to execute
  71537. * @param container defines the container where controls belong. If null the root container will be used
  71538. */
  71539. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71540. private _useInvalidateRectOptimization;
  71541. /**
  71542. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71543. */
  71544. get useInvalidateRectOptimization(): boolean;
  71545. set useInvalidateRectOptimization(value: boolean);
  71546. private _invalidatedRectangle;
  71547. /**
  71548. * Invalidates a rectangle area on the gui texture
  71549. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71550. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71551. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71552. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71553. */
  71554. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71555. /**
  71556. * Marks the texture as dirty forcing a complete update
  71557. */
  71558. markAsDirty(): void;
  71559. /**
  71560. * Helper function used to create a new style
  71561. * @returns a new style
  71562. * @see http://doc.babylonjs.com/how_to/gui#styles
  71563. */
  71564. createStyle(): Style;
  71565. /**
  71566. * Adds a new control to the root container
  71567. * @param control defines the control to add
  71568. * @returns the current texture
  71569. */
  71570. addControl(control: Control): AdvancedDynamicTexture;
  71571. /**
  71572. * Removes a control from the root container
  71573. * @param control defines the control to remove
  71574. * @returns the current texture
  71575. */
  71576. removeControl(control: Control): AdvancedDynamicTexture;
  71577. /**
  71578. * Release all resources
  71579. */
  71580. dispose(): void;
  71581. private _onResize;
  71582. /** @hidden */
  71583. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71584. /**
  71585. * Get screen coordinates for a vector3
  71586. * @param position defines the position to project
  71587. * @param worldMatrix defines the world matrix to use
  71588. * @returns the projected position
  71589. */
  71590. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71591. private _checkUpdate;
  71592. private _clearMeasure;
  71593. private _render;
  71594. /** @hidden */
  71595. _changeCursor(cursor: string): void;
  71596. /** @hidden */
  71597. _registerLastControlDown(control: Control, pointerId: number): void;
  71598. private _doPicking;
  71599. /** @hidden */
  71600. _cleanControlAfterRemovalFromList(list: {
  71601. [pointerId: number]: Control;
  71602. }, control: Control): void;
  71603. /** @hidden */
  71604. _cleanControlAfterRemoval(control: Control): void;
  71605. /** Attach to all scene events required to support pointer events */
  71606. attach(): void;
  71607. /** @hidden */
  71608. private onClipboardCopy;
  71609. /** @hidden */
  71610. private onClipboardCut;
  71611. /** @hidden */
  71612. private onClipboardPaste;
  71613. /**
  71614. * Register the clipboard Events onto the canvas
  71615. */
  71616. registerClipboardEvents(): void;
  71617. /**
  71618. * Unregister the clipboard Events from the canvas
  71619. */
  71620. unRegisterClipboardEvents(): void;
  71621. /**
  71622. * Connect the texture to a hosting mesh to enable interactions
  71623. * @param mesh defines the mesh to attach to
  71624. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71625. */
  71626. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71627. /**
  71628. * Move the focus to a specific control
  71629. * @param control defines the control which will receive the focus
  71630. */
  71631. moveFocusToControl(control: IFocusableControl): void;
  71632. private _manageFocus;
  71633. private _attachToOnPointerOut;
  71634. /**
  71635. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71636. * @param mesh defines the mesh which will receive the texture
  71637. * @param width defines the texture width (1024 by default)
  71638. * @param height defines the texture height (1024 by default)
  71639. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71640. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71641. * @returns a new AdvancedDynamicTexture
  71642. */
  71643. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71644. /**
  71645. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71646. * In this mode the texture will rely on a layer for its rendering.
  71647. * This allows it to be treated like any other layer.
  71648. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71649. * LayerMask is set through advancedTexture.layer.layerMask
  71650. * @param name defines name for the texture
  71651. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71652. * @param scene defines the hsoting scene
  71653. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71654. * @returns a new AdvancedDynamicTexture
  71655. */
  71656. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71657. }
  71658. }
  71659. declare module BABYLON.GUI {
  71660. /**
  71661. * Root class used for all 2D controls
  71662. * @see http://doc.babylonjs.com/how_to/gui#controls
  71663. */
  71664. export class Control {
  71665. /** defines the name of the control */
  71666. name?: string | undefined;
  71667. /**
  71668. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71669. */
  71670. static AllowAlphaInheritance: boolean;
  71671. private _alpha;
  71672. private _alphaSet;
  71673. private _zIndex;
  71674. /** @hidden */
  71675. _host: AdvancedDynamicTexture;
  71676. /** Gets or sets the control parent */
  71677. parent: BABYLON.Nullable<Container>;
  71678. /** @hidden */
  71679. _currentMeasure: Measure;
  71680. private _fontFamily;
  71681. private _fontStyle;
  71682. private _fontWeight;
  71683. private _fontSize;
  71684. private _font;
  71685. /** @hidden */
  71686. _width: ValueAndUnit;
  71687. /** @hidden */
  71688. _height: ValueAndUnit;
  71689. /** @hidden */
  71690. protected _fontOffset: {
  71691. ascent: number;
  71692. height: number;
  71693. descent: number;
  71694. };
  71695. private _color;
  71696. private _style;
  71697. private _styleObserver;
  71698. /** @hidden */
  71699. protected _horizontalAlignment: number;
  71700. /** @hidden */
  71701. protected _verticalAlignment: number;
  71702. /** @hidden */
  71703. protected _isDirty: boolean;
  71704. /** @hidden */
  71705. protected _wasDirty: boolean;
  71706. /** @hidden */
  71707. _tempParentMeasure: Measure;
  71708. /** @hidden */
  71709. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71710. /** @hidden */
  71711. protected _cachedParentMeasure: Measure;
  71712. private _paddingLeft;
  71713. private _paddingRight;
  71714. private _paddingTop;
  71715. private _paddingBottom;
  71716. /** @hidden */
  71717. _left: ValueAndUnit;
  71718. /** @hidden */
  71719. _top: ValueAndUnit;
  71720. private _scaleX;
  71721. private _scaleY;
  71722. private _rotation;
  71723. private _transformCenterX;
  71724. private _transformCenterY;
  71725. /** @hidden */
  71726. _transformMatrix: Matrix2D;
  71727. /** @hidden */
  71728. protected _invertTransformMatrix: Matrix2D;
  71729. /** @hidden */
  71730. protected _transformedPosition: BABYLON.Vector2;
  71731. private _isMatrixDirty;
  71732. private _cachedOffsetX;
  71733. private _cachedOffsetY;
  71734. private _isVisible;
  71735. private _isHighlighted;
  71736. /** @hidden */
  71737. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71738. private _fontSet;
  71739. private _dummyVector2;
  71740. private _downCount;
  71741. private _enterCount;
  71742. private _doNotRender;
  71743. private _downPointerIds;
  71744. protected _isEnabled: boolean;
  71745. protected _disabledColor: string;
  71746. protected _disabledColorItem: string;
  71747. /** @hidden */
  71748. protected _rebuildLayout: boolean;
  71749. /** @hidden */
  71750. _customData: any;
  71751. /** @hidden */
  71752. _isClipped: boolean;
  71753. /** @hidden */
  71754. _automaticSize: boolean;
  71755. /** @hidden */
  71756. _tag: any;
  71757. /**
  71758. * 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
  71759. */
  71760. uniqueId: number;
  71761. /**
  71762. * Gets or sets an object used to store user defined information for the node
  71763. */
  71764. metadata: any;
  71765. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71766. isHitTestVisible: boolean;
  71767. /** Gets or sets a boolean indicating if the control can block pointer events */
  71768. isPointerBlocker: boolean;
  71769. /** Gets or sets a boolean indicating if the control can be focusable */
  71770. isFocusInvisible: boolean;
  71771. /**
  71772. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71773. * 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
  71774. */
  71775. clipChildren: boolean;
  71776. /**
  71777. * Gets or sets a boolean indicating that control content must be clipped
  71778. * 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
  71779. */
  71780. clipContent: boolean;
  71781. /**
  71782. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71783. */
  71784. useBitmapCache: boolean;
  71785. private _cacheData;
  71786. private _shadowOffsetX;
  71787. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71788. get shadowOffsetX(): number;
  71789. set shadowOffsetX(value: number);
  71790. private _shadowOffsetY;
  71791. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71792. get shadowOffsetY(): number;
  71793. set shadowOffsetY(value: number);
  71794. private _shadowBlur;
  71795. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71796. get shadowBlur(): number;
  71797. set shadowBlur(value: number);
  71798. private _shadowColor;
  71799. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71800. get shadowColor(): string;
  71801. set shadowColor(value: string);
  71802. /** Gets or sets the cursor to use when the control is hovered */
  71803. hoverCursor: string;
  71804. /** @hidden */
  71805. protected _linkOffsetX: ValueAndUnit;
  71806. /** @hidden */
  71807. protected _linkOffsetY: ValueAndUnit;
  71808. /** Gets the control type name */
  71809. get typeName(): string;
  71810. /**
  71811. * Get the current class name of the control.
  71812. * @returns current class name
  71813. */
  71814. getClassName(): string;
  71815. /**
  71816. * An event triggered when pointer wheel is scrolled
  71817. */
  71818. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71819. /**
  71820. * An event triggered when the pointer move over the control.
  71821. */
  71822. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71823. /**
  71824. * An event triggered when the pointer move out of the control.
  71825. */
  71826. onPointerOutObservable: BABYLON.Observable<Control>;
  71827. /**
  71828. * An event triggered when the pointer taps the control
  71829. */
  71830. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71831. /**
  71832. * An event triggered when pointer up
  71833. */
  71834. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71835. /**
  71836. * An event triggered when a control is clicked on
  71837. */
  71838. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71839. /**
  71840. * An event triggered when pointer enters the control
  71841. */
  71842. onPointerEnterObservable: BABYLON.Observable<Control>;
  71843. /**
  71844. * An event triggered when the control is marked as dirty
  71845. */
  71846. onDirtyObservable: BABYLON.Observable<Control>;
  71847. /**
  71848. * An event triggered before drawing the control
  71849. */
  71850. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71851. /**
  71852. * An event triggered after the control was drawn
  71853. */
  71854. onAfterDrawObservable: BABYLON.Observable<Control>;
  71855. /**
  71856. * Get the hosting AdvancedDynamicTexture
  71857. */
  71858. get host(): AdvancedDynamicTexture;
  71859. /** Gets or set information about font offsets (used to render and align text) */
  71860. get fontOffset(): {
  71861. ascent: number;
  71862. height: number;
  71863. descent: number;
  71864. };
  71865. set fontOffset(offset: {
  71866. ascent: number;
  71867. height: number;
  71868. descent: number;
  71869. });
  71870. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71871. get alpha(): number;
  71872. set alpha(value: number);
  71873. /**
  71874. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71875. */
  71876. get isHighlighted(): boolean;
  71877. set isHighlighted(value: boolean);
  71878. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71879. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71880. */
  71881. get scaleX(): number;
  71882. set scaleX(value: number);
  71883. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71884. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71885. */
  71886. get scaleY(): number;
  71887. set scaleY(value: number);
  71888. /** Gets or sets the rotation angle (0 by default)
  71889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71890. */
  71891. get rotation(): number;
  71892. set rotation(value: number);
  71893. /** Gets or sets the transformation center on Y axis (0 by default)
  71894. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71895. */
  71896. get transformCenterY(): number;
  71897. set transformCenterY(value: number);
  71898. /** Gets or sets the transformation center on X axis (0 by default)
  71899. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71900. */
  71901. get transformCenterX(): number;
  71902. set transformCenterX(value: number);
  71903. /**
  71904. * Gets or sets the horizontal alignment
  71905. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71906. */
  71907. get horizontalAlignment(): number;
  71908. set horizontalAlignment(value: number);
  71909. /**
  71910. * Gets or sets the vertical alignment
  71911. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71912. */
  71913. get verticalAlignment(): number;
  71914. set verticalAlignment(value: number);
  71915. /**
  71916. * Gets or sets control width
  71917. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71918. */
  71919. get width(): string | number;
  71920. set width(value: string | number);
  71921. /**
  71922. * Gets or sets the control width in pixel
  71923. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71924. */
  71925. get widthInPixels(): number;
  71926. set widthInPixels(value: number);
  71927. /**
  71928. * Gets or sets control height
  71929. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71930. */
  71931. get height(): string | number;
  71932. set height(value: string | number);
  71933. /**
  71934. * Gets or sets control height in pixel
  71935. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71936. */
  71937. get heightInPixels(): number;
  71938. set heightInPixels(value: number);
  71939. /** Gets or set font family */
  71940. get fontFamily(): string;
  71941. set fontFamily(value: string);
  71942. /** Gets or sets font style */
  71943. get fontStyle(): string;
  71944. set fontStyle(value: string);
  71945. /** Gets or sets font weight */
  71946. get fontWeight(): string;
  71947. set fontWeight(value: string);
  71948. /**
  71949. * Gets or sets style
  71950. * @see http://doc.babylonjs.com/how_to/gui#styles
  71951. */
  71952. get style(): BABYLON.Nullable<Style>;
  71953. set style(value: BABYLON.Nullable<Style>);
  71954. /** @hidden */
  71955. get _isFontSizeInPercentage(): boolean;
  71956. /** Gets or sets font size in pixels */
  71957. get fontSizeInPixels(): number;
  71958. set fontSizeInPixels(value: number);
  71959. /** Gets or sets font size */
  71960. get fontSize(): string | number;
  71961. set fontSize(value: string | number);
  71962. /** Gets or sets foreground color */
  71963. get color(): string;
  71964. set color(value: string);
  71965. /** Gets or sets z index which is used to reorder controls on the z axis */
  71966. get zIndex(): number;
  71967. set zIndex(value: number);
  71968. /** Gets or sets a boolean indicating if the control can be rendered */
  71969. get notRenderable(): boolean;
  71970. set notRenderable(value: boolean);
  71971. /** Gets or sets a boolean indicating if the control is visible */
  71972. get isVisible(): boolean;
  71973. set isVisible(value: boolean);
  71974. /** Gets a boolean indicating that the control needs to update its rendering */
  71975. get isDirty(): boolean;
  71976. /**
  71977. * Gets the current linked mesh (or null if none)
  71978. */
  71979. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71980. /**
  71981. * Gets or sets a value indicating the padding to use on the left of the control
  71982. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71983. */
  71984. get paddingLeft(): string | number;
  71985. set paddingLeft(value: string | number);
  71986. /**
  71987. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71989. */
  71990. get paddingLeftInPixels(): number;
  71991. set paddingLeftInPixels(value: number);
  71992. /**
  71993. * Gets or sets a value indicating the padding to use on the right of the control
  71994. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71995. */
  71996. get paddingRight(): string | number;
  71997. set paddingRight(value: string | number);
  71998. /**
  71999. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72001. */
  72002. get paddingRightInPixels(): number;
  72003. set paddingRightInPixels(value: number);
  72004. /**
  72005. * Gets or sets a value indicating the padding to use on the top of the control
  72006. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72007. */
  72008. get paddingTop(): string | number;
  72009. set paddingTop(value: string | number);
  72010. /**
  72011. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72012. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72013. */
  72014. get paddingTopInPixels(): number;
  72015. set paddingTopInPixels(value: number);
  72016. /**
  72017. * Gets or sets a value indicating the padding to use on the bottom of the control
  72018. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72019. */
  72020. get paddingBottom(): string | number;
  72021. set paddingBottom(value: string | number);
  72022. /**
  72023. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72024. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72025. */
  72026. get paddingBottomInPixels(): number;
  72027. set paddingBottomInPixels(value: number);
  72028. /**
  72029. * Gets or sets a value indicating the left coordinate of the control
  72030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72031. */
  72032. get left(): string | number;
  72033. set left(value: string | number);
  72034. /**
  72035. * Gets or sets a value indicating the left coordinate in pixels of the control
  72036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72037. */
  72038. get leftInPixels(): number;
  72039. set leftInPixels(value: number);
  72040. /**
  72041. * Gets or sets a value indicating the top coordinate of the control
  72042. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72043. */
  72044. get top(): string | number;
  72045. set top(value: string | number);
  72046. /**
  72047. * Gets or sets a value indicating the top coordinate in pixels of the control
  72048. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72049. */
  72050. get topInPixels(): number;
  72051. set topInPixels(value: number);
  72052. /**
  72053. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72054. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72055. */
  72056. get linkOffsetX(): string | number;
  72057. set linkOffsetX(value: string | number);
  72058. /**
  72059. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72060. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72061. */
  72062. get linkOffsetXInPixels(): number;
  72063. set linkOffsetXInPixels(value: number);
  72064. /**
  72065. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72066. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72067. */
  72068. get linkOffsetY(): string | number;
  72069. set linkOffsetY(value: string | number);
  72070. /**
  72071. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72072. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72073. */
  72074. get linkOffsetYInPixels(): number;
  72075. set linkOffsetYInPixels(value: number);
  72076. /** Gets the center coordinate on X axis */
  72077. get centerX(): number;
  72078. /** Gets the center coordinate on Y axis */
  72079. get centerY(): number;
  72080. /** Gets or sets if control is Enabled*/
  72081. get isEnabled(): boolean;
  72082. set isEnabled(value: boolean);
  72083. /** Gets or sets background color of control if it's disabled*/
  72084. get disabledColor(): string;
  72085. set disabledColor(value: string);
  72086. /** Gets or sets front color of control if it's disabled*/
  72087. get disabledColorItem(): string;
  72088. set disabledColorItem(value: string);
  72089. /**
  72090. * Creates a new control
  72091. * @param name defines the name of the control
  72092. */
  72093. constructor(
  72094. /** defines the name of the control */
  72095. name?: string | undefined);
  72096. /** @hidden */
  72097. protected _getTypeName(): string;
  72098. /**
  72099. * Gets the first ascendant in the hierarchy of the given type
  72100. * @param className defines the required type
  72101. * @returns the ascendant or null if not found
  72102. */
  72103. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72104. /** @hidden */
  72105. _resetFontCache(): void;
  72106. /**
  72107. * Determines if a container is an ascendant of the current control
  72108. * @param container defines the container to look for
  72109. * @returns true if the container is one of the ascendant of the control
  72110. */
  72111. isAscendant(container: Control): boolean;
  72112. /**
  72113. * Gets coordinates in local control space
  72114. * @param globalCoordinates defines the coordinates to transform
  72115. * @returns the new coordinates in local space
  72116. */
  72117. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72118. /**
  72119. * Gets coordinates in local control space
  72120. * @param globalCoordinates defines the coordinates to transform
  72121. * @param result defines the target vector2 where to store the result
  72122. * @returns the current control
  72123. */
  72124. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72125. /**
  72126. * Gets coordinates in parent local control space
  72127. * @param globalCoordinates defines the coordinates to transform
  72128. * @returns the new coordinates in parent local space
  72129. */
  72130. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72131. /**
  72132. * Move the current control to a vector3 position projected onto the screen.
  72133. * @param position defines the target position
  72134. * @param scene defines the hosting scene
  72135. */
  72136. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72137. /**
  72138. * Will store all controls that have this control as ascendant in a given array
  72139. * @param results defines the array where to store the descendants
  72140. * @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
  72141. * @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
  72142. */
  72143. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72144. /**
  72145. * Will return all controls that have this control as ascendant
  72146. * @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
  72147. * @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
  72148. * @return all child controls
  72149. */
  72150. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72151. /**
  72152. * Link current control with a target mesh
  72153. * @param mesh defines the mesh to link with
  72154. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72155. */
  72156. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72157. /** @hidden */
  72158. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72159. /** @hidden */
  72160. _offsetLeft(offset: number): void;
  72161. /** @hidden */
  72162. _offsetTop(offset: number): void;
  72163. /** @hidden */
  72164. _markMatrixAsDirty(): void;
  72165. /** @hidden */
  72166. _flagDescendantsAsMatrixDirty(): void;
  72167. /** @hidden */
  72168. _intersectsRect(rect: Measure): boolean;
  72169. /** @hidden */
  72170. protected invalidateRect(): void;
  72171. /** @hidden */
  72172. _markAsDirty(force?: boolean): void;
  72173. /** @hidden */
  72174. _markAllAsDirty(): void;
  72175. /** @hidden */
  72176. _link(host: AdvancedDynamicTexture): void;
  72177. /** @hidden */
  72178. protected _transform(context?: CanvasRenderingContext2D): void;
  72179. /** @hidden */
  72180. _renderHighlight(context: CanvasRenderingContext2D): void;
  72181. /** @hidden */
  72182. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72183. /** @hidden */
  72184. protected _applyStates(context: CanvasRenderingContext2D): void;
  72185. /** @hidden */
  72186. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72187. /** @hidden */
  72188. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72189. protected _evaluateClippingState(parentMeasure: Measure): void;
  72190. /** @hidden */
  72191. _measure(): void;
  72192. /** @hidden */
  72193. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72194. /** @hidden */
  72195. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72196. /** @hidden */
  72197. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72198. /** @hidden */
  72199. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72200. private static _ClipMeasure;
  72201. private _tmpMeasureA;
  72202. private _clip;
  72203. /** @hidden */
  72204. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72205. /** @hidden */
  72206. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72207. /**
  72208. * Tests if a given coordinates belong to the current control
  72209. * @param x defines x coordinate to test
  72210. * @param y defines y coordinate to test
  72211. * @returns true if the coordinates are inside the control
  72212. */
  72213. contains(x: number, y: number): boolean;
  72214. /** @hidden */
  72215. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72216. /** @hidden */
  72217. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72218. /** @hidden */
  72219. _onPointerEnter(target: Control): boolean;
  72220. /** @hidden */
  72221. _onPointerOut(target: Control, force?: boolean): void;
  72222. /** @hidden */
  72223. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72224. /** @hidden */
  72225. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72226. /** @hidden */
  72227. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72228. /** @hidden */
  72229. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72230. /** @hidden */
  72231. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72232. private _prepareFont;
  72233. /** Releases associated resources */
  72234. dispose(): void;
  72235. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72236. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72237. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72238. private static _VERTICAL_ALIGNMENT_TOP;
  72239. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72240. private static _VERTICAL_ALIGNMENT_CENTER;
  72241. /** HORIZONTAL_ALIGNMENT_LEFT */
  72242. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72243. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72244. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72245. /** HORIZONTAL_ALIGNMENT_CENTER */
  72246. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72247. /** VERTICAL_ALIGNMENT_TOP */
  72248. static get VERTICAL_ALIGNMENT_TOP(): number;
  72249. /** VERTICAL_ALIGNMENT_BOTTOM */
  72250. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72251. /** VERTICAL_ALIGNMENT_CENTER */
  72252. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72253. private static _FontHeightSizes;
  72254. /** @hidden */
  72255. static _GetFontOffset(font: string): {
  72256. ascent: number;
  72257. height: number;
  72258. descent: number;
  72259. };
  72260. /**
  72261. * Creates a stack panel that can be used to render headers
  72262. * @param control defines the control to associate with the header
  72263. * @param text defines the text of the header
  72264. * @param size defines the size of the header
  72265. * @param options defines options used to configure the header
  72266. * @returns a new StackPanel
  72267. * @ignore
  72268. * @hidden
  72269. */
  72270. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72271. isHorizontal: boolean;
  72272. controlFirst: boolean;
  72273. }) => any;
  72274. /** @hidden */
  72275. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72276. }
  72277. }
  72278. declare module BABYLON.GUI {
  72279. /**
  72280. * Root class for 2D containers
  72281. * @see http://doc.babylonjs.com/how_to/gui#containers
  72282. */
  72283. export class Container extends Control {
  72284. name?: string | undefined;
  72285. /** @hidden */
  72286. _children: Control[];
  72287. /** @hidden */
  72288. protected _measureForChildren: Measure;
  72289. /** @hidden */
  72290. protected _background: string;
  72291. /** @hidden */
  72292. protected _adaptWidthToChildren: boolean;
  72293. /** @hidden */
  72294. protected _adaptHeightToChildren: boolean;
  72295. /**
  72296. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72297. */
  72298. logLayoutCycleErrors: boolean;
  72299. /**
  72300. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72301. */
  72302. maxLayoutCycle: number;
  72303. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72304. get adaptHeightToChildren(): boolean;
  72305. set adaptHeightToChildren(value: boolean);
  72306. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72307. get adaptWidthToChildren(): boolean;
  72308. set adaptWidthToChildren(value: boolean);
  72309. /** Gets or sets background color */
  72310. get background(): string;
  72311. set background(value: string);
  72312. /** Gets the list of children */
  72313. get children(): Control[];
  72314. /**
  72315. * Creates a new Container
  72316. * @param name defines the name of the container
  72317. */
  72318. constructor(name?: string | undefined);
  72319. protected _getTypeName(): string;
  72320. _flagDescendantsAsMatrixDirty(): void;
  72321. /**
  72322. * Gets a child using its name
  72323. * @param name defines the child name to look for
  72324. * @returns the child control if found
  72325. */
  72326. getChildByName(name: string): BABYLON.Nullable<Control>;
  72327. /**
  72328. * Gets a child using its type and its name
  72329. * @param name defines the child name to look for
  72330. * @param type defines the child type to look for
  72331. * @returns the child control if found
  72332. */
  72333. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72334. /**
  72335. * Search for a specific control in children
  72336. * @param control defines the control to look for
  72337. * @returns true if the control is in child list
  72338. */
  72339. containsControl(control: Control): boolean;
  72340. /**
  72341. * Adds a new control to the current container
  72342. * @param control defines the control to add
  72343. * @returns the current container
  72344. */
  72345. addControl(control: BABYLON.Nullable<Control>): Container;
  72346. /**
  72347. * Removes all controls from the current container
  72348. * @returns the current container
  72349. */
  72350. clearControls(): Container;
  72351. /**
  72352. * Removes a control from the current container
  72353. * @param control defines the control to remove
  72354. * @returns the current container
  72355. */
  72356. removeControl(control: Control): Container;
  72357. /** @hidden */
  72358. _reOrderControl(control: Control): void;
  72359. /** @hidden */
  72360. _offsetLeft(offset: number): void;
  72361. /** @hidden */
  72362. _offsetTop(offset: number): void;
  72363. /** @hidden */
  72364. _markAllAsDirty(): void;
  72365. /** @hidden */
  72366. protected _localDraw(context: CanvasRenderingContext2D): void;
  72367. /** @hidden */
  72368. _link(host: AdvancedDynamicTexture): void;
  72369. /** @hidden */
  72370. protected _beforeLayout(): void;
  72371. /** @hidden */
  72372. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72373. /** @hidden */
  72374. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72375. protected _postMeasure(): void;
  72376. /** @hidden */
  72377. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72378. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72379. /** @hidden */
  72380. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72381. /** @hidden */
  72382. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72383. /** Releases associated resources */
  72384. dispose(): void;
  72385. }
  72386. }
  72387. declare module BABYLON.GUI {
  72388. /** Class used to create rectangle container */
  72389. export class Rectangle extends Container {
  72390. name?: string | undefined;
  72391. private _thickness;
  72392. private _cornerRadius;
  72393. /** Gets or sets border thickness */
  72394. get thickness(): number;
  72395. set thickness(value: number);
  72396. /** Gets or sets the corner radius angle */
  72397. get cornerRadius(): number;
  72398. set cornerRadius(value: number);
  72399. /**
  72400. * Creates a new Rectangle
  72401. * @param name defines the control name
  72402. */
  72403. constructor(name?: string | undefined);
  72404. protected _getTypeName(): string;
  72405. protected _localDraw(context: CanvasRenderingContext2D): void;
  72406. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72407. private _drawRoundedRect;
  72408. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72409. }
  72410. }
  72411. declare module BABYLON.GUI {
  72412. /**
  72413. * Enum that determines the text-wrapping mode to use.
  72414. */
  72415. export enum TextWrapping {
  72416. /**
  72417. * Clip the text when it's larger than Control.width; this is the default mode.
  72418. */
  72419. Clip = 0,
  72420. /**
  72421. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72422. */
  72423. WordWrap = 1,
  72424. /**
  72425. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72426. */
  72427. Ellipsis = 2
  72428. }
  72429. /**
  72430. * Class used to create text block control
  72431. */
  72432. export class TextBlock extends Control {
  72433. /**
  72434. * Defines the name of the control
  72435. */
  72436. name?: string | undefined;
  72437. private _text;
  72438. private _textWrapping;
  72439. private _textHorizontalAlignment;
  72440. private _textVerticalAlignment;
  72441. private _lines;
  72442. private _resizeToFit;
  72443. private _lineSpacing;
  72444. private _outlineWidth;
  72445. private _outlineColor;
  72446. /**
  72447. * An event triggered after the text is changed
  72448. */
  72449. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72450. /**
  72451. * An event triggered after the text was broken up into lines
  72452. */
  72453. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72454. /**
  72455. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72456. */
  72457. get lines(): any[];
  72458. /**
  72459. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72460. */
  72461. get resizeToFit(): boolean;
  72462. /**
  72463. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72464. */
  72465. set resizeToFit(value: boolean);
  72466. /**
  72467. * Gets or sets a boolean indicating if text must be wrapped
  72468. */
  72469. get textWrapping(): TextWrapping | boolean;
  72470. /**
  72471. * Gets or sets a boolean indicating if text must be wrapped
  72472. */
  72473. set textWrapping(value: TextWrapping | boolean);
  72474. /**
  72475. * Gets or sets text to display
  72476. */
  72477. get text(): string;
  72478. /**
  72479. * Gets or sets text to display
  72480. */
  72481. set text(value: string);
  72482. /**
  72483. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72484. */
  72485. get textHorizontalAlignment(): number;
  72486. /**
  72487. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72488. */
  72489. set textHorizontalAlignment(value: number);
  72490. /**
  72491. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72492. */
  72493. get textVerticalAlignment(): number;
  72494. /**
  72495. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72496. */
  72497. set textVerticalAlignment(value: number);
  72498. /**
  72499. * Gets or sets line spacing value
  72500. */
  72501. set lineSpacing(value: string | number);
  72502. /**
  72503. * Gets or sets line spacing value
  72504. */
  72505. get lineSpacing(): string | number;
  72506. /**
  72507. * Gets or sets outlineWidth of the text to display
  72508. */
  72509. get outlineWidth(): number;
  72510. /**
  72511. * Gets or sets outlineWidth of the text to display
  72512. */
  72513. set outlineWidth(value: number);
  72514. /**
  72515. * Gets or sets outlineColor of the text to display
  72516. */
  72517. get outlineColor(): string;
  72518. /**
  72519. * Gets or sets outlineColor of the text to display
  72520. */
  72521. set outlineColor(value: string);
  72522. /**
  72523. * Creates a new TextBlock object
  72524. * @param name defines the name of the control
  72525. * @param text defines the text to display (emptry string by default)
  72526. */
  72527. constructor(
  72528. /**
  72529. * Defines the name of the control
  72530. */
  72531. name?: string | undefined, text?: string);
  72532. protected _getTypeName(): string;
  72533. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72534. private _drawText;
  72535. /** @hidden */
  72536. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72537. protected _applyStates(context: CanvasRenderingContext2D): void;
  72538. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72539. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72540. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72541. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72542. protected _renderLines(context: CanvasRenderingContext2D): void;
  72543. /**
  72544. * Given a width constraint applied on the text block, find the expected height
  72545. * @returns expected height
  72546. */
  72547. computeExpectedHeight(): number;
  72548. dispose(): void;
  72549. }
  72550. }
  72551. declare module BABYLON.GUI {
  72552. /**
  72553. * Class used to create 2D images
  72554. */
  72555. export class Image extends Control {
  72556. name?: string | undefined;
  72557. private _workingCanvas;
  72558. private _domImage;
  72559. private _imageWidth;
  72560. private _imageHeight;
  72561. private _loaded;
  72562. private _stretch;
  72563. private _source;
  72564. private _autoScale;
  72565. private _sourceLeft;
  72566. private _sourceTop;
  72567. private _sourceWidth;
  72568. private _sourceHeight;
  72569. private _svgAttributesComputationCompleted;
  72570. private _isSVG;
  72571. private _cellWidth;
  72572. private _cellHeight;
  72573. private _cellId;
  72574. private _populateNinePatchSlicesFromImage;
  72575. private _sliceLeft;
  72576. private _sliceRight;
  72577. private _sliceTop;
  72578. private _sliceBottom;
  72579. private _detectPointerOnOpaqueOnly;
  72580. /**
  72581. * BABYLON.Observable notified when the content is loaded
  72582. */
  72583. onImageLoadedObservable: BABYLON.Observable<Image>;
  72584. /**
  72585. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72586. */
  72587. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72588. /**
  72589. * Gets a boolean indicating that the content is loaded
  72590. */
  72591. get isLoaded(): boolean;
  72592. /**
  72593. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72594. */
  72595. get populateNinePatchSlicesFromImage(): boolean;
  72596. set populateNinePatchSlicesFromImage(value: boolean);
  72597. /**
  72598. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72599. * Beware using this as this will comsume more memory as the image has to be stored twice
  72600. */
  72601. get detectPointerOnOpaqueOnly(): boolean;
  72602. set detectPointerOnOpaqueOnly(value: boolean);
  72603. /**
  72604. * Gets or sets the left value for slicing (9-patch)
  72605. */
  72606. get sliceLeft(): number;
  72607. set sliceLeft(value: number);
  72608. /**
  72609. * Gets or sets the right value for slicing (9-patch)
  72610. */
  72611. get sliceRight(): number;
  72612. set sliceRight(value: number);
  72613. /**
  72614. * Gets or sets the top value for slicing (9-patch)
  72615. */
  72616. get sliceTop(): number;
  72617. set sliceTop(value: number);
  72618. /**
  72619. * Gets or sets the bottom value for slicing (9-patch)
  72620. */
  72621. get sliceBottom(): number;
  72622. set sliceBottom(value: number);
  72623. /**
  72624. * Gets or sets the left coordinate in the source image
  72625. */
  72626. get sourceLeft(): number;
  72627. set sourceLeft(value: number);
  72628. /**
  72629. * Gets or sets the top coordinate in the source image
  72630. */
  72631. get sourceTop(): number;
  72632. set sourceTop(value: number);
  72633. /**
  72634. * Gets or sets the width to capture in the source image
  72635. */
  72636. get sourceWidth(): number;
  72637. set sourceWidth(value: number);
  72638. /**
  72639. * Gets or sets the height to capture in the source image
  72640. */
  72641. get sourceHeight(): number;
  72642. set sourceHeight(value: number);
  72643. /** Indicates if the format of the image is SVG */
  72644. get isSVG(): boolean;
  72645. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72646. get svgAttributesComputationCompleted(): boolean;
  72647. /**
  72648. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72649. * @see http://doc.babylonjs.com/how_to/gui#image
  72650. */
  72651. get autoScale(): boolean;
  72652. set autoScale(value: boolean);
  72653. /** Gets or sets the streching mode used by the image */
  72654. get stretch(): number;
  72655. set stretch(value: number);
  72656. /** @hidden */
  72657. _rotate90(n: number, preserveProperties?: boolean): Image;
  72658. private _handleRotationForSVGImage;
  72659. private _rotate90SourceProperties;
  72660. /**
  72661. * Gets or sets the internal DOM image used to render the control
  72662. */
  72663. set domImage(value: HTMLImageElement);
  72664. get domImage(): HTMLImageElement;
  72665. private _onImageLoaded;
  72666. private _extractNinePatchSliceDataFromImage;
  72667. /**
  72668. * Gets or sets image source url
  72669. */
  72670. set source(value: BABYLON.Nullable<string>);
  72671. /**
  72672. * Checks for svg document with icon id present
  72673. */
  72674. private _svgCheck;
  72675. /**
  72676. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72677. * given external svg file and icon id
  72678. */
  72679. private _getSVGAttribs;
  72680. /**
  72681. * Gets or sets the cell width to use when animation sheet is enabled
  72682. * @see http://doc.babylonjs.com/how_to/gui#image
  72683. */
  72684. get cellWidth(): number;
  72685. set cellWidth(value: number);
  72686. /**
  72687. * Gets or sets the cell height to use when animation sheet is enabled
  72688. * @see http://doc.babylonjs.com/how_to/gui#image
  72689. */
  72690. get cellHeight(): number;
  72691. set cellHeight(value: number);
  72692. /**
  72693. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72694. * @see http://doc.babylonjs.com/how_to/gui#image
  72695. */
  72696. get cellId(): number;
  72697. set cellId(value: number);
  72698. /**
  72699. * Creates a new Image
  72700. * @param name defines the control name
  72701. * @param url defines the image url
  72702. */
  72703. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72704. /**
  72705. * Tests if a given coordinates belong to the current control
  72706. * @param x defines x coordinate to test
  72707. * @param y defines y coordinate to test
  72708. * @returns true if the coordinates are inside the control
  72709. */
  72710. contains(x: number, y: number): boolean;
  72711. protected _getTypeName(): string;
  72712. /** Force the control to synchronize with its content */
  72713. synchronizeSizeWithContent(): void;
  72714. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72715. private _prepareWorkingCanvasForOpaqueDetection;
  72716. private _drawImage;
  72717. _draw(context: CanvasRenderingContext2D): void;
  72718. private _renderCornerPatch;
  72719. private _renderNinePatch;
  72720. dispose(): void;
  72721. /** STRETCH_NONE */
  72722. static readonly STRETCH_NONE: number;
  72723. /** STRETCH_FILL */
  72724. static readonly STRETCH_FILL: number;
  72725. /** STRETCH_UNIFORM */
  72726. static readonly STRETCH_UNIFORM: number;
  72727. /** STRETCH_EXTEND */
  72728. static readonly STRETCH_EXTEND: number;
  72729. /** NINE_PATCH */
  72730. static readonly STRETCH_NINE_PATCH: number;
  72731. }
  72732. }
  72733. declare module BABYLON.GUI {
  72734. /**
  72735. * Class used to create 2D buttons
  72736. */
  72737. export class Button extends Rectangle {
  72738. name?: string | undefined;
  72739. /**
  72740. * Function called to generate a pointer enter animation
  72741. */
  72742. pointerEnterAnimation: () => void;
  72743. /**
  72744. * Function called to generate a pointer out animation
  72745. */
  72746. pointerOutAnimation: () => void;
  72747. /**
  72748. * Function called to generate a pointer down animation
  72749. */
  72750. pointerDownAnimation: () => void;
  72751. /**
  72752. * Function called to generate a pointer up animation
  72753. */
  72754. pointerUpAnimation: () => void;
  72755. /**
  72756. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72757. */
  72758. delegatePickingToChildren: boolean;
  72759. private _image;
  72760. /**
  72761. * Returns the image part of the button (if any)
  72762. */
  72763. get image(): BABYLON.Nullable<Image>;
  72764. private _textBlock;
  72765. /**
  72766. * Returns the image part of the button (if any)
  72767. */
  72768. get textBlock(): BABYLON.Nullable<TextBlock>;
  72769. /**
  72770. * Creates a new Button
  72771. * @param name defines the name of the button
  72772. */
  72773. constructor(name?: string | undefined);
  72774. protected _getTypeName(): string;
  72775. /** @hidden */
  72776. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72777. /** @hidden */
  72778. _onPointerEnter(target: Control): boolean;
  72779. /** @hidden */
  72780. _onPointerOut(target: Control, force?: boolean): void;
  72781. /** @hidden */
  72782. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72783. /** @hidden */
  72784. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72785. /**
  72786. * Creates a new button made with an image and a text
  72787. * @param name defines the name of the button
  72788. * @param text defines the text of the button
  72789. * @param imageUrl defines the url of the image
  72790. * @returns a new Button
  72791. */
  72792. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72793. /**
  72794. * Creates a new button made with an image
  72795. * @param name defines the name of the button
  72796. * @param imageUrl defines the url of the image
  72797. * @returns a new Button
  72798. */
  72799. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72800. /**
  72801. * Creates a new button made with a text
  72802. * @param name defines the name of the button
  72803. * @param text defines the text of the button
  72804. * @returns a new Button
  72805. */
  72806. static CreateSimpleButton(name: string, text: string): Button;
  72807. /**
  72808. * Creates a new button made with an image and a centered text
  72809. * @param name defines the name of the button
  72810. * @param text defines the text of the button
  72811. * @param imageUrl defines the url of the image
  72812. * @returns a new Button
  72813. */
  72814. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72815. }
  72816. }
  72817. declare module BABYLON.GUI {
  72818. /**
  72819. * Class used to create a 2D stack panel container
  72820. */
  72821. export class StackPanel extends Container {
  72822. name?: string | undefined;
  72823. private _isVertical;
  72824. private _manualWidth;
  72825. private _manualHeight;
  72826. private _doNotTrackManualChanges;
  72827. /**
  72828. * Gets or sets a boolean indicating that layou warnings should be ignored
  72829. */
  72830. ignoreLayoutWarnings: boolean;
  72831. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72832. get isVertical(): boolean;
  72833. set isVertical(value: boolean);
  72834. /**
  72835. * Gets or sets panel width.
  72836. * This value should not be set when in horizontal mode as it will be computed automatically
  72837. */
  72838. set width(value: string | number);
  72839. get width(): string | number;
  72840. /**
  72841. * Gets or sets panel height.
  72842. * This value should not be set when in vertical mode as it will be computed automatically
  72843. */
  72844. set height(value: string | number);
  72845. get height(): string | number;
  72846. /**
  72847. * Creates a new StackPanel
  72848. * @param name defines control name
  72849. */
  72850. constructor(name?: string | undefined);
  72851. protected _getTypeName(): string;
  72852. /** @hidden */
  72853. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72854. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72855. protected _postMeasure(): void;
  72856. }
  72857. }
  72858. declare module BABYLON.GUI {
  72859. /**
  72860. * Class used to represent a 2D checkbox
  72861. */
  72862. export class Checkbox extends Control {
  72863. name?: string | undefined;
  72864. private _isChecked;
  72865. private _background;
  72866. private _checkSizeRatio;
  72867. private _thickness;
  72868. /** Gets or sets border thickness */
  72869. get thickness(): number;
  72870. set thickness(value: number);
  72871. /**
  72872. * BABYLON.Observable raised when isChecked property changes
  72873. */
  72874. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72875. /** Gets or sets a value indicating the ratio between overall size and check size */
  72876. get checkSizeRatio(): number;
  72877. set checkSizeRatio(value: number);
  72878. /** Gets or sets background color */
  72879. get background(): string;
  72880. set background(value: string);
  72881. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72882. get isChecked(): boolean;
  72883. set isChecked(value: boolean);
  72884. /**
  72885. * Creates a new CheckBox
  72886. * @param name defines the control name
  72887. */
  72888. constructor(name?: string | undefined);
  72889. protected _getTypeName(): string;
  72890. /** @hidden */
  72891. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72892. /** @hidden */
  72893. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72894. /**
  72895. * Utility function to easily create a checkbox with a header
  72896. * @param title defines the label to use for the header
  72897. * @param onValueChanged defines the callback to call when value changes
  72898. * @returns a StackPanel containing the checkbox and a textBlock
  72899. */
  72900. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72901. }
  72902. }
  72903. declare module BABYLON.GUI {
  72904. /**
  72905. * Class used to store key control properties
  72906. */
  72907. export class KeyPropertySet {
  72908. /** Width */
  72909. width?: string;
  72910. /** Height */
  72911. height?: string;
  72912. /** Left padding */
  72913. paddingLeft?: string;
  72914. /** Right padding */
  72915. paddingRight?: string;
  72916. /** Top padding */
  72917. paddingTop?: string;
  72918. /** Bottom padding */
  72919. paddingBottom?: string;
  72920. /** Foreground color */
  72921. color?: string;
  72922. /** Background color */
  72923. background?: string;
  72924. }
  72925. /**
  72926. * Class used to create virtual keyboard
  72927. */
  72928. export class VirtualKeyboard extends StackPanel {
  72929. /** BABYLON.Observable raised when a key is pressed */
  72930. onKeyPressObservable: BABYLON.Observable<string>;
  72931. /** Gets or sets default key button width */
  72932. defaultButtonWidth: string;
  72933. /** Gets or sets default key button height */
  72934. defaultButtonHeight: string;
  72935. /** Gets or sets default key button left padding */
  72936. defaultButtonPaddingLeft: string;
  72937. /** Gets or sets default key button right padding */
  72938. defaultButtonPaddingRight: string;
  72939. /** Gets or sets default key button top padding */
  72940. defaultButtonPaddingTop: string;
  72941. /** Gets or sets default key button bottom padding */
  72942. defaultButtonPaddingBottom: string;
  72943. /** Gets or sets default key button foreground color */
  72944. defaultButtonColor: string;
  72945. /** Gets or sets default key button background color */
  72946. defaultButtonBackground: string;
  72947. /** Gets or sets shift button foreground color */
  72948. shiftButtonColor: string;
  72949. /** Gets or sets shift button thickness*/
  72950. selectedShiftThickness: number;
  72951. /** Gets shift key state */
  72952. shiftState: number;
  72953. protected _getTypeName(): string;
  72954. private _createKey;
  72955. /**
  72956. * Adds a new row of keys
  72957. * @param keys defines the list of keys to add
  72958. * @param propertySets defines the associated property sets
  72959. */
  72960. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72961. /**
  72962. * Set the shift key to a specific state
  72963. * @param shiftState defines the new shift state
  72964. */
  72965. applyShiftState(shiftState: number): void;
  72966. private _currentlyConnectedInputText;
  72967. private _connectedInputTexts;
  72968. private _onKeyPressObserver;
  72969. /** Gets the input text control currently attached to the keyboard */
  72970. get connectedInputText(): BABYLON.Nullable<InputText>;
  72971. /**
  72972. * Connects the keyboard with an input text control
  72973. *
  72974. * @param input defines the target control
  72975. */
  72976. connect(input: InputText): void;
  72977. /**
  72978. * Disconnects the keyboard from connected InputText controls
  72979. *
  72980. * @param input optionally defines a target control, otherwise all are disconnected
  72981. */
  72982. disconnect(input?: InputText): void;
  72983. private _removeConnectedInputObservables;
  72984. /**
  72985. * Release all resources
  72986. */
  72987. dispose(): void;
  72988. /**
  72989. * Creates a new keyboard using a default layout
  72990. *
  72991. * @param name defines control name
  72992. * @returns a new VirtualKeyboard
  72993. */
  72994. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72995. }
  72996. }
  72997. declare module BABYLON.GUI {
  72998. /**
  72999. * Class used to create input text control
  73000. */
  73001. export class InputText extends Control implements IFocusableControl {
  73002. name?: string | undefined;
  73003. private _text;
  73004. private _placeholderText;
  73005. private _background;
  73006. private _focusedBackground;
  73007. private _focusedColor;
  73008. private _placeholderColor;
  73009. private _thickness;
  73010. private _margin;
  73011. private _autoStretchWidth;
  73012. private _maxWidth;
  73013. private _isFocused;
  73014. private _blinkTimeout;
  73015. private _blinkIsEven;
  73016. private _cursorOffset;
  73017. private _scrollLeft;
  73018. private _textWidth;
  73019. private _clickedCoordinate;
  73020. private _deadKey;
  73021. private _addKey;
  73022. private _currentKey;
  73023. private _isTextHighlightOn;
  73024. private _textHighlightColor;
  73025. private _highligherOpacity;
  73026. private _highlightedText;
  73027. private _startHighlightIndex;
  73028. private _endHighlightIndex;
  73029. private _cursorIndex;
  73030. private _onFocusSelectAll;
  73031. private _isPointerDown;
  73032. private _onClipboardObserver;
  73033. private _onPointerDblTapObserver;
  73034. /** @hidden */
  73035. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73036. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73037. promptMessage: string;
  73038. /** Force disable prompt on mobile device */
  73039. disableMobilePrompt: boolean;
  73040. /** BABYLON.Observable raised when the text changes */
  73041. onTextChangedObservable: BABYLON.Observable<InputText>;
  73042. /** BABYLON.Observable raised just before an entered character is to be added */
  73043. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73044. /** BABYLON.Observable raised when the control gets the focus */
  73045. onFocusObservable: BABYLON.Observable<InputText>;
  73046. /** BABYLON.Observable raised when the control loses the focus */
  73047. onBlurObservable: BABYLON.Observable<InputText>;
  73048. /**Observable raised when the text is highlighted */
  73049. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73050. /**Observable raised when copy event is triggered */
  73051. onTextCopyObservable: BABYLON.Observable<InputText>;
  73052. /** BABYLON.Observable raised when cut event is triggered */
  73053. onTextCutObservable: BABYLON.Observable<InputText>;
  73054. /** BABYLON.Observable raised when paste event is triggered */
  73055. onTextPasteObservable: BABYLON.Observable<InputText>;
  73056. /** BABYLON.Observable raised when a key event was processed */
  73057. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73058. /** Gets or sets the maximum width allowed by the control */
  73059. get maxWidth(): string | number;
  73060. /** Gets the maximum width allowed by the control in pixels */
  73061. get maxWidthInPixels(): number;
  73062. set maxWidth(value: string | number);
  73063. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73064. get highligherOpacity(): number;
  73065. set highligherOpacity(value: number);
  73066. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73067. get onFocusSelectAll(): boolean;
  73068. set onFocusSelectAll(value: boolean);
  73069. /** Gets or sets the text hightlight color */
  73070. get textHighlightColor(): string;
  73071. set textHighlightColor(value: string);
  73072. /** Gets or sets control margin */
  73073. get margin(): string;
  73074. /** Gets control margin in pixels */
  73075. get marginInPixels(): number;
  73076. set margin(value: string);
  73077. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73078. get autoStretchWidth(): boolean;
  73079. set autoStretchWidth(value: boolean);
  73080. /** Gets or sets border thickness */
  73081. get thickness(): number;
  73082. set thickness(value: number);
  73083. /** Gets or sets the background color when focused */
  73084. get focusedBackground(): string;
  73085. set focusedBackground(value: string);
  73086. /** Gets or sets the background color when focused */
  73087. get focusedColor(): string;
  73088. set focusedColor(value: string);
  73089. /** Gets or sets the background color */
  73090. get background(): string;
  73091. set background(value: string);
  73092. /** Gets or sets the placeholder color */
  73093. get placeholderColor(): string;
  73094. set placeholderColor(value: string);
  73095. /** Gets or sets the text displayed when the control is empty */
  73096. get placeholderText(): string;
  73097. set placeholderText(value: string);
  73098. /** Gets or sets the dead key flag */
  73099. get deadKey(): boolean;
  73100. set deadKey(flag: boolean);
  73101. /** Gets or sets the highlight text */
  73102. get highlightedText(): string;
  73103. set highlightedText(text: string);
  73104. /** Gets or sets if the current key should be added */
  73105. get addKey(): boolean;
  73106. set addKey(flag: boolean);
  73107. /** Gets or sets the value of the current key being entered */
  73108. get currentKey(): string;
  73109. set currentKey(key: string);
  73110. /** Gets or sets the text displayed in the control */
  73111. get text(): string;
  73112. set text(value: string);
  73113. /** Gets or sets control width */
  73114. get width(): string | number;
  73115. set width(value: string | number);
  73116. /**
  73117. * Creates a new InputText
  73118. * @param name defines the control name
  73119. * @param text defines the text of the control
  73120. */
  73121. constructor(name?: string | undefined, text?: string);
  73122. /** @hidden */
  73123. onBlur(): void;
  73124. /** @hidden */
  73125. onFocus(): void;
  73126. protected _getTypeName(): string;
  73127. /**
  73128. * Function called to get the list of controls that should not steal the focus from this control
  73129. * @returns an array of controls
  73130. */
  73131. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73132. /** @hidden */
  73133. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73134. /** @hidden */
  73135. private _updateValueFromCursorIndex;
  73136. /** @hidden */
  73137. private _processDblClick;
  73138. /** @hidden */
  73139. private _selectAllText;
  73140. /**
  73141. * Handles the keyboard event
  73142. * @param evt Defines the KeyboardEvent
  73143. */
  73144. processKeyboard(evt: KeyboardEvent): void;
  73145. /** @hidden */
  73146. private _onCopyText;
  73147. /** @hidden */
  73148. private _onCutText;
  73149. /** @hidden */
  73150. private _onPasteText;
  73151. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73152. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73153. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73154. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73155. protected _beforeRenderText(text: string): string;
  73156. dispose(): void;
  73157. }
  73158. }
  73159. declare module BABYLON.GUI {
  73160. /**
  73161. * Class used to create a 2D grid container
  73162. */
  73163. export class Grid extends Container {
  73164. name?: string | undefined;
  73165. private _rowDefinitions;
  73166. private _columnDefinitions;
  73167. private _cells;
  73168. private _childControls;
  73169. /**
  73170. * Gets the number of columns
  73171. */
  73172. get columnCount(): number;
  73173. /**
  73174. * Gets the number of rows
  73175. */
  73176. get rowCount(): number;
  73177. /** Gets the list of children */
  73178. get children(): Control[];
  73179. /** Gets the list of cells (e.g. the containers) */
  73180. get cells(): {
  73181. [key: string]: Container;
  73182. };
  73183. /**
  73184. * Gets the definition of a specific row
  73185. * @param index defines the index of the row
  73186. * @returns the row definition
  73187. */
  73188. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73189. /**
  73190. * Gets the definition of a specific column
  73191. * @param index defines the index of the column
  73192. * @returns the column definition
  73193. */
  73194. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73195. /**
  73196. * Adds a new row to the grid
  73197. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73198. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73199. * @returns the current grid
  73200. */
  73201. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73202. /**
  73203. * Adds a new column to the grid
  73204. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73205. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73206. * @returns the current grid
  73207. */
  73208. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73209. /**
  73210. * Update a row definition
  73211. * @param index defines the index of the row to update
  73212. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73213. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73214. * @returns the current grid
  73215. */
  73216. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73217. /**
  73218. * Update a column definition
  73219. * @param index defines the index of the column to update
  73220. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73221. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73222. * @returns the current grid
  73223. */
  73224. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73225. /**
  73226. * Gets the list of children stored in a specific cell
  73227. * @param row defines the row to check
  73228. * @param column defines the column to check
  73229. * @returns the list of controls
  73230. */
  73231. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73232. /**
  73233. * Gets a string representing the child cell info (row x column)
  73234. * @param child defines the control to get info from
  73235. * @returns a string containing the child cell info (row x column)
  73236. */
  73237. getChildCellInfo(child: Control): string;
  73238. private _removeCell;
  73239. private _offsetCell;
  73240. /**
  73241. * Remove a column definition at specified index
  73242. * @param index defines the index of the column to remove
  73243. * @returns the current grid
  73244. */
  73245. removeColumnDefinition(index: number): Grid;
  73246. /**
  73247. * Remove a row definition at specified index
  73248. * @param index defines the index of the row to remove
  73249. * @returns the current grid
  73250. */
  73251. removeRowDefinition(index: number): Grid;
  73252. /**
  73253. * Adds a new control to the current grid
  73254. * @param control defines the control to add
  73255. * @param row defines the row where to add the control (0 by default)
  73256. * @param column defines the column where to add the control (0 by default)
  73257. * @returns the current grid
  73258. */
  73259. addControl(control: Control, row?: number, column?: number): Grid;
  73260. /**
  73261. * Removes a control from the current container
  73262. * @param control defines the control to remove
  73263. * @returns the current container
  73264. */
  73265. removeControl(control: Control): Container;
  73266. /**
  73267. * Creates a new Grid
  73268. * @param name defines control name
  73269. */
  73270. constructor(name?: string | undefined);
  73271. protected _getTypeName(): string;
  73272. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73273. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73274. _flagDescendantsAsMatrixDirty(): void;
  73275. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73276. /** Releases associated resources */
  73277. dispose(): void;
  73278. }
  73279. }
  73280. declare module BABYLON.GUI {
  73281. /** Class used to create color pickers */
  73282. export class ColorPicker extends Control {
  73283. name?: string | undefined;
  73284. private static _Epsilon;
  73285. private _colorWheelCanvas;
  73286. private _value;
  73287. private _tmpColor;
  73288. private _pointerStartedOnSquare;
  73289. private _pointerStartedOnWheel;
  73290. private _squareLeft;
  73291. private _squareTop;
  73292. private _squareSize;
  73293. private _h;
  73294. private _s;
  73295. private _v;
  73296. private _lastPointerDownID;
  73297. /**
  73298. * BABYLON.Observable raised when the value changes
  73299. */
  73300. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73301. /** Gets or sets the color of the color picker */
  73302. get value(): BABYLON.Color3;
  73303. set value(value: BABYLON.Color3);
  73304. /**
  73305. * Gets or sets control width
  73306. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73307. */
  73308. get width(): string | number;
  73309. set width(value: string | number);
  73310. /**
  73311. * Gets or sets control height
  73312. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73313. */
  73314. get height(): string | number;
  73315. /** Gets or sets control height */
  73316. set height(value: string | number);
  73317. /** Gets or sets control size */
  73318. get size(): string | number;
  73319. set size(value: string | number);
  73320. /**
  73321. * Creates a new ColorPicker
  73322. * @param name defines the control name
  73323. */
  73324. constructor(name?: string | undefined);
  73325. protected _getTypeName(): string;
  73326. /** @hidden */
  73327. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73328. private _updateSquareProps;
  73329. private _drawGradientSquare;
  73330. private _drawCircle;
  73331. private _createColorWheelCanvas;
  73332. /** @hidden */
  73333. _draw(context: CanvasRenderingContext2D): void;
  73334. private _pointerIsDown;
  73335. private _updateValueFromPointer;
  73336. private _isPointOnSquare;
  73337. private _isPointOnWheel;
  73338. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73339. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73340. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73341. /**
  73342. * This function expands the color picker by creating a color picker dialog with manual
  73343. * color value input and the ability to save colors into an array to be used later in
  73344. * subsequent launches of the dialogue.
  73345. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73346. * @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.
  73347. * @returns picked color as a hex string and the saved colors array as hex strings.
  73348. */
  73349. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73350. pickerWidth?: string;
  73351. pickerHeight?: string;
  73352. headerHeight?: string;
  73353. lastColor?: string;
  73354. swatchLimit?: number;
  73355. numSwatchesPerLine?: number;
  73356. savedColors?: Array<string>;
  73357. }): Promise<{
  73358. savedColors?: string[];
  73359. pickedColor: string;
  73360. }>;
  73361. }
  73362. }
  73363. declare module BABYLON.GUI {
  73364. /** Class used to create 2D ellipse containers */
  73365. export class Ellipse extends Container {
  73366. name?: string | undefined;
  73367. private _thickness;
  73368. /** Gets or sets border thickness */
  73369. get thickness(): number;
  73370. set thickness(value: number);
  73371. /**
  73372. * Creates a new Ellipse
  73373. * @param name defines the control name
  73374. */
  73375. constructor(name?: string | undefined);
  73376. protected _getTypeName(): string;
  73377. protected _localDraw(context: CanvasRenderingContext2D): void;
  73378. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73379. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73380. }
  73381. }
  73382. declare module BABYLON.GUI {
  73383. /**
  73384. * Class used to create a password control
  73385. */
  73386. export class InputPassword extends InputText {
  73387. protected _beforeRenderText(text: string): string;
  73388. }
  73389. }
  73390. declare module BABYLON.GUI {
  73391. /** Class used to render 2D lines */
  73392. export class Line extends Control {
  73393. name?: string | undefined;
  73394. private _lineWidth;
  73395. private _x1;
  73396. private _y1;
  73397. private _x2;
  73398. private _y2;
  73399. private _dash;
  73400. private _connectedControl;
  73401. private _connectedControlDirtyObserver;
  73402. /** Gets or sets the dash pattern */
  73403. get dash(): Array<number>;
  73404. set dash(value: Array<number>);
  73405. /** Gets or sets the control connected with the line end */
  73406. get connectedControl(): Control;
  73407. set connectedControl(value: Control);
  73408. /** Gets or sets start coordinates on X axis */
  73409. get x1(): string | number;
  73410. set x1(value: string | number);
  73411. /** Gets or sets start coordinates on Y axis */
  73412. get y1(): string | number;
  73413. set y1(value: string | number);
  73414. /** Gets or sets end coordinates on X axis */
  73415. get x2(): string | number;
  73416. set x2(value: string | number);
  73417. /** Gets or sets end coordinates on Y axis */
  73418. get y2(): string | number;
  73419. set y2(value: string | number);
  73420. /** Gets or sets line width */
  73421. get lineWidth(): number;
  73422. set lineWidth(value: number);
  73423. /** Gets or sets horizontal alignment */
  73424. set horizontalAlignment(value: number);
  73425. /** Gets or sets vertical alignment */
  73426. set verticalAlignment(value: number);
  73427. private get _effectiveX2();
  73428. private get _effectiveY2();
  73429. /**
  73430. * Creates a new Line
  73431. * @param name defines the control name
  73432. */
  73433. constructor(name?: string | undefined);
  73434. protected _getTypeName(): string;
  73435. _draw(context: CanvasRenderingContext2D): void;
  73436. _measure(): void;
  73437. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73438. /**
  73439. * Move one end of the line given 3D cartesian coordinates.
  73440. * @param position Targeted world position
  73441. * @param scene BABYLON.Scene
  73442. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73443. */
  73444. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73445. /**
  73446. * Move one end of the line to a position in screen absolute space.
  73447. * @param projectedPosition Position in screen absolute space (X, Y)
  73448. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73449. */
  73450. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73451. }
  73452. }
  73453. declare module BABYLON.GUI {
  73454. /**
  73455. * Class used to store a point for a MultiLine object.
  73456. * The point can be pure 2D coordinates, a mesh or a control
  73457. */
  73458. export class MultiLinePoint {
  73459. private _multiLine;
  73460. private _x;
  73461. private _y;
  73462. private _control;
  73463. private _mesh;
  73464. private _controlObserver;
  73465. private _meshObserver;
  73466. /** @hidden */
  73467. _point: BABYLON.Vector2;
  73468. /**
  73469. * Creates a new MultiLinePoint
  73470. * @param multiLine defines the source MultiLine object
  73471. */
  73472. constructor(multiLine: MultiLine);
  73473. /** Gets or sets x coordinate */
  73474. get x(): string | number;
  73475. set x(value: string | number);
  73476. /** Gets or sets y coordinate */
  73477. get y(): string | number;
  73478. set y(value: string | number);
  73479. /** Gets or sets the control associated with this point */
  73480. get control(): BABYLON.Nullable<Control>;
  73481. set control(value: BABYLON.Nullable<Control>);
  73482. /** Gets or sets the mesh associated with this point */
  73483. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73484. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73485. /** Resets links */
  73486. resetLinks(): void;
  73487. /**
  73488. * Gets a translation vector
  73489. * @returns the translation vector
  73490. */
  73491. translate(): BABYLON.Vector2;
  73492. private _translatePoint;
  73493. /** Release associated resources */
  73494. dispose(): void;
  73495. }
  73496. }
  73497. declare module BABYLON.GUI {
  73498. /**
  73499. * Class used to create multi line control
  73500. */
  73501. export class MultiLine extends Control {
  73502. name?: string | undefined;
  73503. private _lineWidth;
  73504. private _dash;
  73505. private _points;
  73506. private _minX;
  73507. private _minY;
  73508. private _maxX;
  73509. private _maxY;
  73510. /**
  73511. * Creates a new MultiLine
  73512. * @param name defines the control name
  73513. */
  73514. constructor(name?: string | undefined);
  73515. /** Gets or sets dash pattern */
  73516. get dash(): Array<number>;
  73517. set dash(value: Array<number>);
  73518. /**
  73519. * Gets point stored at specified index
  73520. * @param index defines the index to look for
  73521. * @returns the requested point if found
  73522. */
  73523. getAt(index: number): MultiLinePoint;
  73524. /** Function called when a point is updated */
  73525. onPointUpdate: () => void;
  73526. /**
  73527. * Adds new points to the point collection
  73528. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73529. * @returns the list of created MultiLinePoint
  73530. */
  73531. add(...items: (AbstractMesh | Control | {
  73532. x: string | number;
  73533. y: string | number;
  73534. })[]): MultiLinePoint[];
  73535. /**
  73536. * Adds a new point to the point collection
  73537. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73538. * @returns the created MultiLinePoint
  73539. */
  73540. push(item?: (AbstractMesh | Control | {
  73541. x: string | number;
  73542. y: string | number;
  73543. })): MultiLinePoint;
  73544. /**
  73545. * Remove a specific value or point from the active point collection
  73546. * @param value defines the value or point to remove
  73547. */
  73548. remove(value: number | MultiLinePoint): void;
  73549. /**
  73550. * Resets this object to initial state (no point)
  73551. */
  73552. reset(): void;
  73553. /**
  73554. * Resets all links
  73555. */
  73556. resetLinks(): void;
  73557. /** Gets or sets line width */
  73558. get lineWidth(): number;
  73559. set lineWidth(value: number);
  73560. set horizontalAlignment(value: number);
  73561. set verticalAlignment(value: number);
  73562. protected _getTypeName(): string;
  73563. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73564. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73565. _measure(): void;
  73566. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73567. dispose(): void;
  73568. }
  73569. }
  73570. declare module BABYLON.GUI {
  73571. /**
  73572. * Class used to create radio button controls
  73573. */
  73574. export class RadioButton extends Control {
  73575. name?: string | undefined;
  73576. private _isChecked;
  73577. private _background;
  73578. private _checkSizeRatio;
  73579. private _thickness;
  73580. /** Gets or sets border thickness */
  73581. get thickness(): number;
  73582. set thickness(value: number);
  73583. /** Gets or sets group name */
  73584. group: string;
  73585. /** BABYLON.Observable raised when isChecked is changed */
  73586. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73587. /** Gets or sets a value indicating the ratio between overall size and check size */
  73588. get checkSizeRatio(): number;
  73589. set checkSizeRatio(value: number);
  73590. /** Gets or sets background color */
  73591. get background(): string;
  73592. set background(value: string);
  73593. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73594. get isChecked(): boolean;
  73595. set isChecked(value: boolean);
  73596. /**
  73597. * Creates a new RadioButton
  73598. * @param name defines the control name
  73599. */
  73600. constructor(name?: string | undefined);
  73601. protected _getTypeName(): string;
  73602. _draw(context: CanvasRenderingContext2D): void;
  73603. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73604. /**
  73605. * Utility function to easily create a radio button with a header
  73606. * @param title defines the label to use for the header
  73607. * @param group defines the group to use for the radio button
  73608. * @param isChecked defines the initial state of the radio button
  73609. * @param onValueChanged defines the callback to call when value changes
  73610. * @returns a StackPanel containing the radio button and a textBlock
  73611. */
  73612. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73613. }
  73614. }
  73615. declare module BABYLON.GUI {
  73616. /**
  73617. * Class used to create slider controls
  73618. */
  73619. export class BaseSlider extends Control {
  73620. name?: string | undefined;
  73621. protected _thumbWidth: ValueAndUnit;
  73622. private _minimum;
  73623. private _maximum;
  73624. private _value;
  73625. private _isVertical;
  73626. protected _barOffset: ValueAndUnit;
  73627. private _isThumbClamped;
  73628. protected _displayThumb: boolean;
  73629. private _step;
  73630. private _lastPointerDownID;
  73631. protected _effectiveBarOffset: number;
  73632. protected _renderLeft: number;
  73633. protected _renderTop: number;
  73634. protected _renderWidth: number;
  73635. protected _renderHeight: number;
  73636. protected _backgroundBoxLength: number;
  73637. protected _backgroundBoxThickness: number;
  73638. protected _effectiveThumbThickness: number;
  73639. /** BABYLON.Observable raised when the sldier value changes */
  73640. onValueChangedObservable: BABYLON.Observable<number>;
  73641. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73642. get displayThumb(): boolean;
  73643. set displayThumb(value: boolean);
  73644. /** Gets or sets a step to apply to values (0 by default) */
  73645. get step(): number;
  73646. set step(value: number);
  73647. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73648. get barOffset(): string | number;
  73649. /** Gets main bar offset in pixels*/
  73650. get barOffsetInPixels(): number;
  73651. set barOffset(value: string | number);
  73652. /** Gets or sets thumb width */
  73653. get thumbWidth(): string | number;
  73654. /** Gets thumb width in pixels */
  73655. get thumbWidthInPixels(): number;
  73656. set thumbWidth(value: string | number);
  73657. /** Gets or sets minimum value */
  73658. get minimum(): number;
  73659. set minimum(value: number);
  73660. /** Gets or sets maximum value */
  73661. get maximum(): number;
  73662. set maximum(value: number);
  73663. /** Gets or sets current value */
  73664. get value(): number;
  73665. set value(value: number);
  73666. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73667. get isVertical(): boolean;
  73668. set isVertical(value: boolean);
  73669. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73670. get isThumbClamped(): boolean;
  73671. set isThumbClamped(value: boolean);
  73672. /**
  73673. * Creates a new BaseSlider
  73674. * @param name defines the control name
  73675. */
  73676. constructor(name?: string | undefined);
  73677. protected _getTypeName(): string;
  73678. protected _getThumbPosition(): number;
  73679. protected _getThumbThickness(type: string): number;
  73680. protected _prepareRenderingData(type: string): void;
  73681. private _pointerIsDown;
  73682. /** @hidden */
  73683. protected _updateValueFromPointer(x: number, y: number): void;
  73684. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73685. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73686. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73687. }
  73688. }
  73689. declare module BABYLON.GUI {
  73690. /**
  73691. * Class used to create slider controls
  73692. */
  73693. export class Slider extends BaseSlider {
  73694. name?: string | undefined;
  73695. private _background;
  73696. private _borderColor;
  73697. private _isThumbCircle;
  73698. protected _displayValueBar: boolean;
  73699. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73700. get displayValueBar(): boolean;
  73701. set displayValueBar(value: boolean);
  73702. /** Gets or sets border color */
  73703. get borderColor(): string;
  73704. set borderColor(value: string);
  73705. /** Gets or sets background color */
  73706. get background(): string;
  73707. set background(value: string);
  73708. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73709. get isThumbCircle(): boolean;
  73710. set isThumbCircle(value: boolean);
  73711. /**
  73712. * Creates a new Slider
  73713. * @param name defines the control name
  73714. */
  73715. constructor(name?: string | undefined);
  73716. protected _getTypeName(): string;
  73717. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73718. }
  73719. }
  73720. declare module BABYLON.GUI {
  73721. /** Class used to create a RadioGroup
  73722. * which contains groups of radio buttons
  73723. */
  73724. export class SelectorGroup {
  73725. /** name of SelectorGroup */
  73726. name: string;
  73727. private _groupPanel;
  73728. private _selectors;
  73729. private _groupHeader;
  73730. /**
  73731. * Creates a new SelectorGroup
  73732. * @param name of group, used as a group heading
  73733. */
  73734. constructor(
  73735. /** name of SelectorGroup */
  73736. name: string);
  73737. /** Gets the groupPanel of the SelectorGroup */
  73738. get groupPanel(): StackPanel;
  73739. /** Gets the selectors array */
  73740. get selectors(): StackPanel[];
  73741. /** Gets and sets the group header */
  73742. get header(): string;
  73743. set header(label: string);
  73744. /** @hidden */
  73745. private _addGroupHeader;
  73746. /** @hidden*/
  73747. _getSelector(selectorNb: number): StackPanel | undefined;
  73748. /** Removes the selector at the given position
  73749. * @param selectorNb the position of the selector within the group
  73750. */
  73751. removeSelector(selectorNb: number): void;
  73752. }
  73753. /** Class used to create a CheckboxGroup
  73754. * which contains groups of checkbox buttons
  73755. */
  73756. export class CheckboxGroup extends SelectorGroup {
  73757. /** Adds a checkbox as a control
  73758. * @param text is the label for the selector
  73759. * @param func is the function called when the Selector is checked
  73760. * @param checked is true when Selector is checked
  73761. */
  73762. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73763. /** @hidden */
  73764. _setSelectorLabel(selectorNb: number, label: string): void;
  73765. /** @hidden */
  73766. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73767. /** @hidden */
  73768. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73769. /** @hidden */
  73770. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73771. }
  73772. /** Class used to create a RadioGroup
  73773. * which contains groups of radio buttons
  73774. */
  73775. export class RadioGroup extends SelectorGroup {
  73776. private _selectNb;
  73777. /** Adds a radio button as a control
  73778. * @param label is the label for the selector
  73779. * @param func is the function called when the Selector is checked
  73780. * @param checked is true when Selector is checked
  73781. */
  73782. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73783. /** @hidden */
  73784. _setSelectorLabel(selectorNb: number, label: string): void;
  73785. /** @hidden */
  73786. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73787. /** @hidden */
  73788. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73789. /** @hidden */
  73790. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73791. }
  73792. /** Class used to create a SliderGroup
  73793. * which contains groups of slider buttons
  73794. */
  73795. export class SliderGroup extends SelectorGroup {
  73796. /**
  73797. * Adds a slider to the SelectorGroup
  73798. * @param label is the label for the SliderBar
  73799. * @param func is the function called when the Slider moves
  73800. * @param unit is a string describing the units used, eg degrees or metres
  73801. * @param min is the minimum value for the Slider
  73802. * @param max is the maximum value for the Slider
  73803. * @param value is the start value for the Slider between min and max
  73804. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73805. */
  73806. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73807. /** @hidden */
  73808. _setSelectorLabel(selectorNb: number, label: string): void;
  73809. /** @hidden */
  73810. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73811. /** @hidden */
  73812. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73813. /** @hidden */
  73814. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73815. }
  73816. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73817. * @see http://doc.babylonjs.com/how_to/selector
  73818. */
  73819. export class SelectionPanel extends Rectangle {
  73820. /** name of SelectionPanel */
  73821. name: string;
  73822. /** an array of SelectionGroups */
  73823. groups: SelectorGroup[];
  73824. private _panel;
  73825. private _buttonColor;
  73826. private _buttonBackground;
  73827. private _headerColor;
  73828. private _barColor;
  73829. private _barHeight;
  73830. private _spacerHeight;
  73831. private _labelColor;
  73832. private _groups;
  73833. private _bars;
  73834. /**
  73835. * Creates a new SelectionPanel
  73836. * @param name of SelectionPanel
  73837. * @param groups is an array of SelectionGroups
  73838. */
  73839. constructor(
  73840. /** name of SelectionPanel */
  73841. name: string,
  73842. /** an array of SelectionGroups */
  73843. groups?: SelectorGroup[]);
  73844. protected _getTypeName(): string;
  73845. /** Gets or sets the headerColor */
  73846. get headerColor(): string;
  73847. set headerColor(color: string);
  73848. private _setHeaderColor;
  73849. /** Gets or sets the button color */
  73850. get buttonColor(): string;
  73851. set buttonColor(color: string);
  73852. private _setbuttonColor;
  73853. /** Gets or sets the label color */
  73854. get labelColor(): string;
  73855. set labelColor(color: string);
  73856. private _setLabelColor;
  73857. /** Gets or sets the button background */
  73858. get buttonBackground(): string;
  73859. set buttonBackground(color: string);
  73860. private _setButtonBackground;
  73861. /** Gets or sets the color of separator bar */
  73862. get barColor(): string;
  73863. set barColor(color: string);
  73864. private _setBarColor;
  73865. /** Gets or sets the height of separator bar */
  73866. get barHeight(): string;
  73867. set barHeight(value: string);
  73868. private _setBarHeight;
  73869. /** Gets or sets the height of spacers*/
  73870. get spacerHeight(): string;
  73871. set spacerHeight(value: string);
  73872. private _setSpacerHeight;
  73873. /** Adds a bar between groups */
  73874. private _addSpacer;
  73875. /** Add a group to the selection panel
  73876. * @param group is the selector group to add
  73877. */
  73878. addGroup(group: SelectorGroup): void;
  73879. /** Remove the group from the given position
  73880. * @param groupNb is the position of the group in the list
  73881. */
  73882. removeGroup(groupNb: number): void;
  73883. /** Change a group header label
  73884. * @param label is the new group header label
  73885. * @param groupNb is the number of the group to relabel
  73886. * */
  73887. setHeaderName(label: string, groupNb: number): void;
  73888. /** Change selector label to the one given
  73889. * @param label is the new selector label
  73890. * @param groupNb is the number of the groupcontaining the selector
  73891. * @param selectorNb is the number of the selector within a group to relabel
  73892. * */
  73893. relabel(label: string, groupNb: number, selectorNb: number): void;
  73894. /** For a given group position remove the selector at the given position
  73895. * @param groupNb is the number of the group to remove the selector from
  73896. * @param selectorNb is the number of the selector within the group
  73897. */
  73898. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73899. /** For a given group position of correct type add a checkbox button
  73900. * @param groupNb is the number of the group to remove the selector from
  73901. * @param label is the label for the selector
  73902. * @param func is the function called when the Selector is checked
  73903. * @param checked is true when Selector is checked
  73904. */
  73905. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73906. /** For a given group position of correct type add a radio button
  73907. * @param groupNb is the number of the group to remove the selector from
  73908. * @param label is the label for the selector
  73909. * @param func is the function called when the Selector is checked
  73910. * @param checked is true when Selector is checked
  73911. */
  73912. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73913. /**
  73914. * For a given slider group add a slider
  73915. * @param groupNb is the number of the group to add the slider to
  73916. * @param label is the label for the Slider
  73917. * @param func is the function called when the Slider moves
  73918. * @param unit is a string describing the units used, eg degrees or metres
  73919. * @param min is the minimum value for the Slider
  73920. * @param max is the maximum value for the Slider
  73921. * @param value is the start value for the Slider between min and max
  73922. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73923. */
  73924. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73925. }
  73926. }
  73927. declare module BABYLON.GUI {
  73928. /**
  73929. * Class used to hold a the container for ScrollViewer
  73930. * @hidden
  73931. */
  73932. export class _ScrollViewerWindow extends Container {
  73933. parentClientWidth: number;
  73934. parentClientHeight: number;
  73935. private _freezeControls;
  73936. private _parentMeasure;
  73937. private _oldLeft;
  73938. private _oldTop;
  73939. get freezeControls(): boolean;
  73940. set freezeControls(value: boolean);
  73941. private _bucketWidth;
  73942. private _bucketHeight;
  73943. private _buckets;
  73944. private _bucketLen;
  73945. get bucketWidth(): number;
  73946. get bucketHeight(): number;
  73947. setBucketSizes(width: number, height: number): void;
  73948. private _useBuckets;
  73949. private _makeBuckets;
  73950. private _dispatchInBuckets;
  73951. private _updateMeasures;
  73952. private _updateChildrenMeasures;
  73953. private _restoreMeasures;
  73954. /**
  73955. * Creates a new ScrollViewerWindow
  73956. * @param name of ScrollViewerWindow
  73957. */
  73958. constructor(name?: string);
  73959. protected _getTypeName(): string;
  73960. /** @hidden */
  73961. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73962. /** @hidden */
  73963. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73964. private _scrollChildren;
  73965. private _scrollChildrenWithBuckets;
  73966. /** @hidden */
  73967. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73968. protected _postMeasure(): void;
  73969. }
  73970. }
  73971. declare module BABYLON.GUI {
  73972. /**
  73973. * Class used to create slider controls
  73974. */
  73975. export class ScrollBar extends BaseSlider {
  73976. name?: string | undefined;
  73977. private _background;
  73978. private _borderColor;
  73979. private _tempMeasure;
  73980. /** Gets or sets border color */
  73981. get borderColor(): string;
  73982. set borderColor(value: string);
  73983. /** Gets or sets background color */
  73984. get background(): string;
  73985. set background(value: string);
  73986. /**
  73987. * Creates a new Slider
  73988. * @param name defines the control name
  73989. */
  73990. constructor(name?: string | undefined);
  73991. protected _getTypeName(): string;
  73992. protected _getThumbThickness(): number;
  73993. _draw(context: CanvasRenderingContext2D): void;
  73994. private _first;
  73995. private _originX;
  73996. private _originY;
  73997. /** @hidden */
  73998. protected _updateValueFromPointer(x: number, y: number): void;
  73999. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74000. }
  74001. }
  74002. declare module BABYLON.GUI {
  74003. /**
  74004. * Class used to create slider controls
  74005. */
  74006. export class ImageScrollBar extends BaseSlider {
  74007. name?: string | undefined;
  74008. private _backgroundBaseImage;
  74009. private _backgroundImage;
  74010. private _thumbImage;
  74011. private _thumbBaseImage;
  74012. private _thumbLength;
  74013. private _thumbHeight;
  74014. private _barImageHeight;
  74015. private _tempMeasure;
  74016. /** Number of 90° rotation to apply on the images when in vertical mode */
  74017. num90RotationInVerticalMode: number;
  74018. /**
  74019. * Gets or sets the image used to render the background for horizontal bar
  74020. */
  74021. get backgroundImage(): Image;
  74022. set backgroundImage(value: Image);
  74023. /**
  74024. * Gets or sets the image used to render the thumb
  74025. */
  74026. get thumbImage(): Image;
  74027. set thumbImage(value: Image);
  74028. /**
  74029. * Gets or sets the length of the thumb
  74030. */
  74031. get thumbLength(): number;
  74032. set thumbLength(value: number);
  74033. /**
  74034. * Gets or sets the height of the thumb
  74035. */
  74036. get thumbHeight(): number;
  74037. set thumbHeight(value: number);
  74038. /**
  74039. * Gets or sets the height of the bar image
  74040. */
  74041. get barImageHeight(): number;
  74042. set barImageHeight(value: number);
  74043. /**
  74044. * Creates a new ImageScrollBar
  74045. * @param name defines the control name
  74046. */
  74047. constructor(name?: string | undefined);
  74048. protected _getTypeName(): string;
  74049. protected _getThumbThickness(): number;
  74050. _draw(context: CanvasRenderingContext2D): void;
  74051. private _first;
  74052. private _originX;
  74053. private _originY;
  74054. /** @hidden */
  74055. protected _updateValueFromPointer(x: number, y: number): void;
  74056. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74057. }
  74058. }
  74059. declare module BABYLON.GUI {
  74060. /**
  74061. * Class used to hold a viewer window and sliders in a grid
  74062. */
  74063. export class ScrollViewer extends Rectangle {
  74064. private _grid;
  74065. private _horizontalBarSpace;
  74066. private _verticalBarSpace;
  74067. private _dragSpace;
  74068. private _horizontalBar;
  74069. private _verticalBar;
  74070. private _barColor;
  74071. private _barBackground;
  74072. private _barImage;
  74073. private _horizontalBarImage;
  74074. private _verticalBarImage;
  74075. private _barBackgroundImage;
  74076. private _horizontalBarBackgroundImage;
  74077. private _verticalBarBackgroundImage;
  74078. private _barSize;
  74079. private _window;
  74080. private _pointerIsOver;
  74081. private _wheelPrecision;
  74082. private _onWheelObserver;
  74083. private _clientWidth;
  74084. private _clientHeight;
  74085. private _useImageBar;
  74086. private _thumbLength;
  74087. private _thumbHeight;
  74088. private _barImageHeight;
  74089. private _horizontalBarImageHeight;
  74090. private _verticalBarImageHeight;
  74091. private _oldWindowContentsWidth;
  74092. private _oldWindowContentsHeight;
  74093. /**
  74094. * Gets the horizontal scrollbar
  74095. */
  74096. get horizontalBar(): ScrollBar | ImageScrollBar;
  74097. /**
  74098. * Gets the vertical scrollbar
  74099. */
  74100. get verticalBar(): ScrollBar | ImageScrollBar;
  74101. /**
  74102. * Adds a new control to the current container
  74103. * @param control defines the control to add
  74104. * @returns the current container
  74105. */
  74106. addControl(control: BABYLON.Nullable<Control>): Container;
  74107. /**
  74108. * Removes a control from the current container
  74109. * @param control defines the control to remove
  74110. * @returns the current container
  74111. */
  74112. removeControl(control: Control): Container;
  74113. /** Gets the list of children */
  74114. get children(): Control[];
  74115. _flagDescendantsAsMatrixDirty(): void;
  74116. /**
  74117. * Freezes or unfreezes the controls in the window.
  74118. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74119. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74120. */
  74121. get freezeControls(): boolean;
  74122. set freezeControls(value: boolean);
  74123. /** Gets the bucket width */
  74124. get bucketWidth(): number;
  74125. /** Gets the bucket height */
  74126. get bucketHeight(): number;
  74127. /**
  74128. * Sets the bucket sizes.
  74129. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74130. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74131. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74132. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74133. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74134. * used), that's why it is not enabled by default.
  74135. * @param width width of the bucket
  74136. * @param height height of the bucket
  74137. */
  74138. setBucketSizes(width: number, height: number): void;
  74139. private _forceHorizontalBar;
  74140. private _forceVerticalBar;
  74141. /**
  74142. * Forces the horizontal scroll bar to be displayed
  74143. */
  74144. get forceHorizontalBar(): boolean;
  74145. set forceHorizontalBar(value: boolean);
  74146. /**
  74147. * Forces the vertical scroll bar to be displayed
  74148. */
  74149. get forceVerticalBar(): boolean;
  74150. set forceVerticalBar(value: boolean);
  74151. /**
  74152. * Creates a new ScrollViewer
  74153. * @param name of ScrollViewer
  74154. */
  74155. constructor(name?: string, isImageBased?: boolean);
  74156. /** Reset the scroll viewer window to initial size */
  74157. resetWindow(): void;
  74158. protected _getTypeName(): string;
  74159. private _buildClientSizes;
  74160. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74161. protected _postMeasure(): void;
  74162. /**
  74163. * Gets or sets the mouse wheel precision
  74164. * from 0 to 1 with a default value of 0.05
  74165. * */
  74166. get wheelPrecision(): number;
  74167. set wheelPrecision(value: number);
  74168. /** Gets or sets the scroll bar container background color */
  74169. get scrollBackground(): string;
  74170. set scrollBackground(color: string);
  74171. /** Gets or sets the bar color */
  74172. get barColor(): string;
  74173. set barColor(color: string);
  74174. /** Gets or sets the bar image */
  74175. get thumbImage(): Image;
  74176. set thumbImage(value: Image);
  74177. /** Gets or sets the horizontal bar image */
  74178. get horizontalThumbImage(): Image;
  74179. set horizontalThumbImage(value: Image);
  74180. /** Gets or sets the vertical bar image */
  74181. get verticalThumbImage(): Image;
  74182. set verticalThumbImage(value: Image);
  74183. /** Gets or sets the size of the bar */
  74184. get barSize(): number;
  74185. set barSize(value: number);
  74186. /** Gets or sets the length of the thumb */
  74187. get thumbLength(): number;
  74188. set thumbLength(value: number);
  74189. /** Gets or sets the height of the thumb */
  74190. get thumbHeight(): number;
  74191. set thumbHeight(value: number);
  74192. /** Gets or sets the height of the bar image */
  74193. get barImageHeight(): number;
  74194. set barImageHeight(value: number);
  74195. /** Gets or sets the height of the horizontal bar image */
  74196. get horizontalBarImageHeight(): number;
  74197. set horizontalBarImageHeight(value: number);
  74198. /** Gets or sets the height of the vertical bar image */
  74199. get verticalBarImageHeight(): number;
  74200. set verticalBarImageHeight(value: number);
  74201. /** Gets or sets the bar background */
  74202. get barBackground(): string;
  74203. set barBackground(color: string);
  74204. /** Gets or sets the bar background image */
  74205. get barImage(): Image;
  74206. set barImage(value: Image);
  74207. /** Gets or sets the horizontal bar background image */
  74208. get horizontalBarImage(): Image;
  74209. set horizontalBarImage(value: Image);
  74210. /** Gets or sets the vertical bar background image */
  74211. get verticalBarImage(): Image;
  74212. set verticalBarImage(value: Image);
  74213. private _setWindowPosition;
  74214. /** @hidden */
  74215. private _updateScroller;
  74216. _link(host: AdvancedDynamicTexture): void;
  74217. /** @hidden */
  74218. private _addBar;
  74219. /** @hidden */
  74220. private _attachWheel;
  74221. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74222. /** Releases associated resources */
  74223. dispose(): void;
  74224. }
  74225. }
  74226. declare module BABYLON.GUI {
  74227. /** Class used to render a grid */
  74228. export class DisplayGrid extends Control {
  74229. name?: string | undefined;
  74230. private _cellWidth;
  74231. private _cellHeight;
  74232. private _minorLineTickness;
  74233. private _minorLineColor;
  74234. private _majorLineTickness;
  74235. private _majorLineColor;
  74236. private _majorLineFrequency;
  74237. private _background;
  74238. private _displayMajorLines;
  74239. private _displayMinorLines;
  74240. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74241. get displayMinorLines(): boolean;
  74242. set displayMinorLines(value: boolean);
  74243. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74244. get displayMajorLines(): boolean;
  74245. set displayMajorLines(value: boolean);
  74246. /** Gets or sets background color (Black by default) */
  74247. get background(): string;
  74248. set background(value: string);
  74249. /** Gets or sets the width of each cell (20 by default) */
  74250. get cellWidth(): number;
  74251. set cellWidth(value: number);
  74252. /** Gets or sets the height of each cell (20 by default) */
  74253. get cellHeight(): number;
  74254. set cellHeight(value: number);
  74255. /** Gets or sets the tickness of minor lines (1 by default) */
  74256. get minorLineTickness(): number;
  74257. set minorLineTickness(value: number);
  74258. /** Gets or sets the color of minor lines (DarkGray by default) */
  74259. get minorLineColor(): string;
  74260. set minorLineColor(value: string);
  74261. /** Gets or sets the tickness of major lines (2 by default) */
  74262. get majorLineTickness(): number;
  74263. set majorLineTickness(value: number);
  74264. /** Gets or sets the color of major lines (White by default) */
  74265. get majorLineColor(): string;
  74266. set majorLineColor(value: string);
  74267. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74268. get majorLineFrequency(): number;
  74269. set majorLineFrequency(value: number);
  74270. /**
  74271. * Creates a new GridDisplayRectangle
  74272. * @param name defines the control name
  74273. */
  74274. constructor(name?: string | undefined);
  74275. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74276. protected _getTypeName(): string;
  74277. }
  74278. }
  74279. declare module BABYLON.GUI {
  74280. /**
  74281. * Class used to create slider controls based on images
  74282. */
  74283. export class ImageBasedSlider extends BaseSlider {
  74284. name?: string | undefined;
  74285. private _backgroundImage;
  74286. private _thumbImage;
  74287. private _valueBarImage;
  74288. private _tempMeasure;
  74289. get displayThumb(): boolean;
  74290. set displayThumb(value: boolean);
  74291. /**
  74292. * Gets or sets the image used to render the background
  74293. */
  74294. get backgroundImage(): Image;
  74295. set backgroundImage(value: Image);
  74296. /**
  74297. * Gets or sets the image used to render the value bar
  74298. */
  74299. get valueBarImage(): Image;
  74300. set valueBarImage(value: Image);
  74301. /**
  74302. * Gets or sets the image used to render the thumb
  74303. */
  74304. get thumbImage(): Image;
  74305. set thumbImage(value: Image);
  74306. /**
  74307. * Creates a new ImageBasedSlider
  74308. * @param name defines the control name
  74309. */
  74310. constructor(name?: string | undefined);
  74311. protected _getTypeName(): string;
  74312. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74313. }
  74314. }
  74315. declare module BABYLON.GUI {
  74316. /**
  74317. * Forcing an export so that this code will execute
  74318. * @hidden
  74319. */
  74320. const name = "Statics";
  74321. }
  74322. declare module BABYLON.GUI {
  74323. /**
  74324. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74325. */
  74326. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74327. /**
  74328. * Define the instrumented AdvancedDynamicTexture.
  74329. */
  74330. texture: AdvancedDynamicTexture;
  74331. private _captureRenderTime;
  74332. private _renderTime;
  74333. private _captureLayoutTime;
  74334. private _layoutTime;
  74335. private _onBeginRenderObserver;
  74336. private _onEndRenderObserver;
  74337. private _onBeginLayoutObserver;
  74338. private _onEndLayoutObserver;
  74339. /**
  74340. * Gets the perf counter used to capture render time
  74341. */
  74342. get renderTimeCounter(): BABYLON.PerfCounter;
  74343. /**
  74344. * Gets the perf counter used to capture layout time
  74345. */
  74346. get layoutTimeCounter(): BABYLON.PerfCounter;
  74347. /**
  74348. * Enable or disable the render time capture
  74349. */
  74350. get captureRenderTime(): boolean;
  74351. set captureRenderTime(value: boolean);
  74352. /**
  74353. * Enable or disable the layout time capture
  74354. */
  74355. get captureLayoutTime(): boolean;
  74356. set captureLayoutTime(value: boolean);
  74357. /**
  74358. * Instantiates a new advanced dynamic texture instrumentation.
  74359. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74360. * @param texture Defines the AdvancedDynamicTexture to instrument
  74361. */
  74362. constructor(
  74363. /**
  74364. * Define the instrumented AdvancedDynamicTexture.
  74365. */
  74366. texture: AdvancedDynamicTexture);
  74367. /**
  74368. * Dispose and release associated resources.
  74369. */
  74370. dispose(): void;
  74371. }
  74372. }
  74373. declare module BABYLON.GUI {
  74374. /**
  74375. * Class used to load GUI via XML.
  74376. */
  74377. export class XmlLoader {
  74378. private _nodes;
  74379. private _nodeTypes;
  74380. private _isLoaded;
  74381. private _objectAttributes;
  74382. private _parentClass;
  74383. /**
  74384. * Create a new xml loader
  74385. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74386. */
  74387. constructor(parentClass?: null);
  74388. private _getChainElement;
  74389. private _getClassAttribute;
  74390. private _createGuiElement;
  74391. private _parseGrid;
  74392. private _parseElement;
  74393. private _prepareSourceElement;
  74394. private _parseElementsFromSource;
  74395. private _parseXml;
  74396. /**
  74397. * Gets if the loading has finished.
  74398. * @returns whether the loading has finished or not
  74399. */
  74400. isLoaded(): boolean;
  74401. /**
  74402. * Gets a loaded node / control by id.
  74403. * @param id the Controls id set in the xml
  74404. * @returns element of type Control
  74405. */
  74406. getNodeById(id: string): any;
  74407. /**
  74408. * Gets all loaded nodes / controls
  74409. * @returns Array of controls
  74410. */
  74411. getNodes(): any;
  74412. /**
  74413. * Initiates the xml layout loading
  74414. * @param xmlFile defines the xml layout to load
  74415. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74416. * @param callback defines the callback called on layout load.
  74417. */
  74418. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74419. }
  74420. }
  74421. declare module BABYLON.GUI {
  74422. /**
  74423. * Class used to create containers for controls
  74424. */
  74425. export class Container3D extends Control3D {
  74426. private _blockLayout;
  74427. /**
  74428. * Gets the list of child controls
  74429. */
  74430. protected _children: Control3D[];
  74431. /**
  74432. * Gets the list of child controls
  74433. */
  74434. get children(): Array<Control3D>;
  74435. /**
  74436. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74437. * This is helpful to optimize layout operation when adding multiple children in a row
  74438. */
  74439. get blockLayout(): boolean;
  74440. set blockLayout(value: boolean);
  74441. /**
  74442. * Creates a new container
  74443. * @param name defines the container name
  74444. */
  74445. constructor(name?: string);
  74446. /**
  74447. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74448. * @returns the current container
  74449. */
  74450. updateLayout(): Container3D;
  74451. /**
  74452. * Gets a boolean indicating if the given control is in the children of this control
  74453. * @param control defines the control to check
  74454. * @returns true if the control is in the child list
  74455. */
  74456. containsControl(control: Control3D): boolean;
  74457. /**
  74458. * Adds a control to the children of this control
  74459. * @param control defines the control to add
  74460. * @returns the current container
  74461. */
  74462. addControl(control: Control3D): Container3D;
  74463. /**
  74464. * This function will be called everytime a new control is added
  74465. */
  74466. protected _arrangeChildren(): void;
  74467. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74468. /**
  74469. * Removes a control from the children of this control
  74470. * @param control defines the control to remove
  74471. * @returns the current container
  74472. */
  74473. removeControl(control: Control3D): Container3D;
  74474. protected _getTypeName(): string;
  74475. /**
  74476. * Releases all associated resources
  74477. */
  74478. dispose(): void;
  74479. /** Control rotation will remain unchanged */
  74480. static readonly UNSET_ORIENTATION: number;
  74481. /** Control will rotate to make it look at sphere central axis */
  74482. static readonly FACEORIGIN_ORIENTATION: number;
  74483. /** Control will rotate to make it look back at sphere central axis */
  74484. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74485. /** Control will rotate to look at z axis (0, 0, 1) */
  74486. static readonly FACEFORWARD_ORIENTATION: number;
  74487. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74488. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74489. }
  74490. }
  74491. declare module BABYLON.GUI {
  74492. /**
  74493. * Class used to manage 3D user interface
  74494. * @see http://doc.babylonjs.com/how_to/gui3d
  74495. */
  74496. export class GUI3DManager implements BABYLON.IDisposable {
  74497. private _scene;
  74498. private _sceneDisposeObserver;
  74499. private _utilityLayer;
  74500. private _rootContainer;
  74501. private _pointerObserver;
  74502. private _pointerOutObserver;
  74503. /** @hidden */
  74504. _lastPickedControl: Control3D;
  74505. /** @hidden */
  74506. _lastControlOver: {
  74507. [pointerId: number]: Control3D;
  74508. };
  74509. /** @hidden */
  74510. _lastControlDown: {
  74511. [pointerId: number]: Control3D;
  74512. };
  74513. /**
  74514. * BABYLON.Observable raised when the point picked by the pointer events changed
  74515. */
  74516. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74517. /** @hidden */
  74518. _sharedMaterials: {
  74519. [key: string]: BABYLON.Material;
  74520. };
  74521. /** Gets the hosting scene */
  74522. get scene(): BABYLON.Scene;
  74523. /** Gets associated utility layer */
  74524. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74525. /**
  74526. * Creates a new GUI3DManager
  74527. * @param scene
  74528. */
  74529. constructor(scene?: BABYLON.Scene);
  74530. private _handlePointerOut;
  74531. private _doPicking;
  74532. /**
  74533. * Gets the root container
  74534. */
  74535. get rootContainer(): Container3D;
  74536. /**
  74537. * Gets a boolean indicating if the given control is in the root child list
  74538. * @param control defines the control to check
  74539. * @returns true if the control is in the root child list
  74540. */
  74541. containsControl(control: Control3D): boolean;
  74542. /**
  74543. * Adds a control to the root child list
  74544. * @param control defines the control to add
  74545. * @returns the current manager
  74546. */
  74547. addControl(control: Control3D): GUI3DManager;
  74548. /**
  74549. * Removes a control from the root child list
  74550. * @param control defines the control to remove
  74551. * @returns the current container
  74552. */
  74553. removeControl(control: Control3D): GUI3DManager;
  74554. /**
  74555. * Releases all associated resources
  74556. */
  74557. dispose(): void;
  74558. }
  74559. }
  74560. declare module BABYLON.GUI {
  74561. /**
  74562. * Class used to transport BABYLON.Vector3 information for pointer events
  74563. */
  74564. export class Vector3WithInfo extends BABYLON.Vector3 {
  74565. /** defines the current mouse button index */
  74566. buttonIndex: number;
  74567. /**
  74568. * Creates a new Vector3WithInfo
  74569. * @param source defines the vector3 data to transport
  74570. * @param buttonIndex defines the current mouse button index
  74571. */
  74572. constructor(source: BABYLON.Vector3,
  74573. /** defines the current mouse button index */
  74574. buttonIndex?: number);
  74575. }
  74576. }
  74577. declare module BABYLON.GUI {
  74578. /**
  74579. * Class used as base class for controls
  74580. */
  74581. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74582. /** Defines the control name */
  74583. name?: string | undefined;
  74584. /** @hidden */
  74585. _host: GUI3DManager;
  74586. private _node;
  74587. private _downCount;
  74588. private _enterCount;
  74589. private _downPointerIds;
  74590. private _isVisible;
  74591. /** Gets or sets the control position in world space */
  74592. get position(): BABYLON.Vector3;
  74593. set position(value: BABYLON.Vector3);
  74594. /** Gets or sets the control scaling in world space */
  74595. get scaling(): BABYLON.Vector3;
  74596. set scaling(value: BABYLON.Vector3);
  74597. /** Callback used to start pointer enter animation */
  74598. pointerEnterAnimation: () => void;
  74599. /** Callback used to start pointer out animation */
  74600. pointerOutAnimation: () => void;
  74601. /** Callback used to start pointer down animation */
  74602. pointerDownAnimation: () => void;
  74603. /** Callback used to start pointer up animation */
  74604. pointerUpAnimation: () => void;
  74605. /**
  74606. * An event triggered when the pointer move over the control
  74607. */
  74608. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74609. /**
  74610. * An event triggered when the pointer move out of the control
  74611. */
  74612. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74613. /**
  74614. * An event triggered when the pointer taps the control
  74615. */
  74616. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74617. /**
  74618. * An event triggered when pointer is up
  74619. */
  74620. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74621. /**
  74622. * An event triggered when a control is clicked on (with a mouse)
  74623. */
  74624. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74625. /**
  74626. * An event triggered when pointer enters the control
  74627. */
  74628. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74629. /**
  74630. * Gets or sets the parent container
  74631. */
  74632. parent: BABYLON.Nullable<Container3D>;
  74633. private _behaviors;
  74634. /**
  74635. * Gets the list of attached behaviors
  74636. * @see http://doc.babylonjs.com/features/behaviour
  74637. */
  74638. get behaviors(): BABYLON.Behavior<Control3D>[];
  74639. /**
  74640. * Attach a behavior to the control
  74641. * @see http://doc.babylonjs.com/features/behaviour
  74642. * @param behavior defines the behavior to attach
  74643. * @returns the current control
  74644. */
  74645. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74646. /**
  74647. * Remove an attached behavior
  74648. * @see http://doc.babylonjs.com/features/behaviour
  74649. * @param behavior defines the behavior to attach
  74650. * @returns the current control
  74651. */
  74652. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74653. /**
  74654. * Gets an attached behavior by name
  74655. * @param name defines the name of the behavior to look for
  74656. * @see http://doc.babylonjs.com/features/behaviour
  74657. * @returns null if behavior was not found else the requested behavior
  74658. */
  74659. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74660. /** Gets or sets a boolean indicating if the control is visible */
  74661. get isVisible(): boolean;
  74662. set isVisible(value: boolean);
  74663. /**
  74664. * Creates a new control
  74665. * @param name defines the control name
  74666. */
  74667. constructor(
  74668. /** Defines the control name */
  74669. name?: string | undefined);
  74670. /**
  74671. * Gets a string representing the class name
  74672. */
  74673. get typeName(): string;
  74674. /**
  74675. * Get the current class name of the control.
  74676. * @returns current class name
  74677. */
  74678. getClassName(): string;
  74679. protected _getTypeName(): string;
  74680. /**
  74681. * Gets the transform node used by this control
  74682. */
  74683. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74684. /**
  74685. * Gets the mesh used to render this control
  74686. */
  74687. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74688. /**
  74689. * Link the control as child of the given node
  74690. * @param node defines the node to link to. Use null to unlink the control
  74691. * @returns the current control
  74692. */
  74693. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74694. /** @hidden **/
  74695. _prepareNode(scene: BABYLON.Scene): void;
  74696. /**
  74697. * Node creation.
  74698. * Can be overriden by children
  74699. * @param scene defines the scene where the node must be attached
  74700. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74701. */
  74702. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74703. /**
  74704. * Affect a material to the given mesh
  74705. * @param mesh defines the mesh which will represent the control
  74706. */
  74707. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74708. /** @hidden */
  74709. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74710. /** @hidden */
  74711. _onPointerEnter(target: Control3D): boolean;
  74712. /** @hidden */
  74713. _onPointerOut(target: Control3D): void;
  74714. /** @hidden */
  74715. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74716. /** @hidden */
  74717. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74718. /** @hidden */
  74719. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74720. /** @hidden */
  74721. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74722. /** @hidden */
  74723. _disposeNode(): void;
  74724. /**
  74725. * Releases all associated resources
  74726. */
  74727. dispose(): void;
  74728. }
  74729. }
  74730. declare module BABYLON.GUI {
  74731. /**
  74732. * Class used as a root to all buttons
  74733. */
  74734. export class AbstractButton3D extends Control3D {
  74735. /**
  74736. * Creates a new button
  74737. * @param name defines the control name
  74738. */
  74739. constructor(name?: string);
  74740. protected _getTypeName(): string;
  74741. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74742. }
  74743. }
  74744. declare module BABYLON.GUI {
  74745. /**
  74746. * Class used to create a button in 3D
  74747. */
  74748. export class Button3D extends AbstractButton3D {
  74749. /** @hidden */
  74750. protected _currentMaterial: BABYLON.Material;
  74751. private _facadeTexture;
  74752. private _content;
  74753. private _contentResolution;
  74754. private _contentScaleRatio;
  74755. /**
  74756. * Gets or sets the texture resolution used to render content (512 by default)
  74757. */
  74758. get contentResolution(): BABYLON.int;
  74759. set contentResolution(value: BABYLON.int);
  74760. /**
  74761. * Gets or sets the texture scale ratio used to render content (2 by default)
  74762. */
  74763. get contentScaleRatio(): number;
  74764. set contentScaleRatio(value: number);
  74765. protected _disposeFacadeTexture(): void;
  74766. protected _resetContent(): void;
  74767. /**
  74768. * Creates a new button
  74769. * @param name defines the control name
  74770. */
  74771. constructor(name?: string);
  74772. /**
  74773. * Gets or sets the GUI 2D content used to display the button's facade
  74774. */
  74775. get content(): Control;
  74776. set content(value: Control);
  74777. /**
  74778. * Apply the facade texture (created from the content property).
  74779. * This function can be overloaded by child classes
  74780. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74781. */
  74782. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74783. protected _getTypeName(): string;
  74784. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74785. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74786. /**
  74787. * Releases all associated resources
  74788. */
  74789. dispose(): void;
  74790. }
  74791. }
  74792. declare module BABYLON.GUI {
  74793. /**
  74794. * Abstract class used to create a container panel deployed on the surface of a volume
  74795. */
  74796. export abstract class VolumeBasedPanel extends Container3D {
  74797. private _columns;
  74798. private _rows;
  74799. private _rowThenColum;
  74800. private _orientation;
  74801. protected _cellWidth: number;
  74802. protected _cellHeight: number;
  74803. /**
  74804. * Gets or sets the distance between elements
  74805. */
  74806. margin: number;
  74807. /**
  74808. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74809. * | Value | Type | Description |
  74810. * | ----- | ----------------------------------- | ----------- |
  74811. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74812. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74813. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74814. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74815. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74816. */
  74817. get orientation(): number;
  74818. set orientation(value: number);
  74819. /**
  74820. * Gets or sets the number of columns requested (10 by default).
  74821. * The panel will automatically compute the number of rows based on number of child controls.
  74822. */
  74823. get columns(): BABYLON.int;
  74824. set columns(value: BABYLON.int);
  74825. /**
  74826. * Gets or sets a the number of rows requested.
  74827. * The panel will automatically compute the number of columns based on number of child controls.
  74828. */
  74829. get rows(): BABYLON.int;
  74830. set rows(value: BABYLON.int);
  74831. /**
  74832. * Creates new VolumeBasedPanel
  74833. */
  74834. constructor();
  74835. protected _arrangeChildren(): void;
  74836. /** Child classes must implement this function to provide correct control positioning */
  74837. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74838. /** Child classes can implement this function to provide additional processing */
  74839. protected _finalProcessing(): void;
  74840. }
  74841. }
  74842. declare module BABYLON.GUI {
  74843. /**
  74844. * Class used to create a container panel deployed on the surface of a cylinder
  74845. */
  74846. export class CylinderPanel extends VolumeBasedPanel {
  74847. private _radius;
  74848. /**
  74849. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74850. */
  74851. get radius(): BABYLON.float;
  74852. set radius(value: BABYLON.float);
  74853. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74854. private _cylindricalMapping;
  74855. }
  74856. }
  74857. declare module BABYLON.GUI {
  74858. /** @hidden */
  74859. export var fluentVertexShader: {
  74860. name: string;
  74861. shader: string;
  74862. };
  74863. }
  74864. declare module BABYLON.GUI {
  74865. /** @hidden */
  74866. export var fluentPixelShader: {
  74867. name: string;
  74868. shader: string;
  74869. };
  74870. }
  74871. declare module BABYLON.GUI {
  74872. /** @hidden */
  74873. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74874. INNERGLOW: boolean;
  74875. BORDER: boolean;
  74876. HOVERLIGHT: boolean;
  74877. TEXTURE: boolean;
  74878. constructor();
  74879. }
  74880. /**
  74881. * Class used to render controls with fluent desgin
  74882. */
  74883. export class FluentMaterial extends BABYLON.PushMaterial {
  74884. /**
  74885. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74886. */
  74887. innerGlowColorIntensity: number;
  74888. /**
  74889. * Gets or sets the inner glow color (white by default)
  74890. */
  74891. innerGlowColor: BABYLON.Color3;
  74892. /**
  74893. * Gets or sets alpha value (default is 1.0)
  74894. */
  74895. alpha: number;
  74896. /**
  74897. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74898. */
  74899. albedoColor: BABYLON.Color3;
  74900. /**
  74901. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74902. */
  74903. renderBorders: boolean;
  74904. /**
  74905. * Gets or sets border width (default is 0.5)
  74906. */
  74907. borderWidth: number;
  74908. /**
  74909. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74910. */
  74911. edgeSmoothingValue: number;
  74912. /**
  74913. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74914. */
  74915. borderMinValue: number;
  74916. /**
  74917. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74918. */
  74919. renderHoverLight: boolean;
  74920. /**
  74921. * Gets or sets the radius used to render the hover light (default is 1.0)
  74922. */
  74923. hoverRadius: number;
  74924. /**
  74925. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74926. */
  74927. hoverColor: BABYLON.Color4;
  74928. /**
  74929. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74930. */
  74931. hoverPosition: BABYLON.Vector3;
  74932. private _albedoTexture;
  74933. /** Gets or sets the texture to use for albedo color */
  74934. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74935. /**
  74936. * Creates a new Fluent material
  74937. * @param name defines the name of the material
  74938. * @param scene defines the hosting scene
  74939. */
  74940. constructor(name: string, scene: BABYLON.Scene);
  74941. needAlphaBlending(): boolean;
  74942. needAlphaTesting(): boolean;
  74943. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74944. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74945. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74946. getActiveTextures(): BABYLON.BaseTexture[];
  74947. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74948. dispose(forceDisposeEffect?: boolean): void;
  74949. clone(name: string): FluentMaterial;
  74950. serialize(): any;
  74951. getClassName(): string;
  74952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74953. }
  74954. }
  74955. declare module BABYLON.GUI {
  74956. /**
  74957. * Class used to create a holographic button in 3D
  74958. */
  74959. export class HolographicButton extends Button3D {
  74960. private _backPlate;
  74961. private _textPlate;
  74962. private _frontPlate;
  74963. private _text;
  74964. private _imageUrl;
  74965. private _shareMaterials;
  74966. private _frontMaterial;
  74967. private _backMaterial;
  74968. private _plateMaterial;
  74969. private _pickedPointObserver;
  74970. private _tooltipFade;
  74971. private _tooltipTextBlock;
  74972. private _tooltipTexture;
  74973. private _tooltipMesh;
  74974. private _tooltipHoverObserver;
  74975. private _tooltipOutObserver;
  74976. private _disposeTooltip;
  74977. /**
  74978. * Rendering ground id of all the mesh in the button
  74979. */
  74980. set renderingGroupId(id: number);
  74981. get renderingGroupId(): number;
  74982. /**
  74983. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74984. */
  74985. set tooltipText(text: BABYLON.Nullable<string>);
  74986. get tooltipText(): BABYLON.Nullable<string>;
  74987. /**
  74988. * Gets or sets text for the button
  74989. */
  74990. get text(): string;
  74991. set text(value: string);
  74992. /**
  74993. * Gets or sets the image url for the button
  74994. */
  74995. get imageUrl(): string;
  74996. set imageUrl(value: string);
  74997. /**
  74998. * Gets the back material used by this button
  74999. */
  75000. get backMaterial(): FluentMaterial;
  75001. /**
  75002. * Gets the front material used by this button
  75003. */
  75004. get frontMaterial(): FluentMaterial;
  75005. /**
  75006. * Gets the plate material used by this button
  75007. */
  75008. get plateMaterial(): BABYLON.StandardMaterial;
  75009. /**
  75010. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75011. */
  75012. get shareMaterials(): boolean;
  75013. /**
  75014. * Creates a new button
  75015. * @param name defines the control name
  75016. */
  75017. constructor(name?: string, shareMaterials?: boolean);
  75018. protected _getTypeName(): string;
  75019. private _rebuildContent;
  75020. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75021. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75022. private _createBackMaterial;
  75023. private _createFrontMaterial;
  75024. private _createPlateMaterial;
  75025. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75026. /**
  75027. * Releases all associated resources
  75028. */
  75029. dispose(): void;
  75030. }
  75031. }
  75032. declare module BABYLON.GUI {
  75033. /**
  75034. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75035. */
  75036. export class MeshButton3D extends Button3D {
  75037. /** @hidden */
  75038. protected _currentMesh: BABYLON.Mesh;
  75039. /**
  75040. * Creates a new 3D button based on a mesh
  75041. * @param mesh mesh to become a 3D button
  75042. * @param name defines the control name
  75043. */
  75044. constructor(mesh: BABYLON.Mesh, name?: string);
  75045. protected _getTypeName(): string;
  75046. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75047. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75048. }
  75049. }
  75050. declare module BABYLON.GUI {
  75051. /**
  75052. * Class used to create a container panel deployed on the surface of a plane
  75053. */
  75054. export class PlanePanel extends VolumeBasedPanel {
  75055. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75056. }
  75057. }
  75058. declare module BABYLON.GUI {
  75059. /**
  75060. * Class used to create a container panel where items get randomized planar mapping
  75061. */
  75062. export class ScatterPanel extends VolumeBasedPanel {
  75063. private _iteration;
  75064. /**
  75065. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75066. */
  75067. get iteration(): BABYLON.float;
  75068. set iteration(value: BABYLON.float);
  75069. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75070. private _scatterMapping;
  75071. protected _finalProcessing(): void;
  75072. }
  75073. }
  75074. declare module BABYLON.GUI {
  75075. /**
  75076. * Class used to create a container panel deployed on the surface of a sphere
  75077. */
  75078. export class SpherePanel extends VolumeBasedPanel {
  75079. private _radius;
  75080. /**
  75081. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75082. */
  75083. get radius(): BABYLON.float;
  75084. set radius(value: BABYLON.float);
  75085. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75086. private _sphericalMapping;
  75087. }
  75088. }
  75089. declare module BABYLON.GUI {
  75090. /**
  75091. * Class used to create a stack panel in 3D on XY plane
  75092. */
  75093. export class StackPanel3D extends Container3D {
  75094. private _isVertical;
  75095. /**
  75096. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75097. */
  75098. get isVertical(): boolean;
  75099. set isVertical(value: boolean);
  75100. /**
  75101. * Gets or sets the distance between elements
  75102. */
  75103. margin: number;
  75104. /**
  75105. * Creates new StackPanel
  75106. * @param isVertical
  75107. */
  75108. constructor(isVertical?: boolean);
  75109. protected _arrangeChildren(): void;
  75110. }
  75111. }
  75112. declare module BABYLON {
  75113. /**
  75114. * Configuration for glTF validation
  75115. */
  75116. export interface IGLTFValidationConfiguration {
  75117. /**
  75118. * The url of the glTF validator.
  75119. */
  75120. url: string;
  75121. }
  75122. /**
  75123. * glTF validation
  75124. */
  75125. export class GLTFValidation {
  75126. /**
  75127. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75128. */
  75129. static Configuration: IGLTFValidationConfiguration;
  75130. private static _LoadScriptPromise;
  75131. /**
  75132. * Validate a glTF asset using the glTF-Validator.
  75133. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75134. * @param rootUrl The root url for the glTF
  75135. * @param fileName The file name for the glTF
  75136. * @param getExternalResource The callback to get external resources for the glTF validator
  75137. * @returns A promise that resolves with the glTF validation results once complete
  75138. */
  75139. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75140. }
  75141. }
  75142. declare module BABYLON {
  75143. /**
  75144. * Mode that determines the coordinate system to use.
  75145. */
  75146. export enum GLTFLoaderCoordinateSystemMode {
  75147. /**
  75148. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75149. */
  75150. AUTO = 0,
  75151. /**
  75152. * Sets the useRightHandedSystem flag on the scene.
  75153. */
  75154. FORCE_RIGHT_HANDED = 1
  75155. }
  75156. /**
  75157. * Mode that determines what animations will start.
  75158. */
  75159. export enum GLTFLoaderAnimationStartMode {
  75160. /**
  75161. * No animation will start.
  75162. */
  75163. NONE = 0,
  75164. /**
  75165. * The first animation will start.
  75166. */
  75167. FIRST = 1,
  75168. /**
  75169. * All animations will start.
  75170. */
  75171. ALL = 2
  75172. }
  75173. /**
  75174. * Interface that contains the data for the glTF asset.
  75175. */
  75176. export interface IGLTFLoaderData {
  75177. /**
  75178. * The object that represents the glTF JSON.
  75179. */
  75180. json: Object;
  75181. /**
  75182. * The BIN chunk of a binary glTF.
  75183. */
  75184. bin: Nullable<IDataBuffer>;
  75185. }
  75186. /**
  75187. * Interface for extending the loader.
  75188. */
  75189. export interface IGLTFLoaderExtension {
  75190. /**
  75191. * The name of this extension.
  75192. */
  75193. readonly name: string;
  75194. /**
  75195. * Defines whether this extension is enabled.
  75196. */
  75197. enabled: boolean;
  75198. /**
  75199. * Defines the order of this extension.
  75200. * The loader sorts the extensions using these values when loading.
  75201. */
  75202. order?: number;
  75203. }
  75204. /**
  75205. * Loader state.
  75206. */
  75207. export enum GLTFLoaderState {
  75208. /**
  75209. * The asset is loading.
  75210. */
  75211. LOADING = 0,
  75212. /**
  75213. * The asset is ready for rendering.
  75214. */
  75215. READY = 1,
  75216. /**
  75217. * The asset is completely loaded.
  75218. */
  75219. COMPLETE = 2
  75220. }
  75221. /** @hidden */
  75222. export interface IImportMeshAsyncOutput {
  75223. meshes: AbstractMesh[];
  75224. particleSystems: IParticleSystem[];
  75225. skeletons: Skeleton[];
  75226. animationGroups: AnimationGroup[];
  75227. lights: Light[];
  75228. transformNodes: TransformNode[];
  75229. }
  75230. /** @hidden */
  75231. export interface IGLTFLoader extends IDisposable {
  75232. readonly state: Nullable<GLTFLoaderState>;
  75233. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75234. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75235. }
  75236. /**
  75237. * File loader for loading glTF files into a scene.
  75238. */
  75239. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75240. /** @hidden */
  75241. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75242. /** @hidden */
  75243. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75244. /**
  75245. * Raised when the asset has been parsed
  75246. */
  75247. onParsedObservable: Observable<IGLTFLoaderData>;
  75248. private _onParsedObserver;
  75249. /**
  75250. * Raised when the asset has been parsed
  75251. */
  75252. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75253. /**
  75254. * 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.
  75255. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75256. * Defaults to true.
  75257. * @hidden
  75258. */
  75259. static IncrementalLoading: boolean;
  75260. /**
  75261. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75262. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75263. * @hidden
  75264. */
  75265. static HomogeneousCoordinates: boolean;
  75266. /**
  75267. * The coordinate system mode. Defaults to AUTO.
  75268. */
  75269. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75270. /**
  75271. * The animation start mode. Defaults to FIRST.
  75272. */
  75273. animationStartMode: GLTFLoaderAnimationStartMode;
  75274. /**
  75275. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75276. */
  75277. compileMaterials: boolean;
  75278. /**
  75279. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75280. */
  75281. useClipPlane: boolean;
  75282. /**
  75283. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75284. */
  75285. compileShadowGenerators: boolean;
  75286. /**
  75287. * Defines if the Alpha blended materials are only applied as coverage.
  75288. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75289. * If true, no extra effects are applied to transparent pixels.
  75290. */
  75291. transparencyAsCoverage: boolean;
  75292. /**
  75293. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75294. * Enabling will disable offline support and glTF validator.
  75295. * Defaults to false.
  75296. */
  75297. useRangeRequests: boolean;
  75298. /**
  75299. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75300. */
  75301. createInstances: boolean;
  75302. /**
  75303. * Function called before loading a url referenced by the asset.
  75304. */
  75305. preprocessUrlAsync: (url: string) => Promise<string>;
  75306. /**
  75307. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75308. */
  75309. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75310. private _onMeshLoadedObserver;
  75311. /**
  75312. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75313. */
  75314. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75315. /**
  75316. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75317. */
  75318. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75319. private _onTextureLoadedObserver;
  75320. /**
  75321. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75322. */
  75323. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75324. /**
  75325. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75326. */
  75327. readonly onMaterialLoadedObservable: Observable<Material>;
  75328. private _onMaterialLoadedObserver;
  75329. /**
  75330. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75331. */
  75332. set onMaterialLoaded(callback: (material: Material) => void);
  75333. /**
  75334. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75335. */
  75336. readonly onCameraLoadedObservable: Observable<Camera>;
  75337. private _onCameraLoadedObserver;
  75338. /**
  75339. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75340. */
  75341. set onCameraLoaded(callback: (camera: Camera) => void);
  75342. /**
  75343. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75344. * For assets with LODs, raised when all of the LODs are complete.
  75345. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75346. */
  75347. readonly onCompleteObservable: Observable<void>;
  75348. private _onCompleteObserver;
  75349. /**
  75350. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75351. * For assets with LODs, raised when all of the LODs are complete.
  75352. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75353. */
  75354. set onComplete(callback: () => void);
  75355. /**
  75356. * Observable raised when an error occurs.
  75357. */
  75358. readonly onErrorObservable: Observable<any>;
  75359. private _onErrorObserver;
  75360. /**
  75361. * Callback raised when an error occurs.
  75362. */
  75363. set onError(callback: (reason: any) => void);
  75364. /**
  75365. * Observable raised after the loader is disposed.
  75366. */
  75367. readonly onDisposeObservable: Observable<void>;
  75368. private _onDisposeObserver;
  75369. /**
  75370. * Callback raised after the loader is disposed.
  75371. */
  75372. set onDispose(callback: () => void);
  75373. /**
  75374. * Observable raised after a loader extension is created.
  75375. * Set additional options for a loader extension in this event.
  75376. */
  75377. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75378. private _onExtensionLoadedObserver;
  75379. /**
  75380. * Callback raised after a loader extension is created.
  75381. */
  75382. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75383. /**
  75384. * Defines if the loader logging is enabled.
  75385. */
  75386. get loggingEnabled(): boolean;
  75387. set loggingEnabled(value: boolean);
  75388. /**
  75389. * Defines if the loader should capture performance counters.
  75390. */
  75391. get capturePerformanceCounters(): boolean;
  75392. set capturePerformanceCounters(value: boolean);
  75393. /**
  75394. * Defines if the loader should validate the asset.
  75395. */
  75396. validate: boolean;
  75397. /**
  75398. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75399. */
  75400. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75401. private _onValidatedObserver;
  75402. /**
  75403. * Callback raised after a loader extension is created.
  75404. */
  75405. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75406. private _loader;
  75407. /**
  75408. * Name of the loader ("gltf")
  75409. */
  75410. name: string;
  75411. /** @hidden */
  75412. extensions: ISceneLoaderPluginExtensions;
  75413. /**
  75414. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75415. */
  75416. dispose(): void;
  75417. /** @hidden */
  75418. _clear(): void;
  75419. /** @hidden */
  75420. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75421. /** @hidden */
  75422. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75423. /** @hidden */
  75424. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75425. meshes: AbstractMesh[];
  75426. particleSystems: IParticleSystem[];
  75427. skeletons: Skeleton[];
  75428. animationGroups: AnimationGroup[];
  75429. }>;
  75430. /** @hidden */
  75431. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75432. /** @hidden */
  75433. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75434. /** @hidden */
  75435. canDirectLoad(data: string): boolean;
  75436. /** @hidden */
  75437. directLoad(scene: Scene, data: string): any;
  75438. /**
  75439. * The callback that allows custom handling of the root url based on the response url.
  75440. * @param rootUrl the original root url
  75441. * @param responseURL the response url if available
  75442. * @returns the new root url
  75443. */
  75444. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75445. /** @hidden */
  75446. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75447. /**
  75448. * The loader state or null if the loader is not active.
  75449. */
  75450. get loaderState(): Nullable<GLTFLoaderState>;
  75451. /**
  75452. * Returns a promise that resolves when the asset is completely loaded.
  75453. * @returns a promise that resolves when the asset is completely loaded.
  75454. */
  75455. whenCompleteAsync(): Promise<void>;
  75456. private _validate;
  75457. private _getLoader;
  75458. private _parseJson;
  75459. private _unpackBinaryAsync;
  75460. private _unpackBinaryV1Async;
  75461. private _unpackBinaryV2Async;
  75462. private static _parseVersion;
  75463. private static _compareVersion;
  75464. private static readonly _logSpaces;
  75465. private _logIndentLevel;
  75466. private _loggingEnabled;
  75467. /** @hidden */
  75468. _log: (message: string) => void;
  75469. /** @hidden */
  75470. _logOpen(message: string): void;
  75471. /** @hidden */
  75472. _logClose(): void;
  75473. private _logEnabled;
  75474. private _logDisabled;
  75475. private _capturePerformanceCounters;
  75476. /** @hidden */
  75477. _startPerformanceCounter: (counterName: string) => void;
  75478. /** @hidden */
  75479. _endPerformanceCounter: (counterName: string) => void;
  75480. private _startPerformanceCounterEnabled;
  75481. private _startPerformanceCounterDisabled;
  75482. private _endPerformanceCounterEnabled;
  75483. private _endPerformanceCounterDisabled;
  75484. }
  75485. }
  75486. declare module BABYLON.GLTF1 {
  75487. /**
  75488. * Enums
  75489. * @hidden
  75490. */
  75491. export enum EComponentType {
  75492. BYTE = 5120,
  75493. UNSIGNED_BYTE = 5121,
  75494. SHORT = 5122,
  75495. UNSIGNED_SHORT = 5123,
  75496. FLOAT = 5126
  75497. }
  75498. /** @hidden */
  75499. export enum EShaderType {
  75500. FRAGMENT = 35632,
  75501. VERTEX = 35633
  75502. }
  75503. /** @hidden */
  75504. export enum EParameterType {
  75505. BYTE = 5120,
  75506. UNSIGNED_BYTE = 5121,
  75507. SHORT = 5122,
  75508. UNSIGNED_SHORT = 5123,
  75509. INT = 5124,
  75510. UNSIGNED_INT = 5125,
  75511. FLOAT = 5126,
  75512. FLOAT_VEC2 = 35664,
  75513. FLOAT_VEC3 = 35665,
  75514. FLOAT_VEC4 = 35666,
  75515. INT_VEC2 = 35667,
  75516. INT_VEC3 = 35668,
  75517. INT_VEC4 = 35669,
  75518. BOOL = 35670,
  75519. BOOL_VEC2 = 35671,
  75520. BOOL_VEC3 = 35672,
  75521. BOOL_VEC4 = 35673,
  75522. FLOAT_MAT2 = 35674,
  75523. FLOAT_MAT3 = 35675,
  75524. FLOAT_MAT4 = 35676,
  75525. SAMPLER_2D = 35678
  75526. }
  75527. /** @hidden */
  75528. export enum ETextureWrapMode {
  75529. CLAMP_TO_EDGE = 33071,
  75530. MIRRORED_REPEAT = 33648,
  75531. REPEAT = 10497
  75532. }
  75533. /** @hidden */
  75534. export enum ETextureFilterType {
  75535. NEAREST = 9728,
  75536. LINEAR = 9728,
  75537. NEAREST_MIPMAP_NEAREST = 9984,
  75538. LINEAR_MIPMAP_NEAREST = 9985,
  75539. NEAREST_MIPMAP_LINEAR = 9986,
  75540. LINEAR_MIPMAP_LINEAR = 9987
  75541. }
  75542. /** @hidden */
  75543. export enum ETextureFormat {
  75544. ALPHA = 6406,
  75545. RGB = 6407,
  75546. RGBA = 6408,
  75547. LUMINANCE = 6409,
  75548. LUMINANCE_ALPHA = 6410
  75549. }
  75550. /** @hidden */
  75551. export enum ECullingType {
  75552. FRONT = 1028,
  75553. BACK = 1029,
  75554. FRONT_AND_BACK = 1032
  75555. }
  75556. /** @hidden */
  75557. export enum EBlendingFunction {
  75558. ZERO = 0,
  75559. ONE = 1,
  75560. SRC_COLOR = 768,
  75561. ONE_MINUS_SRC_COLOR = 769,
  75562. DST_COLOR = 774,
  75563. ONE_MINUS_DST_COLOR = 775,
  75564. SRC_ALPHA = 770,
  75565. ONE_MINUS_SRC_ALPHA = 771,
  75566. DST_ALPHA = 772,
  75567. ONE_MINUS_DST_ALPHA = 773,
  75568. CONSTANT_COLOR = 32769,
  75569. ONE_MINUS_CONSTANT_COLOR = 32770,
  75570. CONSTANT_ALPHA = 32771,
  75571. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75572. SRC_ALPHA_SATURATE = 776
  75573. }
  75574. /** @hidden */
  75575. export interface IGLTFProperty {
  75576. extensions?: {
  75577. [key: string]: any;
  75578. };
  75579. extras?: Object;
  75580. }
  75581. /** @hidden */
  75582. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75583. name?: string;
  75584. }
  75585. /** @hidden */
  75586. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75587. bufferView: string;
  75588. byteOffset: number;
  75589. byteStride: number;
  75590. count: number;
  75591. type: string;
  75592. componentType: EComponentType;
  75593. max?: number[];
  75594. min?: number[];
  75595. name?: string;
  75596. }
  75597. /** @hidden */
  75598. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75599. buffer: string;
  75600. byteOffset: number;
  75601. byteLength: number;
  75602. byteStride: number;
  75603. target?: number;
  75604. }
  75605. /** @hidden */
  75606. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75607. uri: string;
  75608. byteLength?: number;
  75609. type?: string;
  75610. }
  75611. /** @hidden */
  75612. export interface IGLTFShader extends IGLTFChildRootProperty {
  75613. uri: string;
  75614. type: EShaderType;
  75615. }
  75616. /** @hidden */
  75617. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75618. attributes: string[];
  75619. fragmentShader: string;
  75620. vertexShader: string;
  75621. }
  75622. /** @hidden */
  75623. export interface IGLTFTechniqueParameter {
  75624. type: number;
  75625. count?: number;
  75626. semantic?: string;
  75627. node?: string;
  75628. value?: number | boolean | string | Array<any>;
  75629. source?: string;
  75630. babylonValue?: any;
  75631. }
  75632. /** @hidden */
  75633. export interface IGLTFTechniqueCommonProfile {
  75634. lightingModel: string;
  75635. texcoordBindings: Object;
  75636. parameters?: Array<any>;
  75637. }
  75638. /** @hidden */
  75639. export interface IGLTFTechniqueStatesFunctions {
  75640. blendColor?: number[];
  75641. blendEquationSeparate?: number[];
  75642. blendFuncSeparate?: number[];
  75643. colorMask: boolean[];
  75644. cullFace: number[];
  75645. }
  75646. /** @hidden */
  75647. export interface IGLTFTechniqueStates {
  75648. enable: number[];
  75649. functions: IGLTFTechniqueStatesFunctions;
  75650. }
  75651. /** @hidden */
  75652. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75653. parameters: {
  75654. [key: string]: IGLTFTechniqueParameter;
  75655. };
  75656. program: string;
  75657. attributes: {
  75658. [key: string]: string;
  75659. };
  75660. uniforms: {
  75661. [key: string]: string;
  75662. };
  75663. states: IGLTFTechniqueStates;
  75664. }
  75665. /** @hidden */
  75666. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75667. technique?: string;
  75668. values: string[];
  75669. }
  75670. /** @hidden */
  75671. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75672. attributes: {
  75673. [key: string]: string;
  75674. };
  75675. indices: string;
  75676. material: string;
  75677. mode?: number;
  75678. }
  75679. /** @hidden */
  75680. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75681. primitives: IGLTFMeshPrimitive[];
  75682. }
  75683. /** @hidden */
  75684. export interface IGLTFImage extends IGLTFChildRootProperty {
  75685. uri: string;
  75686. }
  75687. /** @hidden */
  75688. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75689. magFilter?: number;
  75690. minFilter?: number;
  75691. wrapS?: number;
  75692. wrapT?: number;
  75693. }
  75694. /** @hidden */
  75695. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75696. sampler: string;
  75697. source: string;
  75698. format?: ETextureFormat;
  75699. internalFormat?: ETextureFormat;
  75700. target?: number;
  75701. type?: number;
  75702. babylonTexture?: Texture;
  75703. }
  75704. /** @hidden */
  75705. export interface IGLTFAmbienLight {
  75706. color?: number[];
  75707. }
  75708. /** @hidden */
  75709. export interface IGLTFDirectionalLight {
  75710. color?: number[];
  75711. }
  75712. /** @hidden */
  75713. export interface IGLTFPointLight {
  75714. color?: number[];
  75715. constantAttenuation?: number;
  75716. linearAttenuation?: number;
  75717. quadraticAttenuation?: number;
  75718. }
  75719. /** @hidden */
  75720. export interface IGLTFSpotLight {
  75721. color?: number[];
  75722. constantAttenuation?: number;
  75723. fallOfAngle?: number;
  75724. fallOffExponent?: number;
  75725. linearAttenuation?: number;
  75726. quadraticAttenuation?: number;
  75727. }
  75728. /** @hidden */
  75729. export interface IGLTFLight extends IGLTFChildRootProperty {
  75730. type: string;
  75731. }
  75732. /** @hidden */
  75733. export interface IGLTFCameraOrthographic {
  75734. xmag: number;
  75735. ymag: number;
  75736. zfar: number;
  75737. znear: number;
  75738. }
  75739. /** @hidden */
  75740. export interface IGLTFCameraPerspective {
  75741. aspectRatio: number;
  75742. yfov: number;
  75743. zfar: number;
  75744. znear: number;
  75745. }
  75746. /** @hidden */
  75747. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75748. type: string;
  75749. }
  75750. /** @hidden */
  75751. export interface IGLTFAnimationChannelTarget {
  75752. id: string;
  75753. path: string;
  75754. }
  75755. /** @hidden */
  75756. export interface IGLTFAnimationChannel {
  75757. sampler: string;
  75758. target: IGLTFAnimationChannelTarget;
  75759. }
  75760. /** @hidden */
  75761. export interface IGLTFAnimationSampler {
  75762. input: string;
  75763. output: string;
  75764. interpolation?: string;
  75765. }
  75766. /** @hidden */
  75767. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75768. channels?: IGLTFAnimationChannel[];
  75769. parameters?: {
  75770. [key: string]: string;
  75771. };
  75772. samplers?: {
  75773. [key: string]: IGLTFAnimationSampler;
  75774. };
  75775. }
  75776. /** @hidden */
  75777. export interface IGLTFNodeInstanceSkin {
  75778. skeletons: string[];
  75779. skin: string;
  75780. meshes: string[];
  75781. }
  75782. /** @hidden */
  75783. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75784. bindShapeMatrix: number[];
  75785. inverseBindMatrices: string;
  75786. jointNames: string[];
  75787. babylonSkeleton?: Skeleton;
  75788. }
  75789. /** @hidden */
  75790. export interface IGLTFNode extends IGLTFChildRootProperty {
  75791. camera?: string;
  75792. children: string[];
  75793. skin?: string;
  75794. jointName?: string;
  75795. light?: string;
  75796. matrix: number[];
  75797. mesh?: string;
  75798. meshes?: string[];
  75799. rotation?: number[];
  75800. scale?: number[];
  75801. translation?: number[];
  75802. babylonNode?: Node;
  75803. }
  75804. /** @hidden */
  75805. export interface IGLTFScene extends IGLTFChildRootProperty {
  75806. nodes: string[];
  75807. }
  75808. /** @hidden */
  75809. export interface IGLTFRuntime {
  75810. extensions: {
  75811. [key: string]: any;
  75812. };
  75813. accessors: {
  75814. [key: string]: IGLTFAccessor;
  75815. };
  75816. buffers: {
  75817. [key: string]: IGLTFBuffer;
  75818. };
  75819. bufferViews: {
  75820. [key: string]: IGLTFBufferView;
  75821. };
  75822. meshes: {
  75823. [key: string]: IGLTFMesh;
  75824. };
  75825. lights: {
  75826. [key: string]: IGLTFLight;
  75827. };
  75828. cameras: {
  75829. [key: string]: IGLTFCamera;
  75830. };
  75831. nodes: {
  75832. [key: string]: IGLTFNode;
  75833. };
  75834. images: {
  75835. [key: string]: IGLTFImage;
  75836. };
  75837. textures: {
  75838. [key: string]: IGLTFTexture;
  75839. };
  75840. shaders: {
  75841. [key: string]: IGLTFShader;
  75842. };
  75843. programs: {
  75844. [key: string]: IGLTFProgram;
  75845. };
  75846. samplers: {
  75847. [key: string]: IGLTFSampler;
  75848. };
  75849. techniques: {
  75850. [key: string]: IGLTFTechnique;
  75851. };
  75852. materials: {
  75853. [key: string]: IGLTFMaterial;
  75854. };
  75855. animations: {
  75856. [key: string]: IGLTFAnimation;
  75857. };
  75858. skins: {
  75859. [key: string]: IGLTFSkins;
  75860. };
  75861. currentScene?: Object;
  75862. scenes: {
  75863. [key: string]: IGLTFScene;
  75864. };
  75865. extensionsUsed: string[];
  75866. extensionsRequired?: string[];
  75867. buffersCount: number;
  75868. shaderscount: number;
  75869. scene: Scene;
  75870. rootUrl: string;
  75871. loadedBufferCount: number;
  75872. loadedBufferViews: {
  75873. [name: string]: ArrayBufferView;
  75874. };
  75875. loadedShaderCount: number;
  75876. importOnlyMeshes: boolean;
  75877. importMeshesNames?: string[];
  75878. dummyNodes: Node[];
  75879. forAssetContainer: boolean;
  75880. }
  75881. /** @hidden */
  75882. export interface INodeToRoot {
  75883. bone: Bone;
  75884. node: IGLTFNode;
  75885. id: string;
  75886. }
  75887. /** @hidden */
  75888. export interface IJointNode {
  75889. node: IGLTFNode;
  75890. id: string;
  75891. }
  75892. }
  75893. declare module BABYLON.GLTF1 {
  75894. /**
  75895. * Utils functions for GLTF
  75896. * @hidden
  75897. */
  75898. export class GLTFUtils {
  75899. /**
  75900. * Sets the given "parameter" matrix
  75901. * @param scene: the Scene object
  75902. * @param source: the source node where to pick the matrix
  75903. * @param parameter: the GLTF technique parameter
  75904. * @param uniformName: the name of the shader's uniform
  75905. * @param shaderMaterial: the shader material
  75906. */
  75907. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75908. /**
  75909. * Sets the given "parameter" matrix
  75910. * @param shaderMaterial: the shader material
  75911. * @param uniform: the name of the shader's uniform
  75912. * @param value: the value of the uniform
  75913. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75914. */
  75915. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75916. /**
  75917. * Returns the wrap mode of the texture
  75918. * @param mode: the mode value
  75919. */
  75920. static GetWrapMode(mode: number): number;
  75921. /**
  75922. * Returns the byte stride giving an accessor
  75923. * @param accessor: the GLTF accessor objet
  75924. */
  75925. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75926. /**
  75927. * Returns the texture filter mode giving a mode value
  75928. * @param mode: the filter mode value
  75929. */
  75930. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75931. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75932. /**
  75933. * Returns a buffer from its accessor
  75934. * @param gltfRuntime: the GLTF runtime
  75935. * @param accessor: the GLTF accessor
  75936. */
  75937. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75938. /**
  75939. * Decodes a buffer view into a string
  75940. * @param view: the buffer view
  75941. */
  75942. static DecodeBufferToText(view: ArrayBufferView): string;
  75943. /**
  75944. * Returns the default material of gltf. Related to
  75945. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75946. * @param scene: the Babylon.js scene
  75947. */
  75948. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75949. private static _DefaultMaterial;
  75950. }
  75951. }
  75952. declare module BABYLON.GLTF1 {
  75953. /**
  75954. * Implementation of the base glTF spec
  75955. * @hidden
  75956. */
  75957. export class GLTFLoaderBase {
  75958. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75959. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75960. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75961. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75962. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75963. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75964. }
  75965. /**
  75966. * glTF V1 Loader
  75967. * @hidden
  75968. */
  75969. export class GLTFLoader implements IGLTFLoader {
  75970. static Extensions: {
  75971. [name: string]: GLTFLoaderExtension;
  75972. };
  75973. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75974. state: Nullable<GLTFLoaderState>;
  75975. dispose(): void;
  75976. private _importMeshAsync;
  75977. /**
  75978. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75979. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75980. * @param scene the scene the meshes should be added to
  75981. * @param forAssetContainer defines if the entities must be stored in the scene
  75982. * @param data gltf data containing information of the meshes in a loaded file
  75983. * @param rootUrl root url to load from
  75984. * @param onProgress event that fires when loading progress has occured
  75985. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75986. */
  75987. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75988. private _loadAsync;
  75989. /**
  75990. * Imports all objects from a loaded gltf file and adds them to the scene
  75991. * @param scene the scene the objects should be added to
  75992. * @param data gltf data containing information of the meshes in a loaded file
  75993. * @param rootUrl root url to load from
  75994. * @param onProgress event that fires when loading progress has occured
  75995. * @returns a promise which completes when objects have been loaded to the scene
  75996. */
  75997. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75998. private _loadShadersAsync;
  75999. private _loadBuffersAsync;
  76000. private _createNodes;
  76001. }
  76002. /** @hidden */
  76003. export abstract class GLTFLoaderExtension {
  76004. private _name;
  76005. constructor(name: string);
  76006. get name(): string;
  76007. /**
  76008. * Defines an override for loading the runtime
  76009. * Return true to stop further extensions from loading the runtime
  76010. */
  76011. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76012. /**
  76013. * Defines an onverride for creating gltf runtime
  76014. * Return true to stop further extensions from creating the runtime
  76015. */
  76016. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76017. /**
  76018. * Defines an override for loading buffers
  76019. * Return true to stop further extensions from loading this buffer
  76020. */
  76021. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76022. /**
  76023. * Defines an override for loading texture buffers
  76024. * Return true to stop further extensions from loading this texture data
  76025. */
  76026. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76027. /**
  76028. * Defines an override for creating textures
  76029. * Return true to stop further extensions from loading this texture
  76030. */
  76031. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76032. /**
  76033. * Defines an override for loading shader strings
  76034. * Return true to stop further extensions from loading this shader data
  76035. */
  76036. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76037. /**
  76038. * Defines an override for loading materials
  76039. * Return true to stop further extensions from loading this material
  76040. */
  76041. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76042. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76043. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76044. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76045. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76046. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76047. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76048. private static LoadTextureBufferAsync;
  76049. private static CreateTextureAsync;
  76050. private static ApplyExtensions;
  76051. }
  76052. }
  76053. declare module BABYLON.GLTF1 {
  76054. /** @hidden */
  76055. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76056. private _bin;
  76057. constructor();
  76058. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76059. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76060. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76061. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76062. }
  76063. }
  76064. declare module BABYLON.GLTF1 {
  76065. /** @hidden */
  76066. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76067. constructor();
  76068. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76069. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76070. private _loadTexture;
  76071. }
  76072. }
  76073. declare module BABYLON.GLTF2.Loader {
  76074. /**
  76075. * Loader interface with an index field.
  76076. */
  76077. export interface IArrayItem {
  76078. /**
  76079. * The index of this item in the array.
  76080. */
  76081. index: number;
  76082. }
  76083. /**
  76084. * Loader interface with additional members.
  76085. */
  76086. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76087. /** @hidden */
  76088. _data?: Promise<ArrayBufferView>;
  76089. /** @hidden */
  76090. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76091. }
  76092. /**
  76093. * Loader interface with additional members.
  76094. */
  76095. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76096. }
  76097. /** @hidden */
  76098. export interface _IAnimationSamplerData {
  76099. input: Float32Array;
  76100. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76101. output: Float32Array;
  76102. }
  76103. /**
  76104. * Loader interface with additional members.
  76105. */
  76106. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76107. /** @hidden */
  76108. _data?: Promise<_IAnimationSamplerData>;
  76109. }
  76110. /**
  76111. * Loader interface with additional members.
  76112. */
  76113. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76114. channels: IAnimationChannel[];
  76115. samplers: IAnimationSampler[];
  76116. /** @hidden */
  76117. _babylonAnimationGroup?: AnimationGroup;
  76118. }
  76119. /**
  76120. * Loader interface with additional members.
  76121. */
  76122. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76123. /** @hidden */
  76124. _data?: Promise<ArrayBufferView>;
  76125. }
  76126. /**
  76127. * Loader interface with additional members.
  76128. */
  76129. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76130. /** @hidden */
  76131. _data?: Promise<ArrayBufferView>;
  76132. /** @hidden */
  76133. _babylonBuffer?: Promise<Buffer>;
  76134. }
  76135. /**
  76136. * Loader interface with additional members.
  76137. */
  76138. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76139. }
  76140. /**
  76141. * Loader interface with additional members.
  76142. */
  76143. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76144. /** @hidden */
  76145. _data?: Promise<ArrayBufferView>;
  76146. }
  76147. /**
  76148. * Loader interface with additional members.
  76149. */
  76150. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76151. }
  76152. /**
  76153. * Loader interface with additional members.
  76154. */
  76155. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76156. }
  76157. /**
  76158. * Loader interface with additional members.
  76159. */
  76160. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76161. baseColorTexture?: ITextureInfo;
  76162. metallicRoughnessTexture?: ITextureInfo;
  76163. }
  76164. /**
  76165. * Loader interface with additional members.
  76166. */
  76167. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76168. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76169. normalTexture?: IMaterialNormalTextureInfo;
  76170. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76171. emissiveTexture?: ITextureInfo;
  76172. /** @hidden */
  76173. _data?: {
  76174. [babylonDrawMode: number]: {
  76175. babylonMaterial: Material;
  76176. babylonMeshes: AbstractMesh[];
  76177. promise: Promise<void>;
  76178. };
  76179. };
  76180. }
  76181. /**
  76182. * Loader interface with additional members.
  76183. */
  76184. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76185. primitives: IMeshPrimitive[];
  76186. }
  76187. /**
  76188. * Loader interface with additional members.
  76189. */
  76190. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76191. /** @hidden */
  76192. _instanceData?: {
  76193. babylonSourceMesh: Mesh;
  76194. promise: Promise<any>;
  76195. };
  76196. }
  76197. /**
  76198. * Loader interface with additional members.
  76199. */
  76200. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76201. /**
  76202. * The parent glTF node.
  76203. */
  76204. parent?: INode;
  76205. /** @hidden */
  76206. _babylonTransformNode?: TransformNode;
  76207. /** @hidden */
  76208. _primitiveBabylonMeshes?: AbstractMesh[];
  76209. /** @hidden */
  76210. _babylonBones?: Bone[];
  76211. /** @hidden */
  76212. _numMorphTargets?: number;
  76213. }
  76214. /** @hidden */
  76215. export interface _ISamplerData {
  76216. noMipMaps: boolean;
  76217. samplingMode: number;
  76218. wrapU: number;
  76219. wrapV: number;
  76220. }
  76221. /**
  76222. * Loader interface with additional members.
  76223. */
  76224. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76225. /** @hidden */
  76226. _data?: _ISamplerData;
  76227. }
  76228. /**
  76229. * Loader interface with additional members.
  76230. */
  76231. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76232. }
  76233. /**
  76234. * Loader interface with additional members.
  76235. */
  76236. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76237. /** @hidden */
  76238. _data?: {
  76239. babylonSkeleton: Skeleton;
  76240. promise: Promise<void>;
  76241. };
  76242. }
  76243. /**
  76244. * Loader interface with additional members.
  76245. */
  76246. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76247. }
  76248. /**
  76249. * Loader interface with additional members.
  76250. */
  76251. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76252. }
  76253. /**
  76254. * Loader interface with additional members.
  76255. */
  76256. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76257. accessors?: IAccessor[];
  76258. animations?: IAnimation[];
  76259. buffers?: IBuffer[];
  76260. bufferViews?: IBufferView[];
  76261. cameras?: ICamera[];
  76262. images?: IImage[];
  76263. materials?: IMaterial[];
  76264. meshes?: IMesh[];
  76265. nodes?: INode[];
  76266. samplers?: ISampler[];
  76267. scenes?: IScene[];
  76268. skins?: ISkin[];
  76269. textures?: ITexture[];
  76270. }
  76271. }
  76272. declare module BABYLON.GLTF2 {
  76273. /**
  76274. * Interface for a glTF loader extension.
  76275. */
  76276. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76277. /**
  76278. * Called after the loader state changes to LOADING.
  76279. */
  76280. onLoading?(): void;
  76281. /**
  76282. * Called after the loader state changes to READY.
  76283. */
  76284. onReady?(): void;
  76285. /**
  76286. * Define this method to modify the default behavior when loading scenes.
  76287. * @param context The context when loading the asset
  76288. * @param scene The glTF scene property
  76289. * @returns A promise that resolves when the load is complete or null if not handled
  76290. */
  76291. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76292. /**
  76293. * Define this method to modify the default behavior when loading nodes.
  76294. * @param context The context when loading the asset
  76295. * @param node The glTF node property
  76296. * @param assign A function called synchronously after parsing the glTF properties
  76297. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76298. */
  76299. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76300. /**
  76301. * Define this method to modify the default behavior when loading cameras.
  76302. * @param context The context when loading the asset
  76303. * @param camera The glTF camera property
  76304. * @param assign A function called synchronously after parsing the glTF properties
  76305. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76306. */
  76307. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76308. /**
  76309. * @hidden
  76310. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76311. * @param context The context when loading the asset
  76312. * @param primitive The glTF mesh primitive property
  76313. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76314. */
  76315. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76316. /**
  76317. * @hidden
  76318. * Define this method to modify the default behavior when loading data for mesh primitives.
  76319. * @param context The context when loading the asset
  76320. * @param name The mesh name when loading the asset
  76321. * @param node The glTF node when loading the asset
  76322. * @param mesh The glTF mesh when loading the asset
  76323. * @param primitive The glTF mesh primitive property
  76324. * @param assign A function called synchronously after parsing the glTF properties
  76325. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76326. */
  76327. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76328. /**
  76329. * @hidden
  76330. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76331. * @param context The context when loading the asset
  76332. * @param material The glTF material property
  76333. * @param assign A function called synchronously after parsing the glTF properties
  76334. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76335. */
  76336. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76337. /**
  76338. * Define this method to modify the default behavior when creating materials.
  76339. * @param context The context when loading the asset
  76340. * @param material The glTF material property
  76341. * @param babylonDrawMode The draw mode for the Babylon material
  76342. * @returns The Babylon material or null if not handled
  76343. */
  76344. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76345. /**
  76346. * Define this method to modify the default behavior when loading material properties.
  76347. * @param context The context when loading the asset
  76348. * @param material The glTF material property
  76349. * @param babylonMaterial The Babylon material
  76350. * @returns A promise that resolves when the load is complete or null if not handled
  76351. */
  76352. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76353. /**
  76354. * Define this method to modify the default behavior when loading texture infos.
  76355. * @param context The context when loading the asset
  76356. * @param textureInfo The glTF texture info property
  76357. * @param assign A function called synchronously after parsing the glTF properties
  76358. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76359. */
  76360. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76361. /**
  76362. * @hidden
  76363. * Define this method to modify the default behavior when loading textures.
  76364. * @param context The context when loading the asset
  76365. * @param texture The glTF texture property
  76366. * @param assign A function called synchronously after parsing the glTF properties
  76367. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76368. */
  76369. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76370. /**
  76371. * Define this method to modify the default behavior when loading animations.
  76372. * @param context The context when loading the asset
  76373. * @param animation The glTF animation property
  76374. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76375. */
  76376. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76377. /**
  76378. * @hidden
  76379. * Define this method to modify the default behavior when loading skins.
  76380. * @param context The context when loading the asset
  76381. * @param node The glTF node property
  76382. * @param skin The glTF skin property
  76383. * @returns A promise that resolves when the load is complete or null if not handled
  76384. */
  76385. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76386. /**
  76387. * @hidden
  76388. * Define this method to modify the default behavior when loading uris.
  76389. * @param context The context when loading the asset
  76390. * @param property The glTF property associated with the uri
  76391. * @param uri The uri to load
  76392. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76393. */
  76394. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76395. /**
  76396. * Define this method to modify the default behavior when loading buffer views.
  76397. * @param context The context when loading the asset
  76398. * @param bufferView The glTF buffer view property
  76399. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76400. */
  76401. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76402. /**
  76403. * Define this method to modify the default behavior when loading buffers.
  76404. * @param context The context when loading the asset
  76405. * @param buffer The glTF buffer property
  76406. * @param byteOffset The byte offset to load
  76407. * @param byteLength The byte length to load
  76408. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76409. */
  76410. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76411. }
  76412. }
  76413. declare module BABYLON.GLTF2 {
  76414. /**
  76415. * Helper class for working with arrays when loading the glTF asset
  76416. */
  76417. export class ArrayItem {
  76418. /**
  76419. * Gets an item from the given array.
  76420. * @param context The context when loading the asset
  76421. * @param array The array to get the item from
  76422. * @param index The index to the array
  76423. * @returns The array item
  76424. */
  76425. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76426. /**
  76427. * Assign an `index` field to each item of the given array.
  76428. * @param array The array of items
  76429. */
  76430. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76431. }
  76432. /**
  76433. * The glTF 2.0 loader
  76434. */
  76435. export class GLTFLoader implements IGLTFLoader {
  76436. /** @hidden */
  76437. _completePromises: Promise<any>[];
  76438. /** @hidden */
  76439. _forAssetContainer: boolean;
  76440. /** Storage */
  76441. _babylonLights: Light[];
  76442. private _disposed;
  76443. private _parent;
  76444. private _state;
  76445. private _extensions;
  76446. private _rootUrl;
  76447. private _fileName;
  76448. private _uniqueRootUrl;
  76449. private _gltf;
  76450. private _bin;
  76451. private _babylonScene;
  76452. private _rootBabylonMesh;
  76453. private _defaultBabylonMaterialData;
  76454. private _progressCallback?;
  76455. private _requests;
  76456. private static _RegisteredExtensions;
  76457. /**
  76458. * The default glTF sampler.
  76459. */
  76460. static readonly DefaultSampler: ISampler;
  76461. /**
  76462. * Registers a loader extension.
  76463. * @param name The name of the loader extension.
  76464. * @param factory The factory function that creates the loader extension.
  76465. */
  76466. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76467. /**
  76468. * Unregisters a loader extension.
  76469. * @param name The name of the loader extension.
  76470. * @returns A boolean indicating whether the extension has been unregistered
  76471. */
  76472. static UnregisterExtension(name: string): boolean;
  76473. /**
  76474. * The loader state.
  76475. */
  76476. get state(): Nullable<GLTFLoaderState>;
  76477. /**
  76478. * The object that represents the glTF JSON.
  76479. */
  76480. get gltf(): IGLTF;
  76481. /**
  76482. * The BIN chunk of a binary glTF.
  76483. */
  76484. get bin(): Nullable<IDataBuffer>;
  76485. /**
  76486. * The parent file loader.
  76487. */
  76488. get parent(): GLTFFileLoader;
  76489. /**
  76490. * The Babylon scene when loading the asset.
  76491. */
  76492. get babylonScene(): Scene;
  76493. /**
  76494. * The root Babylon mesh when loading the asset.
  76495. */
  76496. get rootBabylonMesh(): Mesh;
  76497. /** @hidden */
  76498. constructor(parent: GLTFFileLoader);
  76499. /** @hidden */
  76500. dispose(): void;
  76501. /** @hidden */
  76502. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76503. /** @hidden */
  76504. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76505. private _loadAsync;
  76506. private _loadData;
  76507. private _setupData;
  76508. private _loadExtensions;
  76509. private _checkExtensions;
  76510. private _setState;
  76511. private _createRootNode;
  76512. /**
  76513. * Loads a glTF scene.
  76514. * @param context The context when loading the asset
  76515. * @param scene The glTF scene property
  76516. * @returns A promise that resolves when the load is complete
  76517. */
  76518. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76519. private _forEachPrimitive;
  76520. private _getMeshes;
  76521. private _getTransformNodes;
  76522. private _getSkeletons;
  76523. private _getAnimationGroups;
  76524. private _startAnimations;
  76525. /**
  76526. * Loads a glTF node.
  76527. * @param context The context when loading the asset
  76528. * @param node The glTF node property
  76529. * @param assign A function called synchronously after parsing the glTF properties
  76530. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76531. */
  76532. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76533. private _loadMeshAsync;
  76534. /**
  76535. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76536. * @param context The context when loading the asset
  76537. * @param name The mesh name when loading the asset
  76538. * @param node The glTF node when loading the asset
  76539. * @param mesh The glTF mesh when loading the asset
  76540. * @param primitive The glTF mesh primitive property
  76541. * @param assign A function called synchronously after parsing the glTF properties
  76542. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76543. */
  76544. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76545. private _loadVertexDataAsync;
  76546. private _createMorphTargets;
  76547. private _loadMorphTargetsAsync;
  76548. private _loadMorphTargetVertexDataAsync;
  76549. private static _LoadTransform;
  76550. private _loadSkinAsync;
  76551. private _loadBones;
  76552. private _loadBone;
  76553. private _loadSkinInverseBindMatricesDataAsync;
  76554. private _updateBoneMatrices;
  76555. private _getNodeMatrix;
  76556. /**
  76557. * Loads a glTF camera.
  76558. * @param context The context when loading the asset
  76559. * @param camera The glTF camera property
  76560. * @param assign A function called synchronously after parsing the glTF properties
  76561. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76562. */
  76563. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76564. private _loadAnimationsAsync;
  76565. /**
  76566. * Loads a glTF animation.
  76567. * @param context The context when loading the asset
  76568. * @param animation The glTF animation property
  76569. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76570. */
  76571. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76572. /**
  76573. * @hidden Loads a glTF animation channel.
  76574. * @param context The context when loading the asset
  76575. * @param animationContext The context of the animation when loading the asset
  76576. * @param animation The glTF animation property
  76577. * @param channel The glTF animation channel property
  76578. * @param babylonAnimationGroup The babylon animation group property
  76579. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76580. * @returns A void promise when the channel load is complete
  76581. */
  76582. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76583. private _loadAnimationSamplerAsync;
  76584. private _loadBufferAsync;
  76585. /**
  76586. * Loads a glTF buffer view.
  76587. * @param context The context when loading the asset
  76588. * @param bufferView The glTF buffer view property
  76589. * @returns A promise that resolves with the loaded data when the load is complete
  76590. */
  76591. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76592. private _loadAccessorAsync;
  76593. /** @hidden */
  76594. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76595. private _loadIndicesAccessorAsync;
  76596. private _loadVertexBufferViewAsync;
  76597. private _loadVertexAccessorAsync;
  76598. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76599. /** @hidden */
  76600. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76601. private _createDefaultMaterial;
  76602. /**
  76603. * Creates a Babylon material from a glTF material.
  76604. * @param context The context when loading the asset
  76605. * @param material The glTF material property
  76606. * @param babylonDrawMode The draw mode for the Babylon material
  76607. * @returns The Babylon material
  76608. */
  76609. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76610. /**
  76611. * Loads properties from a glTF material into a Babylon material.
  76612. * @param context The context when loading the asset
  76613. * @param material The glTF material property
  76614. * @param babylonMaterial The Babylon material
  76615. * @returns A promise that resolves when the load is complete
  76616. */
  76617. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76618. /**
  76619. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76620. * @param context The context when loading the asset
  76621. * @param material The glTF material property
  76622. * @param babylonMaterial The Babylon material
  76623. * @returns A promise that resolves when the load is complete
  76624. */
  76625. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76626. /**
  76627. * Loads the alpha properties from a glTF material into a Babylon material.
  76628. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76629. * @param context The context when loading the asset
  76630. * @param material The glTF material property
  76631. * @param babylonMaterial The Babylon material
  76632. */
  76633. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76634. /**
  76635. * Loads a glTF texture info.
  76636. * @param context The context when loading the asset
  76637. * @param textureInfo The glTF texture info property
  76638. * @param assign A function called synchronously after parsing the glTF properties
  76639. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76640. */
  76641. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76642. /** @hidden */
  76643. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76644. /** @hidden */
  76645. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76646. private _loadSampler;
  76647. /**
  76648. * Loads a glTF image.
  76649. * @param context The context when loading the asset
  76650. * @param image The glTF image property
  76651. * @returns A promise that resolves with the loaded data when the load is complete
  76652. */
  76653. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76654. /**
  76655. * Loads a glTF uri.
  76656. * @param context The context when loading the asset
  76657. * @param property The glTF property associated with the uri
  76658. * @param uri The base64 or relative uri
  76659. * @returns A promise that resolves with the loaded data when the load is complete
  76660. */
  76661. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76662. private _onProgress;
  76663. /**
  76664. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76665. * @param babylonObject the Babylon object with metadata
  76666. * @param pointer the JSON pointer
  76667. */
  76668. static AddPointerMetadata(babylonObject: {
  76669. metadata: any;
  76670. }, pointer: string): void;
  76671. private static _GetTextureWrapMode;
  76672. private static _GetTextureSamplingMode;
  76673. private static _GetTypedArrayConstructor;
  76674. private static _GetTypedArray;
  76675. private static _GetNumComponents;
  76676. private static _ValidateUri;
  76677. private static _GetDrawMode;
  76678. private _compileMaterialsAsync;
  76679. private _compileShadowGeneratorsAsync;
  76680. private _forEachExtensions;
  76681. private _applyExtensions;
  76682. private _extensionsOnLoading;
  76683. private _extensionsOnReady;
  76684. private _extensionsLoadSceneAsync;
  76685. private _extensionsLoadNodeAsync;
  76686. private _extensionsLoadCameraAsync;
  76687. private _extensionsLoadVertexDataAsync;
  76688. private _extensionsLoadMeshPrimitiveAsync;
  76689. private _extensionsLoadMaterialAsync;
  76690. private _extensionsCreateMaterial;
  76691. private _extensionsLoadMaterialPropertiesAsync;
  76692. private _extensionsLoadTextureInfoAsync;
  76693. private _extensionsLoadTextureAsync;
  76694. private _extensionsLoadAnimationAsync;
  76695. private _extensionsLoadSkinAsync;
  76696. private _extensionsLoadUriAsync;
  76697. private _extensionsLoadBufferViewAsync;
  76698. private _extensionsLoadBufferAsync;
  76699. /**
  76700. * Helper method called by a loader extension to load an glTF extension.
  76701. * @param context The context when loading the asset
  76702. * @param property The glTF property to load the extension from
  76703. * @param extensionName The name of the extension to load
  76704. * @param actionAsync The action to run
  76705. * @returns The promise returned by actionAsync or null if the extension does not exist
  76706. */
  76707. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76708. /**
  76709. * Helper method called by a loader extension to load a glTF extra.
  76710. * @param context The context when loading the asset
  76711. * @param property The glTF property to load the extra from
  76712. * @param extensionName The name of the extension to load
  76713. * @param actionAsync The action to run
  76714. * @returns The promise returned by actionAsync or null if the extra does not exist
  76715. */
  76716. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76717. /**
  76718. * Checks for presence of an extension.
  76719. * @param name The name of the extension to check
  76720. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76721. */
  76722. isExtensionUsed(name: string): boolean;
  76723. /**
  76724. * Increments the indentation level and logs a message.
  76725. * @param message The message to log
  76726. */
  76727. logOpen(message: string): void;
  76728. /**
  76729. * Decrements the indentation level.
  76730. */
  76731. logClose(): void;
  76732. /**
  76733. * Logs a message
  76734. * @param message The message to log
  76735. */
  76736. log(message: string): void;
  76737. /**
  76738. * Starts a performance counter.
  76739. * @param counterName The name of the performance counter
  76740. */
  76741. startPerformanceCounter(counterName: string): void;
  76742. /**
  76743. * Ends a performance counter.
  76744. * @param counterName The name of the performance counter
  76745. */
  76746. endPerformanceCounter(counterName: string): void;
  76747. }
  76748. }
  76749. declare module BABYLON.GLTF2.Loader.Extensions {
  76750. /**
  76751. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76752. */
  76753. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76754. /**
  76755. * The name of this extension.
  76756. */
  76757. readonly name: string;
  76758. /**
  76759. * Defines whether this extension is enabled.
  76760. */
  76761. enabled: boolean;
  76762. private _loader;
  76763. private _lights?;
  76764. /** @hidden */
  76765. constructor(loader: GLTFLoader);
  76766. /** @hidden */
  76767. dispose(): void;
  76768. /** @hidden */
  76769. onLoading(): void;
  76770. /** @hidden */
  76771. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76772. private _loadLightAsync;
  76773. }
  76774. }
  76775. declare module BABYLON.GLTF2.Loader.Extensions {
  76776. /**
  76777. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76778. */
  76779. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76780. /**
  76781. * The name of this extension.
  76782. */
  76783. readonly name: string;
  76784. /**
  76785. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76786. */
  76787. dracoCompression?: DracoCompression;
  76788. /**
  76789. * Defines whether this extension is enabled.
  76790. */
  76791. enabled: boolean;
  76792. private _loader;
  76793. /** @hidden */
  76794. constructor(loader: GLTFLoader);
  76795. /** @hidden */
  76796. dispose(): void;
  76797. /** @hidden */
  76798. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76799. }
  76800. }
  76801. declare module BABYLON.GLTF2.Loader.Extensions {
  76802. /**
  76803. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76804. */
  76805. export class KHR_lights implements IGLTFLoaderExtension {
  76806. /**
  76807. * The name of this extension.
  76808. */
  76809. readonly name: string;
  76810. /**
  76811. * Defines whether this extension is enabled.
  76812. */
  76813. enabled: boolean;
  76814. private _loader;
  76815. private _lights?;
  76816. /** @hidden */
  76817. constructor(loader: GLTFLoader);
  76818. /** @hidden */
  76819. dispose(): void;
  76820. /** @hidden */
  76821. onLoading(): void;
  76822. /** @hidden */
  76823. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76824. }
  76825. }
  76826. declare module BABYLON.GLTF2.Loader.Extensions {
  76827. /**
  76828. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76829. */
  76830. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76831. /**
  76832. * The name of this extension.
  76833. */
  76834. readonly name: string;
  76835. /**
  76836. * Defines whether this extension is enabled.
  76837. */
  76838. enabled: boolean;
  76839. /**
  76840. * Defines a number that determines the order the extensions are applied.
  76841. */
  76842. order: number;
  76843. private _loader;
  76844. /** @hidden */
  76845. constructor(loader: GLTFLoader);
  76846. /** @hidden */
  76847. dispose(): void;
  76848. /** @hidden */
  76849. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76850. private _loadSpecularGlossinessPropertiesAsync;
  76851. }
  76852. }
  76853. declare module BABYLON.GLTF2.Loader.Extensions {
  76854. /**
  76855. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76856. */
  76857. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76858. /**
  76859. * The name of this extension.
  76860. */
  76861. readonly name: string;
  76862. /**
  76863. * Defines whether this extension is enabled.
  76864. */
  76865. enabled: boolean;
  76866. /**
  76867. * Defines a number that determines the order the extensions are applied.
  76868. */
  76869. order: number;
  76870. private _loader;
  76871. /** @hidden */
  76872. constructor(loader: GLTFLoader);
  76873. /** @hidden */
  76874. dispose(): void;
  76875. /** @hidden */
  76876. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76877. private _loadUnlitPropertiesAsync;
  76878. }
  76879. }
  76880. declare module BABYLON.GLTF2.Loader.Extensions {
  76881. /**
  76882. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76883. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76884. * !!! Experimental Extension Subject to Changes !!!
  76885. */
  76886. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76887. /**
  76888. * The name of this extension.
  76889. */
  76890. readonly name: string;
  76891. /**
  76892. * Defines whether this extension is enabled.
  76893. */
  76894. enabled: boolean;
  76895. /**
  76896. * Defines a number that determines the order the extensions are applied.
  76897. */
  76898. order: number;
  76899. private _loader;
  76900. /** @hidden */
  76901. constructor(loader: GLTFLoader);
  76902. /** @hidden */
  76903. dispose(): void;
  76904. /** @hidden */
  76905. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76906. private _loadClearCoatPropertiesAsync;
  76907. }
  76908. }
  76909. declare module BABYLON.GLTF2.Loader.Extensions {
  76910. /**
  76911. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76912. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76913. * !!! Experimental Extension Subject to Changes !!!
  76914. */
  76915. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76916. /**
  76917. * The name of this extension.
  76918. */
  76919. readonly name: string;
  76920. /**
  76921. * Defines whether this extension is enabled.
  76922. */
  76923. enabled: boolean;
  76924. /**
  76925. * Defines a number that determines the order the extensions are applied.
  76926. */
  76927. order: number;
  76928. private _loader;
  76929. /** @hidden */
  76930. constructor(loader: GLTFLoader);
  76931. /** @hidden */
  76932. dispose(): void;
  76933. /** @hidden */
  76934. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76935. private _loadSheenPropertiesAsync;
  76936. }
  76937. }
  76938. declare module BABYLON.GLTF2.Loader.Extensions {
  76939. /**
  76940. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76941. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76942. * !!! Experimental Extension Subject to Changes !!!
  76943. */
  76944. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76945. /**
  76946. * The name of this extension.
  76947. */
  76948. readonly name: string;
  76949. /**
  76950. * Defines whether this extension is enabled.
  76951. */
  76952. enabled: boolean;
  76953. /**
  76954. * Defines a number that determines the order the extensions are applied.
  76955. */
  76956. order: number;
  76957. private _loader;
  76958. /** @hidden */
  76959. constructor(loader: GLTFLoader);
  76960. /** @hidden */
  76961. dispose(): void;
  76962. /** @hidden */
  76963. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76964. private _loadSpecularPropertiesAsync;
  76965. }
  76966. }
  76967. declare module BABYLON.GLTF2.Loader.Extensions {
  76968. /**
  76969. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76970. * [Playground Sample](//TODO)
  76971. * !!! Experimental Extension Subject to Changes !!!
  76972. */
  76973. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76974. /**
  76975. * The name of this extension.
  76976. */
  76977. readonly name: string;
  76978. /**
  76979. * Defines whether this extension is enabled.
  76980. */
  76981. enabled: boolean;
  76982. private _loader;
  76983. /** @hidden */
  76984. constructor(loader: GLTFLoader);
  76985. /** @hidden */
  76986. dispose(): void;
  76987. /** @hidden */
  76988. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76989. }
  76990. }
  76991. declare module BABYLON.GLTF2.Loader.Extensions {
  76992. /**
  76993. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76994. */
  76995. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76996. /**
  76997. * The name of this extension.
  76998. */
  76999. readonly name: string;
  77000. /**
  77001. * Defines whether this extension is enabled.
  77002. */
  77003. enabled: boolean;
  77004. /** @hidden */
  77005. constructor(loader: GLTFLoader);
  77006. /** @hidden */
  77007. dispose(): void;
  77008. }
  77009. }
  77010. declare module BABYLON.GLTF2.Loader.Extensions {
  77011. /**
  77012. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77013. * !!! Experimental Extension Subject to Changes !!!
  77014. */
  77015. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77016. /** The name of this extension. */
  77017. readonly name: string;
  77018. /** Defines whether this extension is enabled. */
  77019. enabled: boolean;
  77020. private _loader;
  77021. /** @hidden */
  77022. constructor(loader: GLTFLoader);
  77023. /** @hidden */
  77024. dispose(): void;
  77025. /** @hidden */
  77026. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77027. }
  77028. }
  77029. declare module BABYLON.GLTF2.Loader.Extensions {
  77030. /**
  77031. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77032. */
  77033. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77034. /**
  77035. * The name of this extension.
  77036. */
  77037. readonly name: string;
  77038. /**
  77039. * Defines whether this extension is enabled.
  77040. */
  77041. enabled: boolean;
  77042. private _loader;
  77043. /** @hidden */
  77044. constructor(loader: GLTFLoader);
  77045. /** @hidden */
  77046. dispose(): void;
  77047. /** @hidden */
  77048. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77049. }
  77050. }
  77051. declare module BABYLON.GLTF2.Loader.Extensions {
  77052. /**
  77053. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77054. */
  77055. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77056. /**
  77057. * The name of this extension.
  77058. */
  77059. readonly name: string;
  77060. /**
  77061. * Defines whether this extension is enabled.
  77062. */
  77063. enabled: boolean;
  77064. private _loader;
  77065. private _clips;
  77066. private _emitters;
  77067. /** @hidden */
  77068. constructor(loader: GLTFLoader);
  77069. /** @hidden */
  77070. dispose(): void;
  77071. /** @hidden */
  77072. onLoading(): void;
  77073. /** @hidden */
  77074. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77075. /** @hidden */
  77076. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77077. /** @hidden */
  77078. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77079. private _loadClipAsync;
  77080. private _loadEmitterAsync;
  77081. private _getEventAction;
  77082. private _loadAnimationEventAsync;
  77083. }
  77084. }
  77085. declare module BABYLON.GLTF2.Loader.Extensions {
  77086. /**
  77087. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77088. */
  77089. export class MSFT_lod implements IGLTFLoaderExtension {
  77090. /**
  77091. * The name of this extension.
  77092. */
  77093. readonly name: string;
  77094. /**
  77095. * Defines whether this extension is enabled.
  77096. */
  77097. enabled: boolean;
  77098. /**
  77099. * Defines a number that determines the order the extensions are applied.
  77100. */
  77101. order: number;
  77102. /**
  77103. * Maximum number of LODs to load, starting from the lowest LOD.
  77104. */
  77105. maxLODsToLoad: number;
  77106. /**
  77107. * Observable raised when all node LODs of one level are loaded.
  77108. * The event data is the index of the loaded LOD starting from zero.
  77109. * Dispose the loader to cancel the loading of the next level of LODs.
  77110. */
  77111. onNodeLODsLoadedObservable: Observable<number>;
  77112. /**
  77113. * Observable raised when all material LODs of one level are loaded.
  77114. * The event data is the index of the loaded LOD starting from zero.
  77115. * Dispose the loader to cancel the loading of the next level of LODs.
  77116. */
  77117. onMaterialLODsLoadedObservable: Observable<number>;
  77118. private _loader;
  77119. private _nodeIndexLOD;
  77120. private _nodeSignalLODs;
  77121. private _nodePromiseLODs;
  77122. private _materialIndexLOD;
  77123. private _materialSignalLODs;
  77124. private _materialPromiseLODs;
  77125. private _indexLOD;
  77126. private _bufferLODs;
  77127. /** @hidden */
  77128. constructor(loader: GLTFLoader);
  77129. /** @hidden */
  77130. dispose(): void;
  77131. /** @hidden */
  77132. onReady(): void;
  77133. /** @hidden */
  77134. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77135. /** @hidden */
  77136. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77137. /** @hidden */
  77138. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77139. /** @hidden */
  77140. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77141. /** @hidden */
  77142. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77143. private _loadBufferLOD;
  77144. /**
  77145. * Gets an array of LOD properties from lowest to highest.
  77146. */
  77147. private _getLODs;
  77148. private _disposeTransformNode;
  77149. private _disposeMaterials;
  77150. }
  77151. }
  77152. declare module BABYLON.GLTF2.Loader.Extensions {
  77153. /** @hidden */
  77154. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77155. readonly name: string;
  77156. enabled: boolean;
  77157. private _loader;
  77158. constructor(loader: GLTFLoader);
  77159. dispose(): void;
  77160. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77161. }
  77162. }
  77163. declare module BABYLON.GLTF2.Loader.Extensions {
  77164. /** @hidden */
  77165. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77166. readonly name: string;
  77167. enabled: boolean;
  77168. private _loader;
  77169. constructor(loader: GLTFLoader);
  77170. dispose(): void;
  77171. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77172. }
  77173. }
  77174. declare module BABYLON.GLTF2.Loader.Extensions {
  77175. /**
  77176. * Store glTF extras (if present) in BJS objects' metadata
  77177. */
  77178. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77179. /**
  77180. * The name of this extension.
  77181. */
  77182. readonly name: string;
  77183. /**
  77184. * Defines whether this extension is enabled.
  77185. */
  77186. enabled: boolean;
  77187. private _loader;
  77188. private _assignExtras;
  77189. /** @hidden */
  77190. constructor(loader: GLTFLoader);
  77191. /** @hidden */
  77192. dispose(): void;
  77193. /** @hidden */
  77194. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77195. /** @hidden */
  77196. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77197. /** @hidden */
  77198. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77199. }
  77200. }
  77201. declare module BABYLON {
  77202. /**
  77203. * Class reading and parsing the MTL file bundled with the obj file.
  77204. */
  77205. export class MTLFileLoader {
  77206. /**
  77207. * Invert Y-Axis of referenced textures on load
  77208. */
  77209. static INVERT_TEXTURE_Y: boolean;
  77210. /**
  77211. * All material loaded from the mtl will be set here
  77212. */
  77213. materials: StandardMaterial[];
  77214. /**
  77215. * This function will read the mtl file and create each material described inside
  77216. * This function could be improve by adding :
  77217. * -some component missing (Ni, Tf...)
  77218. * -including the specific options available
  77219. *
  77220. * @param scene defines the scene the material will be created in
  77221. * @param data defines the mtl data to parse
  77222. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77223. * @param forAssetContainer defines if the material should be registered in the scene
  77224. */
  77225. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77226. /**
  77227. * Gets the texture for the material.
  77228. *
  77229. * If the material is imported from input file,
  77230. * We sanitize the url to ensure it takes the textre from aside the material.
  77231. *
  77232. * @param rootUrl The root url to load from
  77233. * @param value The value stored in the mtl
  77234. * @return The Texture
  77235. */
  77236. private static _getTexture;
  77237. }
  77238. }
  77239. declare module BABYLON {
  77240. /**
  77241. * Options for loading OBJ/MTL files
  77242. */
  77243. type MeshLoadOptions = {
  77244. /**
  77245. * Defines if UVs are optimized by default during load.
  77246. */
  77247. OptimizeWithUV: boolean;
  77248. /**
  77249. * Defines custom scaling of UV coordinates of loaded meshes.
  77250. */
  77251. UVScaling: Vector2;
  77252. /**
  77253. * Invert model on y-axis (does a model scaling inversion)
  77254. */
  77255. InvertY: boolean;
  77256. /**
  77257. * Invert Y-Axis of referenced textures on load
  77258. */
  77259. InvertTextureY: boolean;
  77260. /**
  77261. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77262. */
  77263. ImportVertexColors: boolean;
  77264. /**
  77265. * Compute the normals for the model, even if normals are present in the file.
  77266. */
  77267. ComputeNormals: boolean;
  77268. /**
  77269. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77270. */
  77271. SkipMaterials: boolean;
  77272. /**
  77273. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77274. */
  77275. MaterialLoadingFailsSilently: boolean;
  77276. };
  77277. /**
  77278. * OBJ file type loader.
  77279. * This is a babylon scene loader plugin.
  77280. */
  77281. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77282. /**
  77283. * Defines if UVs are optimized by default during load.
  77284. */
  77285. static OPTIMIZE_WITH_UV: boolean;
  77286. /**
  77287. * Invert model on y-axis (does a model scaling inversion)
  77288. */
  77289. static INVERT_Y: boolean;
  77290. /**
  77291. * Invert Y-Axis of referenced textures on load
  77292. */
  77293. static get INVERT_TEXTURE_Y(): boolean;
  77294. static set INVERT_TEXTURE_Y(value: boolean);
  77295. /**
  77296. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77297. */
  77298. static IMPORT_VERTEX_COLORS: boolean;
  77299. /**
  77300. * Compute the normals for the model, even if normals are present in the file.
  77301. */
  77302. static COMPUTE_NORMALS: boolean;
  77303. /**
  77304. * Defines custom scaling of UV coordinates of loaded meshes.
  77305. */
  77306. static UV_SCALING: Vector2;
  77307. /**
  77308. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77309. */
  77310. static SKIP_MATERIALS: boolean;
  77311. /**
  77312. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77313. *
  77314. * Defaults to true for backwards compatibility.
  77315. */
  77316. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77317. /**
  77318. * Defines the name of the plugin.
  77319. */
  77320. name: string;
  77321. /**
  77322. * Defines the extension the plugin is able to load.
  77323. */
  77324. extensions: string;
  77325. /** @hidden */
  77326. obj: RegExp;
  77327. /** @hidden */
  77328. group: RegExp;
  77329. /** @hidden */
  77330. mtllib: RegExp;
  77331. /** @hidden */
  77332. usemtl: RegExp;
  77333. /** @hidden */
  77334. smooth: RegExp;
  77335. /** @hidden */
  77336. vertexPattern: RegExp;
  77337. /** @hidden */
  77338. normalPattern: RegExp;
  77339. /** @hidden */
  77340. uvPattern: RegExp;
  77341. /** @hidden */
  77342. facePattern1: RegExp;
  77343. /** @hidden */
  77344. facePattern2: RegExp;
  77345. /** @hidden */
  77346. facePattern3: RegExp;
  77347. /** @hidden */
  77348. facePattern4: RegExp;
  77349. /** @hidden */
  77350. facePattern5: RegExp;
  77351. private _forAssetContainer;
  77352. private _meshLoadOptions;
  77353. /**
  77354. * Creates loader for .OBJ files
  77355. *
  77356. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77357. */
  77358. constructor(meshLoadOptions?: MeshLoadOptions);
  77359. private static get currentMeshLoadOptions();
  77360. /**
  77361. * Calls synchronously the MTL file attached to this obj.
  77362. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77363. * Without this function materials are not displayed in the first frame (but displayed after).
  77364. * In consequence it is impossible to get material information in your HTML file
  77365. *
  77366. * @param url The URL of the MTL file
  77367. * @param rootUrl
  77368. * @param onSuccess Callback function to be called when the MTL file is loaded
  77369. * @private
  77370. */
  77371. private _loadMTL;
  77372. /**
  77373. * Instantiates a OBJ file loader plugin.
  77374. * @returns the created plugin
  77375. */
  77376. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77377. /**
  77378. * If the data string can be loaded directly.
  77379. *
  77380. * @param data string containing the file data
  77381. * @returns if the data can be loaded directly
  77382. */
  77383. canDirectLoad(data: string): boolean;
  77384. /**
  77385. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77386. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77387. * @param scene the scene the meshes should be added to
  77388. * @param data the OBJ data to load
  77389. * @param rootUrl root url to load from
  77390. * @param onProgress event that fires when loading progress has occured
  77391. * @param fileName Defines the name of the file to load
  77392. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77393. */
  77394. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77395. meshes: AbstractMesh[];
  77396. particleSystems: IParticleSystem[];
  77397. skeletons: Skeleton[];
  77398. animationGroups: AnimationGroup[];
  77399. }>;
  77400. /**
  77401. * Imports all objects from the loaded OBJ data and adds them to the scene
  77402. * @param scene the scene the objects should be added to
  77403. * @param data the OBJ data to load
  77404. * @param rootUrl root url to load from
  77405. * @param onProgress event that fires when loading progress has occured
  77406. * @param fileName Defines the name of the file to load
  77407. * @returns a promise which completes when objects have been loaded to the scene
  77408. */
  77409. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77410. /**
  77411. * Load into an asset container.
  77412. * @param scene The scene to load into
  77413. * @param data The data to import
  77414. * @param rootUrl The root url for scene and resources
  77415. * @param onProgress The callback when the load progresses
  77416. * @param fileName Defines the name of the file to load
  77417. * @returns The loaded asset container
  77418. */
  77419. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77420. /**
  77421. * Read the OBJ file and create an Array of meshes.
  77422. * Each mesh contains all information given by the OBJ and the MTL file.
  77423. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77424. *
  77425. * @param meshesNames
  77426. * @param scene Scene The scene where are displayed the data
  77427. * @param data String The content of the obj file
  77428. * @param rootUrl String The path to the folder
  77429. * @returns Array<AbstractMesh>
  77430. * @private
  77431. */
  77432. private _parseSolid;
  77433. }
  77434. }
  77435. declare module BABYLON {
  77436. /**
  77437. * STL file type loader.
  77438. * This is a babylon scene loader plugin.
  77439. */
  77440. export class STLFileLoader implements ISceneLoaderPlugin {
  77441. /** @hidden */
  77442. solidPattern: RegExp;
  77443. /** @hidden */
  77444. facetsPattern: RegExp;
  77445. /** @hidden */
  77446. normalPattern: RegExp;
  77447. /** @hidden */
  77448. vertexPattern: RegExp;
  77449. /**
  77450. * Defines the name of the plugin.
  77451. */
  77452. name: string;
  77453. /**
  77454. * Defines the extensions the stl loader is able to load.
  77455. * force data to come in as an ArrayBuffer
  77456. * we'll convert to string if it looks like it's an ASCII .stl
  77457. */
  77458. extensions: ISceneLoaderPluginExtensions;
  77459. /**
  77460. * Import meshes into a scene.
  77461. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77462. * @param scene The scene to import into
  77463. * @param data The data to import
  77464. * @param rootUrl The root url for scene and resources
  77465. * @param meshes The meshes array to import into
  77466. * @param particleSystems The particle systems array to import into
  77467. * @param skeletons The skeletons array to import into
  77468. * @param onError The callback when import fails
  77469. * @returns True if successful or false otherwise
  77470. */
  77471. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77472. /**
  77473. * Load into a scene.
  77474. * @param scene The scene to load into
  77475. * @param data The data to import
  77476. * @param rootUrl The root url for scene and resources
  77477. * @param onError The callback when import fails
  77478. * @returns true if successful or false otherwise
  77479. */
  77480. load(scene: Scene, data: any, rootUrl: string): boolean;
  77481. /**
  77482. * Load into an asset container.
  77483. * @param scene The scene to load into
  77484. * @param data The data to import
  77485. * @param rootUrl The root url for scene and resources
  77486. * @param onError The callback when import fails
  77487. * @returns The loaded asset container
  77488. */
  77489. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77490. private _isBinary;
  77491. private _parseBinary;
  77492. private _parseASCII;
  77493. }
  77494. }
  77495. declare module BABYLON {
  77496. /**
  77497. * Class for generating OBJ data from a Babylon scene.
  77498. */
  77499. export class OBJExport {
  77500. /**
  77501. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77502. * @param mesh defines the list of meshes to serialize
  77503. * @param materials defines if materials should be exported
  77504. * @param matlibname defines the name of the associated mtl file
  77505. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77506. * @returns the OBJ content
  77507. */
  77508. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77509. /**
  77510. * Exports the material(s) of a mesh in .MTL file format (text)
  77511. * @param mesh defines the mesh to extract the material from
  77512. * @returns the mtl content
  77513. */
  77514. static MTL(mesh: Mesh): string;
  77515. }
  77516. }
  77517. declare module BABYLON {
  77518. /** @hidden */
  77519. export var __IGLTFExporterExtension: number;
  77520. /**
  77521. * Interface for extending the exporter
  77522. * @hidden
  77523. */
  77524. export interface IGLTFExporterExtension {
  77525. /**
  77526. * The name of this extension
  77527. */
  77528. readonly name: string;
  77529. /**
  77530. * Defines whether this extension is enabled
  77531. */
  77532. enabled: boolean;
  77533. /**
  77534. * Defines whether this extension is required
  77535. */
  77536. required: boolean;
  77537. }
  77538. }
  77539. declare module BABYLON.GLTF2.Exporter {
  77540. /** @hidden */
  77541. export var __IGLTFExporterExtensionV2: number;
  77542. /**
  77543. * Interface for a glTF exporter extension
  77544. * @hidden
  77545. */
  77546. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77547. /**
  77548. * Define this method to modify the default behavior before exporting a texture
  77549. * @param context The context when loading the asset
  77550. * @param babylonTexture The Babylon.js texture
  77551. * @param mimeType The mime-type of the generated image
  77552. * @returns A promise that resolves with the exported texture
  77553. */
  77554. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77555. /**
  77556. * Define this method to get notified when a texture info is created
  77557. * @param context The context when loading the asset
  77558. * @param textureInfo The glTF texture info
  77559. * @param babylonTexture The Babylon.js texture
  77560. */
  77561. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77562. /**
  77563. * Define this method to modify the default behavior when exporting texture info
  77564. * @param context The context when loading the asset
  77565. * @param meshPrimitive glTF mesh primitive
  77566. * @param babylonSubMesh Babylon submesh
  77567. * @param binaryWriter glTF serializer binary writer instance
  77568. * @returns nullable IMeshPrimitive promise
  77569. */
  77570. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77571. /**
  77572. * Define this method to modify the default behavior when exporting a node
  77573. * @param context The context when exporting the node
  77574. * @param node glTF node
  77575. * @param babylonNode BabylonJS node
  77576. * @returns nullable INode promise
  77577. */
  77578. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77579. [key: number]: number;
  77580. }): Promise<Nullable<INode>>;
  77581. /**
  77582. * Define this method to modify the default behavior when exporting a material
  77583. * @param material glTF material
  77584. * @param babylonMaterial BabylonJS material
  77585. * @returns nullable IMaterial promise
  77586. */
  77587. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77588. /**
  77589. * Define this method to return additional textures to export from a material
  77590. * @param material glTF material
  77591. * @param babylonMaterial BabylonJS material
  77592. * @returns List of textures
  77593. */
  77594. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77595. /** Gets a boolean indicating that this extension was used */
  77596. wasUsed: boolean;
  77597. /** Gets a boolean indicating that this extension is required for the file to work */
  77598. required: boolean;
  77599. /**
  77600. * Called after the exporter state changes to EXPORTING
  77601. */
  77602. onExporting?(): void;
  77603. }
  77604. }
  77605. declare module BABYLON.GLTF2.Exporter {
  77606. /**
  77607. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77608. * @hidden
  77609. */
  77610. export class _GLTFMaterialExporter {
  77611. /**
  77612. * Represents the dielectric specular values for R, G and B
  77613. */
  77614. private static readonly _DielectricSpecular;
  77615. /**
  77616. * Allows the maximum specular power to be defined for material calculations
  77617. */
  77618. private static readonly _MaxSpecularPower;
  77619. /**
  77620. * Mapping to store textures
  77621. */
  77622. private _textureMap;
  77623. /**
  77624. * Numeric tolerance value
  77625. */
  77626. private static readonly _Epsilon;
  77627. /**
  77628. * Reference to the glTF Exporter
  77629. */
  77630. private _exporter;
  77631. constructor(exporter: _Exporter);
  77632. /**
  77633. * Specifies if two colors are approximately equal in value
  77634. * @param color1 first color to compare to
  77635. * @param color2 second color to compare to
  77636. * @param epsilon threshold value
  77637. */
  77638. private static FuzzyEquals;
  77639. /**
  77640. * Gets the materials from a Babylon scene and converts them to glTF materials
  77641. * @param scene babylonjs scene
  77642. * @param mimeType texture mime type
  77643. * @param images array of images
  77644. * @param textures array of textures
  77645. * @param materials array of materials
  77646. * @param imageData mapping of texture names to base64 textures
  77647. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77648. */
  77649. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77650. /**
  77651. * Makes a copy of the glTF material without the texture parameters
  77652. * @param originalMaterial original glTF material
  77653. * @returns glTF material without texture parameters
  77654. */
  77655. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77656. /**
  77657. * Specifies if the material has any texture parameters present
  77658. * @param material glTF Material
  77659. * @returns boolean specifying if texture parameters are present
  77660. */
  77661. _hasTexturesPresent(material: IMaterial): boolean;
  77662. /**
  77663. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77664. * @param babylonStandardMaterial
  77665. * @returns glTF Metallic Roughness Material representation
  77666. */
  77667. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77668. /**
  77669. * Computes the metallic factor
  77670. * @param diffuse diffused value
  77671. * @param specular specular value
  77672. * @param oneMinusSpecularStrength one minus the specular strength
  77673. * @returns metallic value
  77674. */
  77675. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77676. /**
  77677. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77678. * @param glTFMaterial glTF material
  77679. * @param babylonMaterial Babylon material
  77680. */
  77681. private static _SetAlphaMode;
  77682. /**
  77683. * Converts a Babylon Standard Material to a glTF Material
  77684. * @param babylonStandardMaterial BJS Standard Material
  77685. * @param mimeType mime type to use for the textures
  77686. * @param images array of glTF image interfaces
  77687. * @param textures array of glTF texture interfaces
  77688. * @param materials array of glTF material interfaces
  77689. * @param imageData map of image file name to data
  77690. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77691. */
  77692. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77693. private _finishMaterial;
  77694. /**
  77695. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77696. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77697. * @param mimeType mime type to use for the textures
  77698. * @param images array of glTF image interfaces
  77699. * @param textures array of glTF texture interfaces
  77700. * @param materials array of glTF material interfaces
  77701. * @param imageData map of image file name to data
  77702. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77703. */
  77704. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77705. /**
  77706. * Converts an image typed array buffer to a base64 image
  77707. * @param buffer typed array buffer
  77708. * @param width width of the image
  77709. * @param height height of the image
  77710. * @param mimeType mimetype of the image
  77711. * @returns base64 image string
  77712. */
  77713. private _createBase64FromCanvasAsync;
  77714. /**
  77715. * Generates a white texture based on the specified width and height
  77716. * @param width width of the texture in pixels
  77717. * @param height height of the texture in pixels
  77718. * @param scene babylonjs scene
  77719. * @returns white texture
  77720. */
  77721. private _createWhiteTexture;
  77722. /**
  77723. * 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
  77724. * @param texture1 first texture to resize
  77725. * @param texture2 second texture to resize
  77726. * @param scene babylonjs scene
  77727. * @returns resized textures or null
  77728. */
  77729. private _resizeTexturesToSameDimensions;
  77730. /**
  77731. * Converts an array of pixels to a Float32Array
  77732. * Throws an error if the pixel format is not supported
  77733. * @param pixels - array buffer containing pixel values
  77734. * @returns Float32 of pixels
  77735. */
  77736. private _convertPixelArrayToFloat32;
  77737. /**
  77738. * Convert Specular Glossiness Textures to Metallic Roughness
  77739. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77740. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77741. * @param diffuseTexture texture used to store diffuse information
  77742. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77743. * @param factors specular glossiness material factors
  77744. * @param mimeType the mime type to use for the texture
  77745. * @returns pbr metallic roughness interface or null
  77746. */
  77747. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77748. /**
  77749. * Converts specular glossiness material properties to metallic roughness
  77750. * @param specularGlossiness interface with specular glossiness material properties
  77751. * @returns interface with metallic roughness material properties
  77752. */
  77753. private _convertSpecularGlossinessToMetallicRoughness;
  77754. /**
  77755. * Calculates the surface reflectance, independent of lighting conditions
  77756. * @param color Color source to calculate brightness from
  77757. * @returns number representing the perceived brightness, or zero if color is undefined
  77758. */
  77759. private _getPerceivedBrightness;
  77760. /**
  77761. * Returns the maximum color component value
  77762. * @param color
  77763. * @returns maximum color component value, or zero if color is null or undefined
  77764. */
  77765. private _getMaxComponent;
  77766. /**
  77767. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77768. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77769. * @param mimeType mime type to use for the textures
  77770. * @param images array of glTF image interfaces
  77771. * @param textures array of glTF texture interfaces
  77772. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77773. * @param imageData map of image file name to data
  77774. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77775. * @returns glTF PBR Metallic Roughness factors
  77776. */
  77777. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77778. private _getGLTFTextureSampler;
  77779. private _getGLTFTextureWrapMode;
  77780. private _getGLTFTextureWrapModesSampler;
  77781. /**
  77782. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77783. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77784. * @param mimeType mime type to use for the textures
  77785. * @param images array of glTF image interfaces
  77786. * @param textures array of glTF texture interfaces
  77787. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77788. * @param imageData map of image file name to data
  77789. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77790. * @returns glTF PBR Metallic Roughness factors
  77791. */
  77792. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77793. /**
  77794. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77795. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77796. * @param mimeType mime type to use for the textures
  77797. * @param images array of glTF image interfaces
  77798. * @param textures array of glTF texture interfaces
  77799. * @param materials array of glTF material interfaces
  77800. * @param imageData map of image file name to data
  77801. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77802. */
  77803. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77804. private setMetallicRoughnessPbrMaterial;
  77805. private getPixelsFromTexture;
  77806. /**
  77807. * Extracts a texture from a Babylon texture into file data and glTF data
  77808. * @param babylonTexture Babylon texture to extract
  77809. * @param mimeType Mime Type of the babylonTexture
  77810. * @return glTF texture info, or null if the texture format is not supported
  77811. */
  77812. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77813. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77814. /**
  77815. * Builds a texture from base64 string
  77816. * @param base64Texture base64 texture string
  77817. * @param baseTextureName Name to use for the texture
  77818. * @param mimeType image mime type for the texture
  77819. * @param images array of images
  77820. * @param textures array of textures
  77821. * @param imageData map of image data
  77822. * @returns glTF texture info, or null if the texture format is not supported
  77823. */
  77824. private _getTextureInfoFromBase64;
  77825. }
  77826. }
  77827. declare module BABYLON {
  77828. /**
  77829. * Class for holding and downloading glTF file data
  77830. */
  77831. export class GLTFData {
  77832. /**
  77833. * Object which contains the file name as the key and its data as the value
  77834. */
  77835. glTFFiles: {
  77836. [fileName: string]: string | Blob;
  77837. };
  77838. /**
  77839. * Initializes the glTF file object
  77840. */
  77841. constructor();
  77842. /**
  77843. * Downloads the glTF data as files based on their names and data
  77844. */
  77845. downloadFiles(): void;
  77846. }
  77847. }
  77848. declare module BABYLON {
  77849. /**
  77850. * Holds a collection of exporter options and parameters
  77851. */
  77852. export interface IExportOptions {
  77853. /**
  77854. * Function which indicates whether a babylon node should be exported or not
  77855. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77856. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77857. */
  77858. shouldExportNode?(node: Node): boolean;
  77859. /**
  77860. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77861. * @param metadata source metadata to read from
  77862. * @returns the data to store to glTF node extras
  77863. */
  77864. metadataSelector?(metadata: any): any;
  77865. /**
  77866. * The sample rate to bake animation curves
  77867. */
  77868. animationSampleRate?: number;
  77869. /**
  77870. * Begin serialization without waiting for the scene to be ready
  77871. */
  77872. exportWithoutWaitingForScene?: boolean;
  77873. /**
  77874. * Indicates if coordinate system swapping root nodes should be included in export
  77875. */
  77876. includeCoordinateSystemConversionNodes?: boolean;
  77877. }
  77878. /**
  77879. * Class for generating glTF data from a Babylon scene.
  77880. */
  77881. export class GLTF2Export {
  77882. /**
  77883. * Exports the geometry of the scene to .gltf file format asynchronously
  77884. * @param scene Babylon scene with scene hierarchy information
  77885. * @param filePrefix File prefix to use when generating the glTF file
  77886. * @param options Exporter options
  77887. * @returns Returns an object with a .gltf file and associates texture names
  77888. * as keys and their data and paths as values
  77889. */
  77890. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77891. private static _PreExportAsync;
  77892. private static _PostExportAsync;
  77893. /**
  77894. * Exports the geometry of the scene to .glb file format asychronously
  77895. * @param scene Babylon scene with scene hierarchy information
  77896. * @param filePrefix File prefix to use when generating glb file
  77897. * @param options Exporter options
  77898. * @returns Returns an object with a .glb filename as key and data as value
  77899. */
  77900. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77901. }
  77902. }
  77903. declare module BABYLON.GLTF2.Exporter {
  77904. /**
  77905. * @hidden
  77906. */
  77907. export class _GLTFUtilities {
  77908. /**
  77909. * Creates a buffer view based on the supplied arguments
  77910. * @param bufferIndex index value of the specified buffer
  77911. * @param byteOffset byte offset value
  77912. * @param byteLength byte length of the bufferView
  77913. * @param byteStride byte distance between conequential elements
  77914. * @param name name of the buffer view
  77915. * @returns bufferView for glTF
  77916. */
  77917. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77918. /**
  77919. * Creates an accessor based on the supplied arguments
  77920. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77921. * @param name The name of the accessor
  77922. * @param type The type of the accessor
  77923. * @param componentType The datatype of components in the attribute
  77924. * @param count The number of attributes referenced by this accessor
  77925. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77926. * @param min Minimum value of each component in this attribute
  77927. * @param max Maximum value of each component in this attribute
  77928. * @returns accessor for glTF
  77929. */
  77930. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77931. /**
  77932. * Calculates the minimum and maximum values of an array of position floats
  77933. * @param positions Positions array of a mesh
  77934. * @param vertexStart Starting vertex offset to calculate min and max values
  77935. * @param vertexCount Number of vertices to check for min and max values
  77936. * @returns min number array and max number array
  77937. */
  77938. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77939. min: number[];
  77940. max: number[];
  77941. };
  77942. /**
  77943. * Converts a new right-handed Vector3
  77944. * @param vector vector3 array
  77945. * @returns right-handed Vector3
  77946. */
  77947. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77948. /**
  77949. * Converts a Vector3 to right-handed
  77950. * @param vector Vector3 to convert to right-handed
  77951. */
  77952. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77953. /**
  77954. * Converts a three element number array to right-handed
  77955. * @param vector number array to convert to right-handed
  77956. */
  77957. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77958. /**
  77959. * Converts a new right-handed Vector3
  77960. * @param vector vector3 array
  77961. * @returns right-handed Vector3
  77962. */
  77963. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77964. /**
  77965. * Converts a Vector3 to right-handed
  77966. * @param vector Vector3 to convert to right-handed
  77967. */
  77968. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77969. /**
  77970. * Converts a three element number array to right-handed
  77971. * @param vector number array to convert to right-handed
  77972. */
  77973. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77974. /**
  77975. * Converts a Vector4 to right-handed
  77976. * @param vector Vector4 to convert to right-handed
  77977. */
  77978. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77979. /**
  77980. * Converts a Vector4 to right-handed
  77981. * @param vector Vector4 to convert to right-handed
  77982. */
  77983. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77984. /**
  77985. * Converts a Quaternion to right-handed
  77986. * @param quaternion Source quaternion to convert to right-handed
  77987. */
  77988. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77989. /**
  77990. * Converts a Quaternion to right-handed
  77991. * @param quaternion Source quaternion to convert to right-handed
  77992. */
  77993. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77994. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77995. }
  77996. }
  77997. declare module BABYLON.GLTF2.Exporter {
  77998. /**
  77999. * Converts Babylon Scene into glTF 2.0.
  78000. * @hidden
  78001. */
  78002. export class _Exporter {
  78003. /**
  78004. * Stores the glTF to export
  78005. */
  78006. _glTF: IGLTF;
  78007. /**
  78008. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78009. */
  78010. _bufferViews: IBufferView[];
  78011. /**
  78012. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78013. */
  78014. _accessors: IAccessor[];
  78015. /**
  78016. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78017. */
  78018. _nodes: INode[];
  78019. /**
  78020. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78021. */
  78022. private _scenes;
  78023. /**
  78024. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78025. */
  78026. private _meshes;
  78027. /**
  78028. * Stores all the generated material information, which represents the appearance of each primitive
  78029. */
  78030. _materials: IMaterial[];
  78031. _materialMap: {
  78032. [materialID: number]: number;
  78033. };
  78034. /**
  78035. * Stores all the generated texture information, which is referenced by glTF materials
  78036. */
  78037. _textures: ITexture[];
  78038. /**
  78039. * Stores all the generated image information, which is referenced by glTF textures
  78040. */
  78041. _images: IImage[];
  78042. /**
  78043. * Stores all the texture samplers
  78044. */
  78045. _samplers: ISampler[];
  78046. /**
  78047. * Stores all the generated animation samplers, which is referenced by glTF animations
  78048. */
  78049. /**
  78050. * Stores the animations for glTF models
  78051. */
  78052. private _animations;
  78053. /**
  78054. * Stores the total amount of bytes stored in the glTF buffer
  78055. */
  78056. private _totalByteLength;
  78057. /**
  78058. * Stores a reference to the Babylon scene containing the source geometry and material information
  78059. */
  78060. _babylonScene: Scene;
  78061. /**
  78062. * Stores a map of the image data, where the key is the file name and the value
  78063. * is the image data
  78064. */
  78065. _imageData: {
  78066. [fileName: string]: {
  78067. data: Uint8Array;
  78068. mimeType: ImageMimeType;
  78069. };
  78070. };
  78071. /**
  78072. * Stores a map of the unique id of a node to its index in the node array
  78073. */
  78074. _nodeMap: {
  78075. [key: number]: number;
  78076. };
  78077. /**
  78078. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78079. */
  78080. _convertToRightHandedSystem: boolean;
  78081. /**
  78082. * Specifies if a Babylon node should be converted to right-handed on export
  78083. */
  78084. _convertToRightHandedSystemMap: {
  78085. [nodeId: number]: boolean;
  78086. };
  78087. _includeCoordinateSystemConversionNodes: boolean;
  78088. /**
  78089. * Baked animation sample rate
  78090. */
  78091. private _animationSampleRate;
  78092. private _options;
  78093. private _localEngine;
  78094. _glTFMaterialExporter: _GLTFMaterialExporter;
  78095. private _extensions;
  78096. private static _ExtensionNames;
  78097. private static _ExtensionFactories;
  78098. private _applyExtension;
  78099. private _applyExtensions;
  78100. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78101. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78102. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78103. [key: number]: number;
  78104. }): Promise<Nullable<INode>>;
  78105. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78106. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78107. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78108. private _forEachExtensions;
  78109. private _extensionsOnExporting;
  78110. /**
  78111. * Load glTF serializer extensions
  78112. */
  78113. private _loadExtensions;
  78114. /**
  78115. * Creates a glTF Exporter instance, which can accept optional exporter options
  78116. * @param babylonScene Babylon scene object
  78117. * @param options Options to modify the behavior of the exporter
  78118. */
  78119. constructor(babylonScene: Scene, options?: IExportOptions);
  78120. dispose(): void;
  78121. /**
  78122. * Registers a glTF exporter extension
  78123. * @param name Name of the extension to export
  78124. * @param factory The factory function that creates the exporter extension
  78125. */
  78126. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78127. /**
  78128. * Un-registers an exporter extension
  78129. * @param name The name fo the exporter extension
  78130. * @returns A boolean indicating whether the extension has been un-registered
  78131. */
  78132. static UnregisterExtension(name: string): boolean;
  78133. /**
  78134. * Lazy load a local engine
  78135. */
  78136. _getLocalEngine(): Engine;
  78137. private reorderIndicesBasedOnPrimitiveMode;
  78138. /**
  78139. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78140. * clock-wise during export to glTF
  78141. * @param submesh BabylonJS submesh
  78142. * @param primitiveMode Primitive mode of the mesh
  78143. * @param sideOrientation the winding order of the submesh
  78144. * @param vertexBufferKind The type of vertex attribute
  78145. * @param meshAttributeArray The vertex attribute data
  78146. * @param byteOffset The offset to the binary data
  78147. * @param binaryWriter The binary data for the glTF file
  78148. * @param convertToRightHandedSystem Converts the values to right-handed
  78149. */
  78150. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78151. /**
  78152. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78153. * clock-wise during export to glTF
  78154. * @param submesh BabylonJS submesh
  78155. * @param primitiveMode Primitive mode of the mesh
  78156. * @param sideOrientation the winding order of the submesh
  78157. * @param vertexBufferKind The type of vertex attribute
  78158. * @param meshAttributeArray The vertex attribute data
  78159. * @param byteOffset The offset to the binary data
  78160. * @param binaryWriter The binary data for the glTF file
  78161. * @param convertToRightHandedSystem Converts the values to right-handed
  78162. */
  78163. private reorderTriangleFillMode;
  78164. /**
  78165. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78166. * clock-wise during export to glTF
  78167. * @param submesh BabylonJS submesh
  78168. * @param primitiveMode Primitive mode of the mesh
  78169. * @param sideOrientation the winding order of the submesh
  78170. * @param vertexBufferKind The type of vertex attribute
  78171. * @param meshAttributeArray The vertex attribute data
  78172. * @param byteOffset The offset to the binary data
  78173. * @param binaryWriter The binary data for the glTF file
  78174. * @param convertToRightHandedSystem Converts the values to right-handed
  78175. */
  78176. private reorderTriangleStripDrawMode;
  78177. /**
  78178. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78179. * clock-wise during export to glTF
  78180. * @param submesh BabylonJS submesh
  78181. * @param primitiveMode Primitive mode of the mesh
  78182. * @param sideOrientation the winding order of the submesh
  78183. * @param vertexBufferKind The type of vertex attribute
  78184. * @param meshAttributeArray The vertex attribute data
  78185. * @param byteOffset The offset to the binary data
  78186. * @param binaryWriter The binary data for the glTF file
  78187. * @param convertToRightHandedSystem Converts the values to right-handed
  78188. */
  78189. private reorderTriangleFanMode;
  78190. /**
  78191. * Writes the vertex attribute data to binary
  78192. * @param vertices The vertices to write to the binary writer
  78193. * @param byteOffset The offset into the binary writer to overwrite binary data
  78194. * @param vertexAttributeKind The vertex attribute type
  78195. * @param meshAttributeArray The vertex attribute data
  78196. * @param binaryWriter The writer containing the binary data
  78197. * @param convertToRightHandedSystem Converts the values to right-handed
  78198. */
  78199. private writeVertexAttributeData;
  78200. /**
  78201. * Writes mesh attribute data to a data buffer
  78202. * Returns the bytelength of the data
  78203. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78204. * @param meshAttributeArray Array containing the attribute data
  78205. * @param binaryWriter The buffer to write the binary data to
  78206. * @param indices Used to specify the order of the vertex data
  78207. * @param convertToRightHandedSystem Converts the values to right-handed
  78208. */
  78209. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78210. /**
  78211. * Generates glTF json data
  78212. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78213. * @param glTFPrefix Text to use when prefixing a glTF file
  78214. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78215. * @returns json data as string
  78216. */
  78217. private generateJSON;
  78218. /**
  78219. * Generates data for .gltf and .bin files based on the glTF prefix string
  78220. * @param glTFPrefix Text to use when prefixing a glTF file
  78221. * @param dispose Dispose the exporter
  78222. * @returns GLTFData with glTF file data
  78223. */
  78224. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78225. /**
  78226. * Creates a binary buffer for glTF
  78227. * @returns array buffer for binary data
  78228. */
  78229. private _generateBinaryAsync;
  78230. /**
  78231. * Pads the number to a multiple of 4
  78232. * @param num number to pad
  78233. * @returns padded number
  78234. */
  78235. private _getPadding;
  78236. /**
  78237. * @hidden
  78238. */
  78239. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78240. /**
  78241. * Sets the TRS for each node
  78242. * @param node glTF Node for storing the transformation data
  78243. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78244. * @param convertToRightHandedSystem Converts the values to right-handed
  78245. */
  78246. private setNodeTransformation;
  78247. private getVertexBufferFromMesh;
  78248. /**
  78249. * Creates a bufferview based on the vertices type for the Babylon mesh
  78250. * @param kind Indicates the type of vertices data
  78251. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78252. * @param binaryWriter The buffer to write the bufferview data to
  78253. * @param convertToRightHandedSystem Converts the values to right-handed
  78254. */
  78255. private createBufferViewKind;
  78256. /**
  78257. * The primitive mode of the Babylon mesh
  78258. * @param babylonMesh The BabylonJS mesh
  78259. */
  78260. private getMeshPrimitiveMode;
  78261. /**
  78262. * Sets the primitive mode of the glTF mesh primitive
  78263. * @param meshPrimitive glTF mesh primitive
  78264. * @param primitiveMode The primitive mode
  78265. */
  78266. private setPrimitiveMode;
  78267. /**
  78268. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78269. * @param meshPrimitive glTF mesh primitive
  78270. * @param attributeKind vertex attribute
  78271. * @returns boolean specifying if uv coordinates are present
  78272. */
  78273. private setAttributeKind;
  78274. /**
  78275. * Sets data for the primitive attributes of each submesh
  78276. * @param mesh glTF Mesh object to store the primitive attribute information
  78277. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78278. * @param binaryWriter Buffer to write the attribute data to
  78279. * @param convertToRightHandedSystem Converts the values to right-handed
  78280. */
  78281. private setPrimitiveAttributesAsync;
  78282. /**
  78283. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78284. * @param node The node to check
  78285. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78286. */
  78287. private isBabylonCoordinateSystemConvertingNode;
  78288. /**
  78289. * Creates a glTF scene based on the array of meshes
  78290. * Returns the the total byte offset
  78291. * @param babylonScene Babylon scene to get the mesh data from
  78292. * @param binaryWriter Buffer to write binary data to
  78293. */
  78294. private createSceneAsync;
  78295. /**
  78296. * Creates a mapping of Node unique id to node index and handles animations
  78297. * @param babylonScene Babylon Scene
  78298. * @param nodes Babylon transform nodes
  78299. * @param binaryWriter Buffer to write binary data to
  78300. * @returns Node mapping of unique id to index
  78301. */
  78302. private createNodeMapAndAnimationsAsync;
  78303. /**
  78304. * Creates a glTF node from a Babylon mesh
  78305. * @param babylonMesh Source Babylon mesh
  78306. * @param binaryWriter Buffer for storing geometry data
  78307. * @param convertToRightHandedSystem Converts the values to right-handed
  78308. * @param nodeMap Node mapping of unique id to glTF node index
  78309. * @returns glTF node
  78310. */
  78311. private createNodeAsync;
  78312. }
  78313. /**
  78314. * @hidden
  78315. *
  78316. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78317. */
  78318. export class _BinaryWriter {
  78319. /**
  78320. * Array buffer which stores all binary data
  78321. */
  78322. private _arrayBuffer;
  78323. /**
  78324. * View of the array buffer
  78325. */
  78326. private _dataView;
  78327. /**
  78328. * byte offset of data in array buffer
  78329. */
  78330. private _byteOffset;
  78331. /**
  78332. * Initialize binary writer with an initial byte length
  78333. * @param byteLength Initial byte length of the array buffer
  78334. */
  78335. constructor(byteLength: number);
  78336. /**
  78337. * Resize the array buffer to the specified byte length
  78338. * @param byteLength
  78339. */
  78340. private resizeBuffer;
  78341. /**
  78342. * Get an array buffer with the length of the byte offset
  78343. * @returns ArrayBuffer resized to the byte offset
  78344. */
  78345. getArrayBuffer(): ArrayBuffer;
  78346. /**
  78347. * Get the byte offset of the array buffer
  78348. * @returns byte offset
  78349. */
  78350. getByteOffset(): number;
  78351. /**
  78352. * Stores an UInt8 in the array buffer
  78353. * @param entry
  78354. * @param byteOffset If defined, specifies where to set the value as an offset.
  78355. */
  78356. setUInt8(entry: number, byteOffset?: number): void;
  78357. /**
  78358. * Gets an UInt32 in the array buffer
  78359. * @param entry
  78360. * @param byteOffset If defined, specifies where to set the value as an offset.
  78361. */
  78362. getUInt32(byteOffset: number): number;
  78363. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78364. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78365. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78366. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78367. /**
  78368. * Stores a Float32 in the array buffer
  78369. * @param entry
  78370. */
  78371. setFloat32(entry: number, byteOffset?: number): void;
  78372. /**
  78373. * Stores an UInt32 in the array buffer
  78374. * @param entry
  78375. * @param byteOffset If defined, specifies where to set the value as an offset.
  78376. */
  78377. setUInt32(entry: number, byteOffset?: number): void;
  78378. }
  78379. }
  78380. declare module BABYLON.GLTF2.Exporter {
  78381. /**
  78382. * @hidden
  78383. * Interface to store animation data.
  78384. */
  78385. export interface _IAnimationData {
  78386. /**
  78387. * Keyframe data.
  78388. */
  78389. inputs: number[];
  78390. /**
  78391. * Value data.
  78392. */
  78393. outputs: number[][];
  78394. /**
  78395. * Animation interpolation data.
  78396. */
  78397. samplerInterpolation: AnimationSamplerInterpolation;
  78398. /**
  78399. * Minimum keyframe value.
  78400. */
  78401. inputsMin: number;
  78402. /**
  78403. * Maximum keyframe value.
  78404. */
  78405. inputsMax: number;
  78406. }
  78407. /**
  78408. * @hidden
  78409. */
  78410. export interface _IAnimationInfo {
  78411. /**
  78412. * The target channel for the animation
  78413. */
  78414. animationChannelTargetPath: AnimationChannelTargetPath;
  78415. /**
  78416. * The glTF accessor type for the data.
  78417. */
  78418. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78419. /**
  78420. * Specifies if quaternions should be used.
  78421. */
  78422. useQuaternion: boolean;
  78423. }
  78424. /**
  78425. * @hidden
  78426. * Utility class for generating glTF animation data from BabylonJS.
  78427. */
  78428. export class _GLTFAnimation {
  78429. /**
  78430. * @ignore
  78431. *
  78432. * Creates glTF channel animation from BabylonJS animation.
  78433. * @param babylonTransformNode - BabylonJS mesh.
  78434. * @param animation - animation.
  78435. * @param animationChannelTargetPath - The target animation channel.
  78436. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78437. * @param useQuaternion - Specifies if quaternions are used.
  78438. * @returns nullable IAnimationData
  78439. */
  78440. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78441. private static _DeduceAnimationInfo;
  78442. /**
  78443. * @ignore
  78444. * Create node animations from the transform node animations
  78445. * @param babylonNode
  78446. * @param runtimeGLTFAnimation
  78447. * @param idleGLTFAnimations
  78448. * @param nodeMap
  78449. * @param nodes
  78450. * @param binaryWriter
  78451. * @param bufferViews
  78452. * @param accessors
  78453. * @param convertToRightHandedSystem
  78454. * @param animationSampleRate
  78455. */
  78456. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78457. [key: number]: number;
  78458. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78459. /**
  78460. * @ignore
  78461. * Create node animations from the animation groups
  78462. * @param babylonScene
  78463. * @param glTFAnimations
  78464. * @param nodeMap
  78465. * @param nodes
  78466. * @param binaryWriter
  78467. * @param bufferViews
  78468. * @param accessors
  78469. * @param convertToRightHandedSystemMap
  78470. * @param animationSampleRate
  78471. */
  78472. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78473. [key: number]: number;
  78474. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78475. [nodeId: number]: boolean;
  78476. }, animationSampleRate: number): void;
  78477. private static AddAnimation;
  78478. /**
  78479. * Create a baked animation
  78480. * @param babylonTransformNode BabylonJS mesh
  78481. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78482. * @param animationChannelTargetPath animation target channel
  78483. * @param minFrame minimum animation frame
  78484. * @param maxFrame maximum animation frame
  78485. * @param fps frames per second of the animation
  78486. * @param inputs input key frames of the animation
  78487. * @param outputs output key frame data of the animation
  78488. * @param convertToRightHandedSystem converts the values to right-handed
  78489. * @param useQuaternion specifies if quaternions should be used
  78490. */
  78491. private static _CreateBakedAnimation;
  78492. private static _ConvertFactorToVector3OrQuaternion;
  78493. private static _SetInterpolatedValue;
  78494. /**
  78495. * Creates linear animation from the animation key frames
  78496. * @param babylonTransformNode BabylonJS mesh
  78497. * @param animation BabylonJS animation
  78498. * @param animationChannelTargetPath The target animation channel
  78499. * @param frameDelta The difference between the last and first frame of the animation
  78500. * @param inputs Array to store the key frame times
  78501. * @param outputs Array to store the key frame data
  78502. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78503. * @param useQuaternion Specifies if quaternions are used in the animation
  78504. */
  78505. private static _CreateLinearOrStepAnimation;
  78506. /**
  78507. * Creates cubic spline animation from the animation key frames
  78508. * @param babylonTransformNode BabylonJS mesh
  78509. * @param animation BabylonJS animation
  78510. * @param animationChannelTargetPath The target animation channel
  78511. * @param frameDelta The difference between the last and first frame of the animation
  78512. * @param inputs Array to store the key frame times
  78513. * @param outputs Array to store the key frame data
  78514. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78515. * @param useQuaternion Specifies if quaternions are used in the animation
  78516. */
  78517. private static _CreateCubicSplineAnimation;
  78518. private static _GetBasePositionRotationOrScale;
  78519. /**
  78520. * Adds a key frame value
  78521. * @param keyFrame
  78522. * @param animation
  78523. * @param outputs
  78524. * @param animationChannelTargetPath
  78525. * @param basePositionRotationOrScale
  78526. * @param convertToRightHandedSystem
  78527. * @param useQuaternion
  78528. */
  78529. private static _AddKeyframeValue;
  78530. /**
  78531. * Determine the interpolation based on the key frames
  78532. * @param keyFrames
  78533. * @param animationChannelTargetPath
  78534. * @param useQuaternion
  78535. */
  78536. private static _DeduceInterpolation;
  78537. /**
  78538. * Adds an input tangent or output tangent to the output data
  78539. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78540. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78541. * @param outputs The animation data by keyframe
  78542. * @param animationChannelTargetPath The target animation channel
  78543. * @param interpolation The interpolation type
  78544. * @param keyFrame The key frame with the animation data
  78545. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78546. * @param useQuaternion Specifies if quaternions are used
  78547. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78548. */
  78549. private static AddSplineTangent;
  78550. /**
  78551. * Get the minimum and maximum key frames' frame values
  78552. * @param keyFrames animation key frames
  78553. * @returns the minimum and maximum key frame value
  78554. */
  78555. private static calculateMinMaxKeyFrames;
  78556. }
  78557. }
  78558. declare module BABYLON.GLTF2.Exporter {
  78559. /** @hidden */
  78560. export var textureTransformPixelShader: {
  78561. name: string;
  78562. shader: string;
  78563. };
  78564. }
  78565. declare module BABYLON.GLTF2.Exporter.Extensions {
  78566. /**
  78567. * @hidden
  78568. */
  78569. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78570. private _recordedTextures;
  78571. /** Name of this extension */
  78572. readonly name: string;
  78573. /** Defines whether this extension is enabled */
  78574. enabled: boolean;
  78575. /** Defines whether this extension is required */
  78576. required: boolean;
  78577. /** Reference to the glTF exporter */
  78578. private _wasUsed;
  78579. constructor(exporter: _Exporter);
  78580. dispose(): void;
  78581. /** @hidden */
  78582. get wasUsed(): boolean;
  78583. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78584. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78585. /**
  78586. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78587. * @param babylonTexture
  78588. * @param offset
  78589. * @param rotation
  78590. * @param scale
  78591. * @param scene
  78592. */
  78593. private _textureTransformTextureAsync;
  78594. }
  78595. }
  78596. declare module BABYLON.GLTF2.Exporter.Extensions {
  78597. /**
  78598. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78599. */
  78600. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78601. /** The name of this extension. */
  78602. readonly name: string;
  78603. /** Defines whether this extension is enabled. */
  78604. enabled: boolean;
  78605. /** Defines whether this extension is required */
  78606. required: boolean;
  78607. /** Reference to the glTF exporter */
  78608. private _exporter;
  78609. private _lights;
  78610. /** @hidden */
  78611. constructor(exporter: _Exporter);
  78612. /** @hidden */
  78613. dispose(): void;
  78614. /** @hidden */
  78615. get wasUsed(): boolean;
  78616. /** @hidden */
  78617. onExporting(): void;
  78618. /**
  78619. * Define this method to modify the default behavior when exporting a node
  78620. * @param context The context when exporting the node
  78621. * @param node glTF node
  78622. * @param babylonNode BabylonJS node
  78623. * @param nodeMap Node mapping of unique id to glTF node index
  78624. * @returns nullable INode promise
  78625. */
  78626. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78627. [key: number]: number;
  78628. }): Promise<Nullable<INode>>;
  78629. }
  78630. }
  78631. declare module BABYLON.GLTF2.Exporter.Extensions {
  78632. /**
  78633. * @hidden
  78634. */
  78635. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78636. /** Name of this extension */
  78637. readonly name: string;
  78638. /** Defines whether this extension is enabled */
  78639. enabled: boolean;
  78640. /** Defines whether this extension is required */
  78641. required: boolean;
  78642. /** Reference to the glTF exporter */
  78643. private _textureInfos;
  78644. private _exportedTextures;
  78645. private _wasUsed;
  78646. constructor(exporter: _Exporter);
  78647. dispose(): void;
  78648. /** @hidden */
  78649. get wasUsed(): boolean;
  78650. private _getTextureIndex;
  78651. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78652. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78653. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78654. }
  78655. }
  78656. declare module BABYLON {
  78657. /**
  78658. * Class for generating STL data from a Babylon scene.
  78659. */
  78660. export class STLExport {
  78661. /**
  78662. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78663. * @param meshes list defines the mesh to serialize
  78664. * @param download triggers the automatic download of the file.
  78665. * @param fileName changes the downloads fileName.
  78666. * @param binary changes the STL to a binary type.
  78667. * @param isLittleEndian toggle for binary type exporter.
  78668. * @returns the STL as UTF8 string
  78669. */
  78670. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78671. }
  78672. }
  78673. declare module "babylonjs-gltf2interface" {
  78674. export = BABYLON.GLTF2;
  78675. }
  78676. /**
  78677. * Module for glTF 2.0 Interface
  78678. */
  78679. declare module BABYLON.GLTF2 {
  78680. /**
  78681. * The datatype of the components in the attribute
  78682. */
  78683. const enum AccessorComponentType {
  78684. /**
  78685. * Byte
  78686. */
  78687. BYTE = 5120,
  78688. /**
  78689. * Unsigned Byte
  78690. */
  78691. UNSIGNED_BYTE = 5121,
  78692. /**
  78693. * Short
  78694. */
  78695. SHORT = 5122,
  78696. /**
  78697. * Unsigned Short
  78698. */
  78699. UNSIGNED_SHORT = 5123,
  78700. /**
  78701. * Unsigned Int
  78702. */
  78703. UNSIGNED_INT = 5125,
  78704. /**
  78705. * Float
  78706. */
  78707. FLOAT = 5126,
  78708. }
  78709. /**
  78710. * Specifies if the attirbute is a scalar, vector, or matrix
  78711. */
  78712. const enum AccessorType {
  78713. /**
  78714. * Scalar
  78715. */
  78716. SCALAR = "SCALAR",
  78717. /**
  78718. * Vector2
  78719. */
  78720. VEC2 = "VEC2",
  78721. /**
  78722. * Vector3
  78723. */
  78724. VEC3 = "VEC3",
  78725. /**
  78726. * Vector4
  78727. */
  78728. VEC4 = "VEC4",
  78729. /**
  78730. * Matrix2x2
  78731. */
  78732. MAT2 = "MAT2",
  78733. /**
  78734. * Matrix3x3
  78735. */
  78736. MAT3 = "MAT3",
  78737. /**
  78738. * Matrix4x4
  78739. */
  78740. MAT4 = "MAT4",
  78741. }
  78742. /**
  78743. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78744. */
  78745. const enum AnimationChannelTargetPath {
  78746. /**
  78747. * Translation
  78748. */
  78749. TRANSLATION = "translation",
  78750. /**
  78751. * Rotation
  78752. */
  78753. ROTATION = "rotation",
  78754. /**
  78755. * Scale
  78756. */
  78757. SCALE = "scale",
  78758. /**
  78759. * Weights
  78760. */
  78761. WEIGHTS = "weights",
  78762. }
  78763. /**
  78764. * Interpolation algorithm
  78765. */
  78766. const enum AnimationSamplerInterpolation {
  78767. /**
  78768. * The animated values are linearly interpolated between keyframes
  78769. */
  78770. LINEAR = "LINEAR",
  78771. /**
  78772. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78773. */
  78774. STEP = "STEP",
  78775. /**
  78776. * The animation's interpolation is computed using a cubic spline with specified tangents
  78777. */
  78778. CUBICSPLINE = "CUBICSPLINE",
  78779. }
  78780. /**
  78781. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78782. */
  78783. const enum CameraType {
  78784. /**
  78785. * A perspective camera containing properties to create a perspective projection matrix
  78786. */
  78787. PERSPECTIVE = "perspective",
  78788. /**
  78789. * An orthographic camera containing properties to create an orthographic projection matrix
  78790. */
  78791. ORTHOGRAPHIC = "orthographic",
  78792. }
  78793. /**
  78794. * The mime-type of the image
  78795. */
  78796. const enum ImageMimeType {
  78797. /**
  78798. * JPEG Mime-type
  78799. */
  78800. JPEG = "image/jpeg",
  78801. /**
  78802. * PNG Mime-type
  78803. */
  78804. PNG = "image/png",
  78805. }
  78806. /**
  78807. * The alpha rendering mode of the material
  78808. */
  78809. const enum MaterialAlphaMode {
  78810. /**
  78811. * The alpha value is ignored and the rendered output is fully opaque
  78812. */
  78813. OPAQUE = "OPAQUE",
  78814. /**
  78815. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78816. */
  78817. MASK = "MASK",
  78818. /**
  78819. * 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)
  78820. */
  78821. BLEND = "BLEND",
  78822. }
  78823. /**
  78824. * The type of the primitives to render
  78825. */
  78826. const enum MeshPrimitiveMode {
  78827. /**
  78828. * Points
  78829. */
  78830. POINTS = 0,
  78831. /**
  78832. * Lines
  78833. */
  78834. LINES = 1,
  78835. /**
  78836. * Line Loop
  78837. */
  78838. LINE_LOOP = 2,
  78839. /**
  78840. * Line Strip
  78841. */
  78842. LINE_STRIP = 3,
  78843. /**
  78844. * Triangles
  78845. */
  78846. TRIANGLES = 4,
  78847. /**
  78848. * Triangle Strip
  78849. */
  78850. TRIANGLE_STRIP = 5,
  78851. /**
  78852. * Triangle Fan
  78853. */
  78854. TRIANGLE_FAN = 6,
  78855. }
  78856. /**
  78857. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78858. */
  78859. const enum TextureMagFilter {
  78860. /**
  78861. * Nearest
  78862. */
  78863. NEAREST = 9728,
  78864. /**
  78865. * Linear
  78866. */
  78867. LINEAR = 9729,
  78868. }
  78869. /**
  78870. * Minification filter. All valid values correspond to WebGL enums
  78871. */
  78872. const enum TextureMinFilter {
  78873. /**
  78874. * Nearest
  78875. */
  78876. NEAREST = 9728,
  78877. /**
  78878. * Linear
  78879. */
  78880. LINEAR = 9729,
  78881. /**
  78882. * Nearest Mip-Map Nearest
  78883. */
  78884. NEAREST_MIPMAP_NEAREST = 9984,
  78885. /**
  78886. * Linear Mipmap Nearest
  78887. */
  78888. LINEAR_MIPMAP_NEAREST = 9985,
  78889. /**
  78890. * Nearest Mipmap Linear
  78891. */
  78892. NEAREST_MIPMAP_LINEAR = 9986,
  78893. /**
  78894. * Linear Mipmap Linear
  78895. */
  78896. LINEAR_MIPMAP_LINEAR = 9987,
  78897. }
  78898. /**
  78899. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78900. */
  78901. const enum TextureWrapMode {
  78902. /**
  78903. * Clamp to Edge
  78904. */
  78905. CLAMP_TO_EDGE = 33071,
  78906. /**
  78907. * Mirrored Repeat
  78908. */
  78909. MIRRORED_REPEAT = 33648,
  78910. /**
  78911. * Repeat
  78912. */
  78913. REPEAT = 10497,
  78914. }
  78915. /**
  78916. * glTF Property
  78917. */
  78918. interface IProperty {
  78919. /**
  78920. * Dictionary object with extension-specific objects
  78921. */
  78922. extensions?: {
  78923. [key: string]: any;
  78924. };
  78925. /**
  78926. * Application-Specific data
  78927. */
  78928. extras?: any;
  78929. }
  78930. /**
  78931. * glTF Child of Root Property
  78932. */
  78933. interface IChildRootProperty extends IProperty {
  78934. /**
  78935. * The user-defined name of this object
  78936. */
  78937. name?: string;
  78938. }
  78939. /**
  78940. * Indices of those attributes that deviate from their initialization value
  78941. */
  78942. interface IAccessorSparseIndices extends IProperty {
  78943. /**
  78944. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78945. */
  78946. bufferView: number;
  78947. /**
  78948. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78949. */
  78950. byteOffset?: number;
  78951. /**
  78952. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78953. */
  78954. componentType: AccessorComponentType;
  78955. }
  78956. /**
  78957. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78958. */
  78959. interface IAccessorSparseValues extends IProperty {
  78960. /**
  78961. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78962. */
  78963. bufferView: number;
  78964. /**
  78965. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78966. */
  78967. byteOffset?: number;
  78968. }
  78969. /**
  78970. * Sparse storage of attributes that deviate from their initialization value
  78971. */
  78972. interface IAccessorSparse extends IProperty {
  78973. /**
  78974. * The number of attributes encoded in this sparse accessor
  78975. */
  78976. count: number;
  78977. /**
  78978. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78979. */
  78980. indices: IAccessorSparseIndices;
  78981. /**
  78982. * 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
  78983. */
  78984. values: IAccessorSparseValues;
  78985. }
  78986. /**
  78987. * 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
  78988. */
  78989. interface IAccessor extends IChildRootProperty {
  78990. /**
  78991. * The index of the bufferview
  78992. */
  78993. bufferView?: number;
  78994. /**
  78995. * The offset relative to the start of the bufferView in bytes
  78996. */
  78997. byteOffset?: number;
  78998. /**
  78999. * The datatype of components in the attribute
  79000. */
  79001. componentType: AccessorComponentType;
  79002. /**
  79003. * Specifies whether integer data values should be normalized
  79004. */
  79005. normalized?: boolean;
  79006. /**
  79007. * The number of attributes referenced by this accessor
  79008. */
  79009. count: number;
  79010. /**
  79011. * Specifies if the attribute is a scalar, vector, or matrix
  79012. */
  79013. type: AccessorType;
  79014. /**
  79015. * Maximum value of each component in this attribute
  79016. */
  79017. max?: number[];
  79018. /**
  79019. * Minimum value of each component in this attribute
  79020. */
  79021. min?: number[];
  79022. /**
  79023. * Sparse storage of attributes that deviate from their initialization value
  79024. */
  79025. sparse?: IAccessorSparse;
  79026. }
  79027. /**
  79028. * Targets an animation's sampler at a node's property
  79029. */
  79030. interface IAnimationChannel extends IProperty {
  79031. /**
  79032. * The index of a sampler in this animation used to compute the value for the target
  79033. */
  79034. sampler: number;
  79035. /**
  79036. * The index of the node and TRS property to target
  79037. */
  79038. target: IAnimationChannelTarget;
  79039. }
  79040. /**
  79041. * The index of the node and TRS property that an animation channel targets
  79042. */
  79043. interface IAnimationChannelTarget extends IProperty {
  79044. /**
  79045. * The index of the node to target
  79046. */
  79047. node: number;
  79048. /**
  79049. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79050. */
  79051. path: AnimationChannelTargetPath;
  79052. }
  79053. /**
  79054. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79055. */
  79056. interface IAnimationSampler extends IProperty {
  79057. /**
  79058. * The index of an accessor containing keyframe input values, e.g., time
  79059. */
  79060. input: number;
  79061. /**
  79062. * Interpolation algorithm
  79063. */
  79064. interpolation?: AnimationSamplerInterpolation;
  79065. /**
  79066. * The index of an accessor, containing keyframe output values
  79067. */
  79068. output: number;
  79069. }
  79070. /**
  79071. * A keyframe animation
  79072. */
  79073. interface IAnimation extends IChildRootProperty {
  79074. /**
  79075. * An array of channels, each of which targets an animation's sampler at a node's property
  79076. */
  79077. channels: IAnimationChannel[];
  79078. /**
  79079. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79080. */
  79081. samplers: IAnimationSampler[];
  79082. }
  79083. /**
  79084. * Metadata about the glTF asset
  79085. */
  79086. interface IAsset extends IChildRootProperty {
  79087. /**
  79088. * A copyright message suitable for display to credit the content creator
  79089. */
  79090. copyright?: string;
  79091. /**
  79092. * Tool that generated this glTF model. Useful for debugging
  79093. */
  79094. generator?: string;
  79095. /**
  79096. * The glTF version that this asset targets
  79097. */
  79098. version: string;
  79099. /**
  79100. * The minimum glTF version that this asset targets
  79101. */
  79102. minVersion?: string;
  79103. }
  79104. /**
  79105. * A buffer points to binary geometry, animation, or skins
  79106. */
  79107. interface IBuffer extends IChildRootProperty {
  79108. /**
  79109. * 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
  79110. */
  79111. uri?: string;
  79112. /**
  79113. * The length of the buffer in bytes
  79114. */
  79115. byteLength: number;
  79116. }
  79117. /**
  79118. * A view into a buffer generally representing a subset of the buffer
  79119. */
  79120. interface IBufferView extends IChildRootProperty {
  79121. /**
  79122. * The index of the buffer
  79123. */
  79124. buffer: number;
  79125. /**
  79126. * The offset into the buffer in bytes
  79127. */
  79128. byteOffset?: number;
  79129. /**
  79130. * The lenth of the bufferView in bytes
  79131. */
  79132. byteLength: number;
  79133. /**
  79134. * The stride, in bytes
  79135. */
  79136. byteStride?: number;
  79137. }
  79138. /**
  79139. * An orthographic camera containing properties to create an orthographic projection matrix
  79140. */
  79141. interface ICameraOrthographic extends IProperty {
  79142. /**
  79143. * The floating-point horizontal magnification of the view. Must not be zero
  79144. */
  79145. xmag: number;
  79146. /**
  79147. * The floating-point vertical magnification of the view. Must not be zero
  79148. */
  79149. ymag: number;
  79150. /**
  79151. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79152. */
  79153. zfar: number;
  79154. /**
  79155. * The floating-point distance to the near clipping plane
  79156. */
  79157. znear: number;
  79158. }
  79159. /**
  79160. * A perspective camera containing properties to create a perspective projection matrix
  79161. */
  79162. interface ICameraPerspective extends IProperty {
  79163. /**
  79164. * The floating-point aspect ratio of the field of view
  79165. */
  79166. aspectRatio?: number;
  79167. /**
  79168. * The floating-point vertical field of view in radians
  79169. */
  79170. yfov: number;
  79171. /**
  79172. * The floating-point distance to the far clipping plane
  79173. */
  79174. zfar?: number;
  79175. /**
  79176. * The floating-point distance to the near clipping plane
  79177. */
  79178. znear: number;
  79179. }
  79180. /**
  79181. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79182. */
  79183. interface ICamera extends IChildRootProperty {
  79184. /**
  79185. * An orthographic camera containing properties to create an orthographic projection matrix
  79186. */
  79187. orthographic?: ICameraOrthographic;
  79188. /**
  79189. * A perspective camera containing properties to create a perspective projection matrix
  79190. */
  79191. perspective?: ICameraPerspective;
  79192. /**
  79193. * Specifies if the camera uses a perspective or orthographic projection
  79194. */
  79195. type: CameraType;
  79196. }
  79197. /**
  79198. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79199. */
  79200. interface IImage extends IChildRootProperty {
  79201. /**
  79202. * 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
  79203. */
  79204. uri?: string;
  79205. /**
  79206. * The image's MIME type
  79207. */
  79208. mimeType?: ImageMimeType;
  79209. /**
  79210. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79211. */
  79212. bufferView?: number;
  79213. }
  79214. /**
  79215. * Material Normal Texture Info
  79216. */
  79217. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79218. /**
  79219. * The scalar multiplier applied to each normal vector of the normal texture
  79220. */
  79221. scale?: number;
  79222. }
  79223. /**
  79224. * Material Occlusion Texture Info
  79225. */
  79226. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79227. /**
  79228. * A scalar multiplier controlling the amount of occlusion applied
  79229. */
  79230. strength?: number;
  79231. }
  79232. /**
  79233. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79234. */
  79235. interface IMaterialPbrMetallicRoughness {
  79236. /**
  79237. * The material's base color factor
  79238. */
  79239. baseColorFactor?: number[];
  79240. /**
  79241. * The base color texture
  79242. */
  79243. baseColorTexture?: ITextureInfo;
  79244. /**
  79245. * The metalness of the material
  79246. */
  79247. metallicFactor?: number;
  79248. /**
  79249. * The roughness of the material
  79250. */
  79251. roughnessFactor?: number;
  79252. /**
  79253. * The metallic-roughness texture
  79254. */
  79255. metallicRoughnessTexture?: ITextureInfo;
  79256. }
  79257. /**
  79258. * The material appearance of a primitive
  79259. */
  79260. interface IMaterial extends IChildRootProperty {
  79261. /**
  79262. * 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
  79263. */
  79264. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79265. /**
  79266. * The normal map texture
  79267. */
  79268. normalTexture?: IMaterialNormalTextureInfo;
  79269. /**
  79270. * The occlusion map texture
  79271. */
  79272. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79273. /**
  79274. * The emissive map texture
  79275. */
  79276. emissiveTexture?: ITextureInfo;
  79277. /**
  79278. * 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
  79279. */
  79280. emissiveFactor?: number[];
  79281. /**
  79282. * The alpha rendering mode of the material
  79283. */
  79284. alphaMode?: MaterialAlphaMode;
  79285. /**
  79286. * The alpha cutoff value of the material
  79287. */
  79288. alphaCutoff?: number;
  79289. /**
  79290. * Specifies whether the material is double sided
  79291. */
  79292. doubleSided?: boolean;
  79293. }
  79294. /**
  79295. * Geometry to be rendered with the given material
  79296. */
  79297. interface IMeshPrimitive extends IProperty {
  79298. /**
  79299. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79300. */
  79301. attributes: {
  79302. [name: string]: number;
  79303. };
  79304. /**
  79305. * The index of the accessor that contains the indices
  79306. */
  79307. indices?: number;
  79308. /**
  79309. * The index of the material to apply to this primitive when rendering
  79310. */
  79311. material?: number;
  79312. /**
  79313. * The type of primitives to render. All valid values correspond to WebGL enums
  79314. */
  79315. mode?: MeshPrimitiveMode;
  79316. /**
  79317. * 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
  79318. */
  79319. targets?: {
  79320. [name: string]: number;
  79321. }[];
  79322. }
  79323. /**
  79324. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79325. */
  79326. interface IMesh extends IChildRootProperty {
  79327. /**
  79328. * An array of primitives, each defining geometry to be rendered with a material
  79329. */
  79330. primitives: IMeshPrimitive[];
  79331. /**
  79332. * Array of weights to be applied to the Morph Targets
  79333. */
  79334. weights?: number[];
  79335. }
  79336. /**
  79337. * A node in the node hierarchy
  79338. */
  79339. interface INode extends IChildRootProperty {
  79340. /**
  79341. * The index of the camera referenced by this node
  79342. */
  79343. camera?: number;
  79344. /**
  79345. * The indices of this node's children
  79346. */
  79347. children?: number[];
  79348. /**
  79349. * The index of the skin referenced by this node
  79350. */
  79351. skin?: number;
  79352. /**
  79353. * A floating-point 4x4 transformation matrix stored in column-major order
  79354. */
  79355. matrix?: number[];
  79356. /**
  79357. * The index of the mesh in this node
  79358. */
  79359. mesh?: number;
  79360. /**
  79361. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79362. */
  79363. rotation?: number[];
  79364. /**
  79365. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79366. */
  79367. scale?: number[];
  79368. /**
  79369. * The node's translation along the x, y, and z axes
  79370. */
  79371. translation?: number[];
  79372. /**
  79373. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79374. */
  79375. weights?: number[];
  79376. }
  79377. /**
  79378. * Texture sampler properties for filtering and wrapping modes
  79379. */
  79380. interface ISampler extends IChildRootProperty {
  79381. /**
  79382. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79383. */
  79384. magFilter?: TextureMagFilter;
  79385. /**
  79386. * Minification filter. All valid values correspond to WebGL enums
  79387. */
  79388. minFilter?: TextureMinFilter;
  79389. /**
  79390. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79391. */
  79392. wrapS?: TextureWrapMode;
  79393. /**
  79394. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79395. */
  79396. wrapT?: TextureWrapMode;
  79397. }
  79398. /**
  79399. * The root nodes of a scene
  79400. */
  79401. interface IScene extends IChildRootProperty {
  79402. /**
  79403. * The indices of each root node
  79404. */
  79405. nodes: number[];
  79406. }
  79407. /**
  79408. * Joints and matrices defining a skin
  79409. */
  79410. interface ISkin extends IChildRootProperty {
  79411. /**
  79412. * 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
  79413. */
  79414. inverseBindMatrices?: number;
  79415. /**
  79416. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79417. */
  79418. skeleton?: number;
  79419. /**
  79420. * 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)
  79421. */
  79422. joints: number[];
  79423. }
  79424. /**
  79425. * A texture and its sampler
  79426. */
  79427. interface ITexture extends IChildRootProperty {
  79428. /**
  79429. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79430. */
  79431. sampler?: number;
  79432. /**
  79433. * The index of the image used by this texture
  79434. */
  79435. source: number;
  79436. }
  79437. /**
  79438. * Reference to a texture
  79439. */
  79440. interface ITextureInfo extends IProperty {
  79441. /**
  79442. * The index of the texture
  79443. */
  79444. index: number;
  79445. /**
  79446. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79447. */
  79448. texCoord?: number;
  79449. }
  79450. /**
  79451. * The root object for a glTF asset
  79452. */
  79453. interface IGLTF extends IProperty {
  79454. /**
  79455. * An array of accessors. An accessor is a typed view into a bufferView
  79456. */
  79457. accessors?: IAccessor[];
  79458. /**
  79459. * An array of keyframe animations
  79460. */
  79461. animations?: IAnimation[];
  79462. /**
  79463. * Metadata about the glTF asset
  79464. */
  79465. asset: IAsset;
  79466. /**
  79467. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79468. */
  79469. buffers?: IBuffer[];
  79470. /**
  79471. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79472. */
  79473. bufferViews?: IBufferView[];
  79474. /**
  79475. * An array of cameras
  79476. */
  79477. cameras?: ICamera[];
  79478. /**
  79479. * Names of glTF extensions used somewhere in this asset
  79480. */
  79481. extensionsUsed?: string[];
  79482. /**
  79483. * Names of glTF extensions required to properly load this asset
  79484. */
  79485. extensionsRequired?: string[];
  79486. /**
  79487. * An array of images. An image defines data used to create a texture
  79488. */
  79489. images?: IImage[];
  79490. /**
  79491. * An array of materials. A material defines the appearance of a primitive
  79492. */
  79493. materials?: IMaterial[];
  79494. /**
  79495. * An array of meshes. A mesh is a set of primitives to be rendered
  79496. */
  79497. meshes?: IMesh[];
  79498. /**
  79499. * An array of nodes
  79500. */
  79501. nodes?: INode[];
  79502. /**
  79503. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79504. */
  79505. samplers?: ISampler[];
  79506. /**
  79507. * The index of the default scene
  79508. */
  79509. scene?: number;
  79510. /**
  79511. * An array of scenes
  79512. */
  79513. scenes?: IScene[];
  79514. /**
  79515. * An array of skins. A skin is defined by joints and matrices
  79516. */
  79517. skins?: ISkin[];
  79518. /**
  79519. * An array of textures
  79520. */
  79521. textures?: ITexture[];
  79522. }
  79523. /**
  79524. * The glTF validation results
  79525. * @ignore
  79526. */
  79527. interface IGLTFValidationResults {
  79528. info: {
  79529. generator: string;
  79530. hasAnimations: boolean;
  79531. hasDefaultScene: boolean;
  79532. hasMaterials: boolean;
  79533. hasMorphTargets: boolean;
  79534. hasSkins: boolean;
  79535. hasTextures: boolean;
  79536. maxAttributesUsed: number;
  79537. primitivesCount: number
  79538. };
  79539. issues: {
  79540. messages: Array<string>;
  79541. numErrors: number;
  79542. numHints: number;
  79543. numInfos: number;
  79544. numWarnings: number;
  79545. truncated: boolean
  79546. };
  79547. mimeType: string;
  79548. uri: string;
  79549. validatedAt: string;
  79550. validatorVersion: string;
  79551. }
  79552. /**
  79553. * The glTF validation options
  79554. */
  79555. interface IGLTFValidationOptions {
  79556. /** Uri to use */
  79557. uri?: string;
  79558. /** Function used to load external resources */
  79559. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79560. /** Boolean indicating that we need to validate accessor data */
  79561. validateAccessorData?: boolean;
  79562. /** max number of issues allowed */
  79563. maxIssues?: number;
  79564. /** Ignored issues */
  79565. ignoredIssues?: Array<string>;
  79566. /** Value to override severy settings */
  79567. severityOverrides?: Object;
  79568. }
  79569. /**
  79570. * The glTF validator object
  79571. * @ignore
  79572. */
  79573. interface IGLTFValidator {
  79574. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79575. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79576. }
  79577. }
  79578. declare module BABYLON {
  79579. /** @hidden */
  79580. export var cellPixelShader: {
  79581. name: string;
  79582. shader: string;
  79583. };
  79584. }
  79585. declare module BABYLON {
  79586. /** @hidden */
  79587. export var cellVertexShader: {
  79588. name: string;
  79589. shader: string;
  79590. };
  79591. }
  79592. declare module BABYLON {
  79593. export class CellMaterial extends BABYLON.PushMaterial {
  79594. private _diffuseTexture;
  79595. diffuseTexture: BABYLON.BaseTexture;
  79596. diffuseColor: BABYLON.Color3;
  79597. _computeHighLevel: boolean;
  79598. computeHighLevel: boolean;
  79599. private _disableLighting;
  79600. disableLighting: boolean;
  79601. private _maxSimultaneousLights;
  79602. maxSimultaneousLights: number;
  79603. constructor(name: string, scene: BABYLON.Scene);
  79604. needAlphaBlending(): boolean;
  79605. needAlphaTesting(): boolean;
  79606. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79607. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79608. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79609. getAnimatables(): BABYLON.IAnimatable[];
  79610. getActiveTextures(): BABYLON.BaseTexture[];
  79611. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79612. dispose(forceDisposeEffect?: boolean): void;
  79613. getClassName(): string;
  79614. clone(name: string): CellMaterial;
  79615. serialize(): any;
  79616. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79617. }
  79618. }
  79619. declare module BABYLON {
  79620. export class CustomShaderStructure {
  79621. FragmentStore: string;
  79622. VertexStore: string;
  79623. constructor();
  79624. }
  79625. export class ShaderSpecialParts {
  79626. constructor();
  79627. Fragment_Begin: string;
  79628. Fragment_Definitions: string;
  79629. Fragment_MainBegin: string;
  79630. Fragment_Custom_Diffuse: string;
  79631. Fragment_Before_Lights: string;
  79632. Fragment_Before_Fog: string;
  79633. Fragment_Custom_Alpha: string;
  79634. Fragment_Before_FragColor: string;
  79635. Vertex_Begin: string;
  79636. Vertex_Definitions: string;
  79637. Vertex_MainBegin: string;
  79638. Vertex_Before_PositionUpdated: string;
  79639. Vertex_Before_NormalUpdated: string;
  79640. Vertex_MainEnd: string;
  79641. }
  79642. export class CustomMaterial extends BABYLON.StandardMaterial {
  79643. static ShaderIndexer: number;
  79644. CustomParts: ShaderSpecialParts;
  79645. _isCreatedShader: boolean;
  79646. _createdShaderName: string;
  79647. _customUniform: string[];
  79648. _newUniforms: string[];
  79649. _newUniformInstances: any[];
  79650. _newSamplerInstances: BABYLON.Texture[];
  79651. _customAttributes: string[];
  79652. FragmentShader: string;
  79653. VertexShader: string;
  79654. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79655. ReviewUniform(name: string, arr: string[]): string[];
  79656. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79657. constructor(name: string, scene: BABYLON.Scene);
  79658. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79659. AddAttribute(name: string): CustomMaterial;
  79660. Fragment_Begin(shaderPart: string): CustomMaterial;
  79661. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79662. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79663. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79664. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79665. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79666. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79667. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79668. Vertex_Begin(shaderPart: string): CustomMaterial;
  79669. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79670. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79671. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79672. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79673. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79674. }
  79675. }
  79676. declare module BABYLON {
  79677. export class ShaderAlebdoParts {
  79678. constructor();
  79679. Fragment_Begin: string;
  79680. Fragment_Definitions: string;
  79681. Fragment_MainBegin: string;
  79682. Fragment_Custom_Albedo: string;
  79683. Fragment_Before_Lights: string;
  79684. Fragment_Custom_MetallicRoughness: string;
  79685. Fragment_Custom_MicroSurface: string;
  79686. Fragment_Before_Fog: string;
  79687. Fragment_Custom_Alpha: string;
  79688. Fragment_Before_FragColor: string;
  79689. Vertex_Begin: string;
  79690. Vertex_Definitions: string;
  79691. Vertex_MainBegin: string;
  79692. Vertex_Before_PositionUpdated: string;
  79693. Vertex_Before_NormalUpdated: string;
  79694. Vertex_MainEnd: string;
  79695. }
  79696. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79697. static ShaderIndexer: number;
  79698. CustomParts: ShaderAlebdoParts;
  79699. _isCreatedShader: boolean;
  79700. _createdShaderName: string;
  79701. _customUniform: string[];
  79702. _newUniforms: string[];
  79703. _newUniformInstances: any[];
  79704. _newSamplerInstances: BABYLON.Texture[];
  79705. _customAttributes: string[];
  79706. FragmentShader: string;
  79707. VertexShader: string;
  79708. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79709. ReviewUniform(name: string, arr: string[]): string[];
  79710. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79711. constructor(name: string, scene: BABYLON.Scene);
  79712. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79713. AddAttribute(name: string): PBRCustomMaterial;
  79714. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79715. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79716. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79717. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79718. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79719. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79720. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79721. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79722. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79723. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79724. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79725. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79726. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79727. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79728. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79729. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79730. }
  79731. }
  79732. declare module BABYLON {
  79733. /** @hidden */
  79734. export var firePixelShader: {
  79735. name: string;
  79736. shader: string;
  79737. };
  79738. }
  79739. declare module BABYLON {
  79740. /** @hidden */
  79741. export var fireVertexShader: {
  79742. name: string;
  79743. shader: string;
  79744. };
  79745. }
  79746. declare module BABYLON {
  79747. export class FireMaterial extends BABYLON.PushMaterial {
  79748. private _diffuseTexture;
  79749. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79750. private _distortionTexture;
  79751. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79752. private _opacityTexture;
  79753. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79754. diffuseColor: BABYLON.Color3;
  79755. speed: number;
  79756. private _scaledDiffuse;
  79757. private _lastTime;
  79758. constructor(name: string, scene: BABYLON.Scene);
  79759. needAlphaBlending(): boolean;
  79760. needAlphaTesting(): boolean;
  79761. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79762. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79763. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79764. getAnimatables(): BABYLON.IAnimatable[];
  79765. getActiveTextures(): BABYLON.BaseTexture[];
  79766. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79767. getClassName(): string;
  79768. dispose(forceDisposeEffect?: boolean): void;
  79769. clone(name: string): FireMaterial;
  79770. serialize(): any;
  79771. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79772. }
  79773. }
  79774. declare module BABYLON {
  79775. /** @hidden */
  79776. export var furPixelShader: {
  79777. name: string;
  79778. shader: string;
  79779. };
  79780. }
  79781. declare module BABYLON {
  79782. /** @hidden */
  79783. export var furVertexShader: {
  79784. name: string;
  79785. shader: string;
  79786. };
  79787. }
  79788. declare module BABYLON {
  79789. export class FurMaterial extends BABYLON.PushMaterial {
  79790. private _diffuseTexture;
  79791. diffuseTexture: BABYLON.BaseTexture;
  79792. private _heightTexture;
  79793. heightTexture: BABYLON.BaseTexture;
  79794. diffuseColor: BABYLON.Color3;
  79795. furLength: number;
  79796. furAngle: number;
  79797. furColor: BABYLON.Color3;
  79798. furOffset: number;
  79799. furSpacing: number;
  79800. furGravity: BABYLON.Vector3;
  79801. furSpeed: number;
  79802. furDensity: number;
  79803. furOcclusion: number;
  79804. furTexture: BABYLON.DynamicTexture;
  79805. private _disableLighting;
  79806. disableLighting: boolean;
  79807. private _maxSimultaneousLights;
  79808. maxSimultaneousLights: number;
  79809. highLevelFur: boolean;
  79810. _meshes: BABYLON.AbstractMesh[];
  79811. private _furTime;
  79812. constructor(name: string, scene: BABYLON.Scene);
  79813. get furTime(): number;
  79814. set furTime(furTime: number);
  79815. needAlphaBlending(): boolean;
  79816. needAlphaTesting(): boolean;
  79817. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79818. updateFur(): void;
  79819. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79820. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79821. getAnimatables(): BABYLON.IAnimatable[];
  79822. getActiveTextures(): BABYLON.BaseTexture[];
  79823. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79824. dispose(forceDisposeEffect?: boolean): void;
  79825. clone(name: string): FurMaterial;
  79826. serialize(): any;
  79827. getClassName(): string;
  79828. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79829. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79830. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79831. }
  79832. }
  79833. declare module BABYLON {
  79834. /** @hidden */
  79835. export var gradientPixelShader: {
  79836. name: string;
  79837. shader: string;
  79838. };
  79839. }
  79840. declare module BABYLON {
  79841. /** @hidden */
  79842. export var gradientVertexShader: {
  79843. name: string;
  79844. shader: string;
  79845. };
  79846. }
  79847. declare module BABYLON {
  79848. export class GradientMaterial extends BABYLON.PushMaterial {
  79849. private _maxSimultaneousLights;
  79850. maxSimultaneousLights: number;
  79851. topColor: BABYLON.Color3;
  79852. topColorAlpha: number;
  79853. bottomColor: BABYLON.Color3;
  79854. bottomColorAlpha: number;
  79855. offset: number;
  79856. scale: number;
  79857. smoothness: number;
  79858. private _disableLighting;
  79859. disableLighting: boolean;
  79860. constructor(name: string, scene: BABYLON.Scene);
  79861. needAlphaBlending(): boolean;
  79862. needAlphaTesting(): boolean;
  79863. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79864. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79865. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79866. getAnimatables(): BABYLON.IAnimatable[];
  79867. dispose(forceDisposeEffect?: boolean): void;
  79868. clone(name: string): GradientMaterial;
  79869. serialize(): any;
  79870. getClassName(): string;
  79871. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79872. }
  79873. }
  79874. declare module BABYLON {
  79875. /** @hidden */
  79876. export var gridPixelShader: {
  79877. name: string;
  79878. shader: string;
  79879. };
  79880. }
  79881. declare module BABYLON {
  79882. /** @hidden */
  79883. export var gridVertexShader: {
  79884. name: string;
  79885. shader: string;
  79886. };
  79887. }
  79888. declare module BABYLON {
  79889. /**
  79890. * The grid materials allows you to wrap any shape with a grid.
  79891. * Colors are customizable.
  79892. */
  79893. export class GridMaterial extends BABYLON.PushMaterial {
  79894. /**
  79895. * Main color of the grid (e.g. between lines)
  79896. */
  79897. mainColor: BABYLON.Color3;
  79898. /**
  79899. * Color of the grid lines.
  79900. */
  79901. lineColor: BABYLON.Color3;
  79902. /**
  79903. * The scale of the grid compared to unit.
  79904. */
  79905. gridRatio: number;
  79906. /**
  79907. * Allows setting an offset for the grid lines.
  79908. */
  79909. gridOffset: BABYLON.Vector3;
  79910. /**
  79911. * The frequency of thicker lines.
  79912. */
  79913. majorUnitFrequency: number;
  79914. /**
  79915. * The visibility of minor units in the grid.
  79916. */
  79917. minorUnitVisibility: number;
  79918. /**
  79919. * The grid opacity outside of the lines.
  79920. */
  79921. opacity: number;
  79922. /**
  79923. * Determine RBG output is premultiplied by alpha value.
  79924. */
  79925. preMultiplyAlpha: boolean;
  79926. private _opacityTexture;
  79927. opacityTexture: BABYLON.BaseTexture;
  79928. private _gridControl;
  79929. /**
  79930. * constructor
  79931. * @param name The name given to the material in order to identify it afterwards.
  79932. * @param scene The scene the material is used in.
  79933. */
  79934. constructor(name: string, scene: BABYLON.Scene);
  79935. /**
  79936. * Returns wehter or not the grid requires alpha blending.
  79937. */
  79938. needAlphaBlending(): boolean;
  79939. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79940. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79941. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79942. /**
  79943. * Dispose the material and its associated resources.
  79944. * @param forceDisposeEffect will also dispose the used effect when true
  79945. */
  79946. dispose(forceDisposeEffect?: boolean): void;
  79947. clone(name: string): GridMaterial;
  79948. serialize(): any;
  79949. getClassName(): string;
  79950. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79951. }
  79952. }
  79953. declare module BABYLON {
  79954. /** @hidden */
  79955. export var lavaPixelShader: {
  79956. name: string;
  79957. shader: string;
  79958. };
  79959. }
  79960. declare module BABYLON {
  79961. /** @hidden */
  79962. export var lavaVertexShader: {
  79963. name: string;
  79964. shader: string;
  79965. };
  79966. }
  79967. declare module BABYLON {
  79968. export class LavaMaterial extends BABYLON.PushMaterial {
  79969. private _diffuseTexture;
  79970. diffuseTexture: BABYLON.BaseTexture;
  79971. noiseTexture: BABYLON.BaseTexture;
  79972. fogColor: BABYLON.Color3;
  79973. speed: number;
  79974. movingSpeed: number;
  79975. lowFrequencySpeed: number;
  79976. fogDensity: number;
  79977. private _lastTime;
  79978. diffuseColor: BABYLON.Color3;
  79979. private _disableLighting;
  79980. disableLighting: boolean;
  79981. private _unlit;
  79982. unlit: boolean;
  79983. private _maxSimultaneousLights;
  79984. maxSimultaneousLights: number;
  79985. private _scaledDiffuse;
  79986. constructor(name: string, scene: BABYLON.Scene);
  79987. needAlphaBlending(): boolean;
  79988. needAlphaTesting(): boolean;
  79989. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79990. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79991. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79992. getAnimatables(): BABYLON.IAnimatable[];
  79993. getActiveTextures(): BABYLON.BaseTexture[];
  79994. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79995. dispose(forceDisposeEffect?: boolean): void;
  79996. clone(name: string): LavaMaterial;
  79997. serialize(): any;
  79998. getClassName(): string;
  79999. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80000. }
  80001. }
  80002. declare module BABYLON {
  80003. /** @hidden */
  80004. export var mixPixelShader: {
  80005. name: string;
  80006. shader: string;
  80007. };
  80008. }
  80009. declare module BABYLON {
  80010. /** @hidden */
  80011. export var mixVertexShader: {
  80012. name: string;
  80013. shader: string;
  80014. };
  80015. }
  80016. declare module BABYLON {
  80017. export class MixMaterial extends BABYLON.PushMaterial {
  80018. /**
  80019. * Mix textures
  80020. */
  80021. private _mixTexture1;
  80022. mixTexture1: BABYLON.BaseTexture;
  80023. private _mixTexture2;
  80024. mixTexture2: BABYLON.BaseTexture;
  80025. /**
  80026. * Diffuse textures
  80027. */
  80028. private _diffuseTexture1;
  80029. diffuseTexture1: BABYLON.Texture;
  80030. private _diffuseTexture2;
  80031. diffuseTexture2: BABYLON.Texture;
  80032. private _diffuseTexture3;
  80033. diffuseTexture3: BABYLON.Texture;
  80034. private _diffuseTexture4;
  80035. diffuseTexture4: BABYLON.Texture;
  80036. private _diffuseTexture5;
  80037. diffuseTexture5: BABYLON.Texture;
  80038. private _diffuseTexture6;
  80039. diffuseTexture6: BABYLON.Texture;
  80040. private _diffuseTexture7;
  80041. diffuseTexture7: BABYLON.Texture;
  80042. private _diffuseTexture8;
  80043. diffuseTexture8: BABYLON.Texture;
  80044. /**
  80045. * Uniforms
  80046. */
  80047. diffuseColor: BABYLON.Color3;
  80048. specularColor: BABYLON.Color3;
  80049. specularPower: number;
  80050. private _disableLighting;
  80051. disableLighting: boolean;
  80052. private _maxSimultaneousLights;
  80053. maxSimultaneousLights: number;
  80054. constructor(name: string, scene: BABYLON.Scene);
  80055. needAlphaBlending(): boolean;
  80056. needAlphaTesting(): boolean;
  80057. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80058. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80059. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80060. getAnimatables(): BABYLON.IAnimatable[];
  80061. getActiveTextures(): BABYLON.BaseTexture[];
  80062. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80063. dispose(forceDisposeEffect?: boolean): void;
  80064. clone(name: string): MixMaterial;
  80065. serialize(): any;
  80066. getClassName(): string;
  80067. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80068. }
  80069. }
  80070. declare module BABYLON {
  80071. /** @hidden */
  80072. export var normalPixelShader: {
  80073. name: string;
  80074. shader: string;
  80075. };
  80076. }
  80077. declare module BABYLON {
  80078. /** @hidden */
  80079. export var normalVertexShader: {
  80080. name: string;
  80081. shader: string;
  80082. };
  80083. }
  80084. declare module BABYLON {
  80085. export class NormalMaterial extends BABYLON.PushMaterial {
  80086. private _diffuseTexture;
  80087. diffuseTexture: BABYLON.BaseTexture;
  80088. diffuseColor: BABYLON.Color3;
  80089. private _disableLighting;
  80090. disableLighting: boolean;
  80091. private _maxSimultaneousLights;
  80092. maxSimultaneousLights: number;
  80093. constructor(name: string, scene: BABYLON.Scene);
  80094. needAlphaBlending(): boolean;
  80095. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80096. needAlphaTesting(): boolean;
  80097. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80098. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80099. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80100. getAnimatables(): BABYLON.IAnimatable[];
  80101. getActiveTextures(): BABYLON.BaseTexture[];
  80102. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80103. dispose(forceDisposeEffect?: boolean): void;
  80104. clone(name: string): NormalMaterial;
  80105. serialize(): any;
  80106. getClassName(): string;
  80107. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80108. }
  80109. }
  80110. declare module BABYLON {
  80111. /** @hidden */
  80112. export var shadowOnlyPixelShader: {
  80113. name: string;
  80114. shader: string;
  80115. };
  80116. }
  80117. declare module BABYLON {
  80118. /** @hidden */
  80119. export var shadowOnlyVertexShader: {
  80120. name: string;
  80121. shader: string;
  80122. };
  80123. }
  80124. declare module BABYLON {
  80125. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80126. private _activeLight;
  80127. constructor(name: string, scene: BABYLON.Scene);
  80128. shadowColor: BABYLON.Color3;
  80129. needAlphaBlending(): boolean;
  80130. needAlphaTesting(): boolean;
  80131. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80132. get activeLight(): BABYLON.IShadowLight;
  80133. set activeLight(light: BABYLON.IShadowLight);
  80134. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80135. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80136. clone(name: string): ShadowOnlyMaterial;
  80137. serialize(): any;
  80138. getClassName(): string;
  80139. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80140. }
  80141. }
  80142. declare module BABYLON {
  80143. /** @hidden */
  80144. export var simplePixelShader: {
  80145. name: string;
  80146. shader: string;
  80147. };
  80148. }
  80149. declare module BABYLON {
  80150. /** @hidden */
  80151. export var simpleVertexShader: {
  80152. name: string;
  80153. shader: string;
  80154. };
  80155. }
  80156. declare module BABYLON {
  80157. export class SimpleMaterial extends BABYLON.PushMaterial {
  80158. private _diffuseTexture;
  80159. diffuseTexture: BABYLON.BaseTexture;
  80160. diffuseColor: BABYLON.Color3;
  80161. private _disableLighting;
  80162. disableLighting: boolean;
  80163. private _maxSimultaneousLights;
  80164. maxSimultaneousLights: number;
  80165. constructor(name: string, scene: BABYLON.Scene);
  80166. needAlphaBlending(): boolean;
  80167. needAlphaTesting(): boolean;
  80168. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80169. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80170. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80171. getAnimatables(): BABYLON.IAnimatable[];
  80172. getActiveTextures(): BABYLON.BaseTexture[];
  80173. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80174. dispose(forceDisposeEffect?: boolean): void;
  80175. clone(name: string): SimpleMaterial;
  80176. serialize(): any;
  80177. getClassName(): string;
  80178. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80179. }
  80180. }
  80181. declare module BABYLON {
  80182. /** @hidden */
  80183. export var skyPixelShader: {
  80184. name: string;
  80185. shader: string;
  80186. };
  80187. }
  80188. declare module BABYLON {
  80189. /** @hidden */
  80190. export var skyVertexShader: {
  80191. name: string;
  80192. shader: string;
  80193. };
  80194. }
  80195. declare module BABYLON {
  80196. /**
  80197. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80198. * @see https://doc.babylonjs.com/extensions/sky
  80199. */
  80200. export class SkyMaterial extends BABYLON.PushMaterial {
  80201. /**
  80202. * Defines the overall luminance of sky in interval ]0, 1[.
  80203. */
  80204. luminance: number;
  80205. /**
  80206. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80207. */
  80208. turbidity: number;
  80209. /**
  80210. * Defines the sky appearance (light intensity).
  80211. */
  80212. rayleigh: number;
  80213. /**
  80214. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80215. */
  80216. mieCoefficient: number;
  80217. /**
  80218. * Defines the amount of haze particles following the Mie scattering theory.
  80219. */
  80220. mieDirectionalG: number;
  80221. /**
  80222. * Defines the distance of the sun according to the active scene camera.
  80223. */
  80224. distance: number;
  80225. /**
  80226. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80227. * "inclined".
  80228. */
  80229. inclination: number;
  80230. /**
  80231. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80232. * an object direction and a reference direction.
  80233. */
  80234. azimuth: number;
  80235. /**
  80236. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80237. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80238. */
  80239. sunPosition: BABYLON.Vector3;
  80240. /**
  80241. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80242. * .sunPosition property.
  80243. */
  80244. useSunPosition: boolean;
  80245. /**
  80246. * Defines an offset vector used to get a horizon offset.
  80247. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80248. */
  80249. cameraOffset: BABYLON.Vector3;
  80250. private _cameraPosition;
  80251. /**
  80252. * Instantiates a new sky material.
  80253. * This material allows to create dynamic and texture free
  80254. * effects for skyboxes by taking care of the atmosphere state.
  80255. * @see https://doc.babylonjs.com/extensions/sky
  80256. * @param name Define the name of the material in the scene
  80257. * @param scene Define the scene the material belong to
  80258. */
  80259. constructor(name: string, scene: BABYLON.Scene);
  80260. /**
  80261. * Specifies if the material will require alpha blending
  80262. * @returns a boolean specifying if alpha blending is needed
  80263. */
  80264. needAlphaBlending(): boolean;
  80265. /**
  80266. * Specifies if this material should be rendered in alpha test mode
  80267. * @returns false as the sky material doesn't need alpha testing.
  80268. */
  80269. needAlphaTesting(): boolean;
  80270. /**
  80271. * Get the texture used for alpha test purpose.
  80272. * @returns null as the sky material has no texture.
  80273. */
  80274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80275. /**
  80276. * Get if the submesh is ready to be used and all its information available.
  80277. * Child classes can use it to update shaders
  80278. * @param mesh defines the mesh to check
  80279. * @param subMesh defines which submesh to check
  80280. * @param useInstances specifies that instances should be used
  80281. * @returns a boolean indicating that the submesh is ready or not
  80282. */
  80283. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80284. /**
  80285. * Binds the submesh to this material by preparing the effect and shader to draw
  80286. * @param world defines the world transformation matrix
  80287. * @param mesh defines the mesh containing the submesh
  80288. * @param subMesh defines the submesh to bind the material to
  80289. */
  80290. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80291. /**
  80292. * Get the list of animatables in the material.
  80293. * @returns the list of animatables object used in the material
  80294. */
  80295. getAnimatables(): BABYLON.IAnimatable[];
  80296. /**
  80297. * Disposes the material
  80298. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80299. */
  80300. dispose(forceDisposeEffect?: boolean): void;
  80301. /**
  80302. * Makes a duplicate of the material, and gives it a new name
  80303. * @param name defines the new name for the duplicated material
  80304. * @returns the cloned material
  80305. */
  80306. clone(name: string): SkyMaterial;
  80307. /**
  80308. * Serializes this material in a JSON representation
  80309. * @returns the serialized material object
  80310. */
  80311. serialize(): any;
  80312. /**
  80313. * Gets the current class name of the material e.g. "SkyMaterial"
  80314. * Mainly use in serialization.
  80315. * @returns the class name
  80316. */
  80317. getClassName(): string;
  80318. /**
  80319. * Creates a sky material from parsed material data
  80320. * @param source defines the JSON representation of the material
  80321. * @param scene defines the hosting scene
  80322. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80323. * @returns a new sky material
  80324. */
  80325. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80326. }
  80327. }
  80328. declare module BABYLON {
  80329. /** @hidden */
  80330. export var terrainPixelShader: {
  80331. name: string;
  80332. shader: string;
  80333. };
  80334. }
  80335. declare module BABYLON {
  80336. /** @hidden */
  80337. export var terrainVertexShader: {
  80338. name: string;
  80339. shader: string;
  80340. };
  80341. }
  80342. declare module BABYLON {
  80343. export class TerrainMaterial extends BABYLON.PushMaterial {
  80344. private _mixTexture;
  80345. mixTexture: BABYLON.BaseTexture;
  80346. private _diffuseTexture1;
  80347. diffuseTexture1: BABYLON.Texture;
  80348. private _diffuseTexture2;
  80349. diffuseTexture2: BABYLON.Texture;
  80350. private _diffuseTexture3;
  80351. diffuseTexture3: BABYLON.Texture;
  80352. private _bumpTexture1;
  80353. bumpTexture1: BABYLON.Texture;
  80354. private _bumpTexture2;
  80355. bumpTexture2: BABYLON.Texture;
  80356. private _bumpTexture3;
  80357. bumpTexture3: BABYLON.Texture;
  80358. diffuseColor: BABYLON.Color3;
  80359. specularColor: BABYLON.Color3;
  80360. specularPower: number;
  80361. private _disableLighting;
  80362. disableLighting: boolean;
  80363. private _maxSimultaneousLights;
  80364. maxSimultaneousLights: number;
  80365. constructor(name: string, scene: BABYLON.Scene);
  80366. needAlphaBlending(): boolean;
  80367. needAlphaTesting(): boolean;
  80368. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80369. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80370. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80371. getAnimatables(): BABYLON.IAnimatable[];
  80372. getActiveTextures(): BABYLON.BaseTexture[];
  80373. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80374. dispose(forceDisposeEffect?: boolean): void;
  80375. clone(name: string): TerrainMaterial;
  80376. serialize(): any;
  80377. getClassName(): string;
  80378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80379. }
  80380. }
  80381. declare module BABYLON {
  80382. /** @hidden */
  80383. export var triplanarPixelShader: {
  80384. name: string;
  80385. shader: string;
  80386. };
  80387. }
  80388. declare module BABYLON {
  80389. /** @hidden */
  80390. export var triplanarVertexShader: {
  80391. name: string;
  80392. shader: string;
  80393. };
  80394. }
  80395. declare module BABYLON {
  80396. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80397. mixTexture: BABYLON.BaseTexture;
  80398. private _diffuseTextureX;
  80399. diffuseTextureX: BABYLON.BaseTexture;
  80400. private _diffuseTextureY;
  80401. diffuseTextureY: BABYLON.BaseTexture;
  80402. private _diffuseTextureZ;
  80403. diffuseTextureZ: BABYLON.BaseTexture;
  80404. private _normalTextureX;
  80405. normalTextureX: BABYLON.BaseTexture;
  80406. private _normalTextureY;
  80407. normalTextureY: BABYLON.BaseTexture;
  80408. private _normalTextureZ;
  80409. normalTextureZ: BABYLON.BaseTexture;
  80410. tileSize: number;
  80411. diffuseColor: BABYLON.Color3;
  80412. specularColor: BABYLON.Color3;
  80413. specularPower: number;
  80414. private _disableLighting;
  80415. disableLighting: boolean;
  80416. private _maxSimultaneousLights;
  80417. maxSimultaneousLights: number;
  80418. constructor(name: string, scene: BABYLON.Scene);
  80419. needAlphaBlending(): boolean;
  80420. needAlphaTesting(): boolean;
  80421. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80422. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80423. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80424. getAnimatables(): BABYLON.IAnimatable[];
  80425. getActiveTextures(): BABYLON.BaseTexture[];
  80426. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80427. dispose(forceDisposeEffect?: boolean): void;
  80428. clone(name: string): TriPlanarMaterial;
  80429. serialize(): any;
  80430. getClassName(): string;
  80431. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80432. }
  80433. }
  80434. declare module BABYLON {
  80435. /** @hidden */
  80436. export var waterPixelShader: {
  80437. name: string;
  80438. shader: string;
  80439. };
  80440. }
  80441. declare module BABYLON {
  80442. /** @hidden */
  80443. export var waterVertexShader: {
  80444. name: string;
  80445. shader: string;
  80446. };
  80447. }
  80448. declare module BABYLON {
  80449. export class WaterMaterial extends BABYLON.PushMaterial {
  80450. renderTargetSize: BABYLON.Vector2;
  80451. private _bumpTexture;
  80452. bumpTexture: BABYLON.BaseTexture;
  80453. diffuseColor: BABYLON.Color3;
  80454. specularColor: BABYLON.Color3;
  80455. specularPower: number;
  80456. private _disableLighting;
  80457. disableLighting: boolean;
  80458. private _maxSimultaneousLights;
  80459. maxSimultaneousLights: number;
  80460. /**
  80461. * @param {number}: Represents the wind force
  80462. */
  80463. windForce: number;
  80464. /**
  80465. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80466. */
  80467. windDirection: BABYLON.Vector2;
  80468. /**
  80469. * @param {number}: Wave height, represents the height of the waves
  80470. */
  80471. waveHeight: number;
  80472. /**
  80473. * @param {number}: Bump height, represents the bump height related to the bump map
  80474. */
  80475. bumpHeight: number;
  80476. /**
  80477. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80478. */
  80479. private _bumpSuperimpose;
  80480. bumpSuperimpose: boolean;
  80481. /**
  80482. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80483. */
  80484. private _fresnelSeparate;
  80485. fresnelSeparate: boolean;
  80486. /**
  80487. * @param {boolean}: bump Waves modify the reflection.
  80488. */
  80489. private _bumpAffectsReflection;
  80490. bumpAffectsReflection: boolean;
  80491. /**
  80492. * @param {number}: The water color blended with the refraction (near)
  80493. */
  80494. waterColor: BABYLON.Color3;
  80495. /**
  80496. * @param {number}: The blend factor related to the water color
  80497. */
  80498. colorBlendFactor: number;
  80499. /**
  80500. * @param {number}: The water color blended with the reflection (far)
  80501. */
  80502. waterColor2: BABYLON.Color3;
  80503. /**
  80504. * @param {number}: The blend factor related to the water color (reflection, far)
  80505. */
  80506. colorBlendFactor2: number;
  80507. /**
  80508. * @param {number}: Represents the maximum length of a wave
  80509. */
  80510. waveLength: number;
  80511. /**
  80512. * @param {number}: Defines the waves speed
  80513. */
  80514. waveSpeed: number;
  80515. /**
  80516. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80517. * will avoid calculating useless pixels in the pixel shader of the water material.
  80518. */
  80519. disableClipPlane: boolean;
  80520. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80521. private _mesh;
  80522. private _refractionRTT;
  80523. private _reflectionRTT;
  80524. private _reflectionTransform;
  80525. private _lastTime;
  80526. private _lastDeltaTime;
  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. }